commit 50885fcef3a7fb651110863dbfcc69372e182ff8
parent d99e339553b0914b861d1faccdc528e05a9e2e33
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Wed, 12 Oct 2016 08:38:54 +0200
Removed helpers from the sdk.
Diffstat:
2 files changed, 0 insertions(+), 368 deletions(-)
diff --git a/include/clap/helpers/serialize.c b/include/clap/helpers/serialize.c
@@ -1,251 +0,0 @@
-#include <string.h>
-
-static inline bool
-clap_serializer_dict(struct clap_serializer *s)
-{
- if (!s->out || s->out + 1 > s->out_end)
- return false;
- *s->out = CLAP_SERIALIZE_DICT;
- ++s->out;
- return true;
-}
-
-static inline bool
-clap_serializer_array(struct clap_serializer *s)
-{
- if (!s->out || s->out + 1 > s->out_end)
- return false;
- *s->out = CLAP_SERIALIZE_ARRAY;
- ++s->out;
- return true;
-}
-
-static inline bool
-clap_serializer_end(struct clap_serializer *s)
-{
- if (!s->out || s->out + 1 > s->out_end)
- return false;
- *s->out = CLAP_SERIALIZE_END;
- ++s->out;
- return true;
-}
-
-static inline bool
-clap_serializer_bool(struct clap_serializer *s, bool value)
-{
- if (!s->out || s->out + 2 > s->out_end)
- return false;
- s->out[0] = CLAP_SERIALIZE_BOOL;
- s->out[1] = value ? true : false; /* ensure bit 0 */
- s->out += 2;
- return true;
-}
-
-static inline bool
-clap_serializer_int8(struct clap_serializer *s, int8_t value)
-{
- if (!s->out || s->out + 2 > s->out_end)
- return false;
- s->out[0] = CLAP_SERIALIZE_INT8;
- s->out[1] = value;
- s->out += 2;
- return true;
-}
-
-static inline void
-clap_serializer_int16_priv(struct clap_serializer *s, int16_t value)
-{
- s->out[1] = value >> 8;
- s->out[2] = value;
-}
-
-static inline bool
-clap_serializer_int16(struct clap_serializer *s, int16_t value)
-{
- if (!s->out || s->out + 3 >= s->out_end)
- return false;
-
- *s->out = CLAP_SERIALIZE_INT16;
- clap_serializer_int16_priv(s, value);
- s->out += 3;
- return true;
-}
-
-static inline void
-clap_serializer_int32_priv(struct clap_serializer *s, int32_t value)
-{
- s->out[1] = value >> 24;
- s->out[2] = value >> 16;
- s->out[3] = value >> 8;
- s->out[4] = value;
-}
-
-static inline bool
-clap_serializer_int32(struct clap_serializer *s, int32_t value)
-{
- if (!s->out || s->out + 5 >= s->out_end)
- return false;
-
- *s->out = CLAP_SERIALIZE_INT32;
- clap_serializer_int32_priv(s, value);
- s->out += 5;
- return true;
-}
-
-static inline void
-clap_serializer_int64_priv(struct clap_serializer *s, int64_t value)
-{
- s->out[1] = value >> 56;
- s->out[2] = value >> 48;
- s->out[3] = value >> 40;
- s->out[4] = value >> 32;
- s->out[5] = value >> 24;
- s->out[6] = value >> 16;
- s->out[7] = value >> 8;
- s->out[8] = value;
-}
-
-static inline bool
-clap_serializer_int64(struct clap_serializer *s, int64_t value)
-{
- if (!s->out || s->out + 9 >= s->out_end)
- return false;
-
- *s->out = CLAP_SERIALIZE_INT64;
- clap_serializer_int64_priv(s, value);
- s->out += 9;
- return true;
-}
-
-static inline bool
-clap_serializer_float(struct clap_serializer *s, float value)
-{
- if (!s->out || s->out + 5 >= s->out_end)
- return false;
-
- union {
- float f;
- int32_t i;
- } u;
-
- u.f = value;
- *s->out = CLAP_SERIALIZE_FLOAT;
- clap_serializer_int32_priv(s, u.i);
- s->out += 5;
- return true;
-}
-
-static inline bool
-clap_serializer_float(struct clap_serializer *s, double value)
-{
- if (!s->out || s->out + 9 >= s->out_end)
- return false;
-
- union {
- double f;
- int64_t i;
- } u;
-
- u.f = value;
- *s->out = CLAP_SERIALIZE_DOUBLE;
- clap_serializer_int64_priv(s, u.i);
- s->out += 9;
- return true;
-}
-
-static inline bool
-clap_serializer_str(struct clap_serializer *s,
- const char *str,
- int32_t len)
-{
- if (!s->out || s->out + 5 + len >= s->out_end)
- return false;
-
- *s->out = CLAP_SERIALIZE_STR;
- clap_serializer_int32_priv(s, len);
- memcpy(s->out + 5, str, len);
- s->out += 5 + len;
- return true;
-}
-
-static inline bool
-clap_deserialize(struct clap_deserializer *d)
-{
- if (!d->in || !d->in_end || d->in >= d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
-
- d->type = (enum clap_serialize_type)*d->in;
- switch (d->type) {
- case CLAP_SERIALIZE_DICT:
- ++d->in;
- return true;
-
- case CLAP_SERIALIZE_ARRAY:
- ++d->in;
- return true;
-
- case CLAP_SERIALIZE_END:
- ++d->in;
- return true;
-
- case CLAP_SERIALIZE_BOOL:
- case CLAP_SERIALIZE_INT8:
- if (d->in + 5 > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->b = d->in[1];
- d->in += 2;
- return true;
-
- case CLAP_SERIALIZE_INT16:
- if (d->in + 3 > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->i16 = (d->in[3] << 8) | d->in[4];
- d->in += 3;
- return true;
-
- case CLAP_SERIALIZE_INT32:
- case CLAP_SERIALIZE_FLOAT:
- if (d->in + 5 > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->i32 = (d->in[1] << 24) | (d->in[2] << 16) | (d->in[3] << 8) | d->in[4];
- d->in += 5;
- return true;
-
- case CLAP_SERIALIZE_INT64:
- case CLAP_SERIALIZE_DOUBLE:
- if (d->in + 9 > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->i64 = (d->in[1] << 56) | (d->in[2] << 48) | (d->in[3] << 40) | (d->in[4] << 32) |
- (d->in[1] << 24) | (d->in[2] << 16) | (d->in[3] << 8) | d->in[4];
- d->in += 9;
- return true;
-
- case CLAP_SERIALIZE_STR:
- if (d->in + 5 > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->slen = (d->in[1] << 24) | (d->in[2] << 16) | (d->in[3] << 8) | d->in[4];
- if (d->in + 5 + d->slen > d->in_end) {
- d->type = CLAP_SERIALIZE_EOB;
- return false;
- }
- d->s = (const char *)d->in + 5;
- d->in = d->in + 5 + d->slen;
- return true;
-
- default:
- d->type = CLAP_SERIALIZE_ERROR;
- return false;
- }
-}
diff --git a/include/clap/helpers/serialize.h b/include/clap/helpers/serialize.h
@@ -1,117 +0,0 @@
-#ifndef CLAP_HELPERS_SERIALIZE_H
-# define CLAP_HELPERS_SERIALIZE_H
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-# include <stdint.h>
-
-enum clap_serialize_type
-{
- CLAP_SERIALIZE_EOB = 'B',
- CLAP_SERIALIZE_ERROR = 'E',
-
- CLAP_SERIALIZE_DICT = 'd',
- CLAP_SERIALIZE_ARRAY = 'a',
- CLAP_SERIALIZE_END = 'e',
- CLAP_SERIALIZE_STR = 's',
- CLAP_SERIALIZE_BOOL = 'b',
- CLAP_SERIALIZE_INT8 = 'c',
- CLAP_SERIALIZE_INT16 = 'j',
- CLAP_SERIALIZE_INT32 = 'i',
- CLAP_SERIALIZE_INT64 = 'l',
-
- /* IEEE 754 format */
- CLAP_SERIALIZE_FLOAT = 'f',
- CLAP_SERIALIZE_DOUBLE = 'g',
-};
-
-struct clap_serializer
-{
- /* output buffer */
- uint8_t *out;
- uint8_t *out_end;
-};
-
-/* Begins a dictionary. Returns false on EOB. */
-static inline bool
-clap_serializer_dict(struct clap_serializer *s);
-
-/* Begins an array. Returns false on EOB. */
-static inline bool
-clap_serializer_array(struct clap_serializer *s);
-
-/* Ends an array or dictionary. Returns false on EOB. */
-static inline bool
-clap_serializer_end(struct clap_serializer *s);
-
-/* Pushes a string. Returns false on EOB.
- * The string might not be null terminated. */
-static inline bool
-clap_serializer_str(struct clap_serializer *s,
- const char *str,
- int32_t len);
-
-/* Pushes an 8 bits integer. Returns false on EOB. */
-static inline bool
-clap_serializer_bool(struct clap_serializer *s, bool value);
-
-/* Pushes an 8 bits integer. Returns false on EOB. */
-static inline bool
-clap_serializer_int8(struct clap_serializer *s, int16_t value);
-
-/* Pushes an 16 bits integer. Returns false on EOB. */
-static inline bool
-clap_serializer_int16(struct clap_serializer *s, int16_t value);
-
-/* Pushes an 32 bits integer. Returns false on EOB. */
-static inline bool
-clap_serializer_int32(struct clap_serializer *s, int32_t value);
-
-/* Pushes an 64 bits integer. Returns false on EOB. */
-static inline bool
-clap_serializer_int64(struct clap_serializer *s, int64_t value);
-
-/* Pushes a float. Returns false on EOB. */
-static inline bool
-clap_serializer_float(struct clap_serializer *s, float value);
-
-/* Pushes a double. Returns false on EOB. */
-static inline bool
-clap_serializer_double(struct clap_serializer *s, double value);
-
-struct clap_deserializer
-{
- /* input buffer */
- const uint8_t *in;
- const uint8_t *in_end;
-
- /* decoded value */
- enum clap_serialize_type type;
- union {
- bool b;
- int8_t i8;
- int16_t i16;
- int32_t i32;
- int64_t i64;
- float f;
- double d;
- const char *s;
- };
- int32_t slen;
-};
-
-/* Decodes one token into *d.
- * Returns false if the type is: CLAP_SERIALIZE_{ERROR,EOB}.
- */
-static inline bool
-clap_deserialize(struct clap_deserializer *d);
-
-# include "serialize.c"
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif /* !CLAP_HELPERS_SERIALIZE_H */