slow_blink 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/ext/slow_blink/ext_schema_parser/lexer.c +2793 -839
  3. data/ext/slow_blink/ext_schema_parser/lexer.h +14 -137
  4. data/ext/slow_blink/ext_schema_parser/parser.c +616 -670
  5. data/ext/slow_blink/ext_schema_parser/parser.h +6 -4
  6. data/ext/slow_blink/message/ext_compact_encoder/blink_compact.c +642 -0
  7. data/ext/slow_blink/message/ext_compact_encoder/blink_compact.h +411 -0
  8. data/ext/slow_blink/message/ext_compact_encoder/blink_debug.h +46 -0
  9. data/ext/slow_blink/message/ext_compact_encoder/blink_stream.c +314 -0
  10. data/ext/slow_blink/message/ext_compact_encoder/blink_stream.h +185 -0
  11. data/ext/slow_blink/message/ext_compact_encoder/ext_compact_encoder.c +382 -269
  12. data/lib/slow_blink/definition.rb +18 -53
  13. data/lib/slow_blink/dynamic_group.rb +8 -0
  14. data/lib/slow_blink/enum.rb +101 -0
  15. data/lib/slow_blink/field.rb +63 -33
  16. data/lib/slow_blink/generate_c/model.rb +89 -0
  17. data/lib/slow_blink/group.rb +119 -100
  18. data/lib/slow_blink/message/binary.rb +3 -4
  19. data/lib/slow_blink/message/boolean.rb +3 -4
  20. data/lib/slow_blink/message/date.rb +3 -4
  21. data/lib/slow_blink/message/decimal.rb +3 -5
  22. data/lib/slow_blink/message/{enumeration.rb → enum.rb} +17 -17
  23. data/lib/slow_blink/message/field.rb +77 -27
  24. data/lib/slow_blink/message/fixed.rb +5 -21
  25. data/lib/slow_blink/message/floating_point.rb +3 -4
  26. data/lib/slow_blink/message/group.rb +90 -161
  27. data/lib/slow_blink/message/integer.rb +24 -32
  28. data/lib/slow_blink/message/model.rb +50 -110
  29. data/lib/slow_blink/message/string.rb +3 -4
  30. data/lib/slow_blink/message/time.rb +5 -5
  31. data/lib/slow_blink/message/time_of_day.rb +5 -12
  32. data/lib/slow_blink/ref.rb +22 -71
  33. data/lib/slow_blink/schema.rb +64 -85
  34. data/lib/slow_blink/schema_buffer.rb +1 -4
  35. data/lib/slow_blink/static_group.rb +37 -0
  36. data/lib/slow_blink/string.rb +4 -5
  37. data/lib/slow_blink/sym.rb +8 -28
  38. data/lib/slow_blink/type.rb +10 -19
  39. data/lib/slow_blink/version.rb +1 -1
  40. data/lib/slow_blink.rb +1 -0
  41. data/test/tc_compact_encoder.rb +114 -147
  42. data/test/tc_inputs.rb +2 -4
  43. data/test/tc_model_string.rb +29 -0
  44. data/test/tc_schema_new.rb +212 -0
  45. metadata +17 -26
  46. data/ext/slow_blink/ext_schema_parser/common.h +0 -27
  47. data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.c +0 -258
  48. data/ext/slow_blink/message/ext_compact_encoder/compact_encoder.h +0 -92
  49. data/lib/slow_blink/annotatable.rb +0 -48
  50. data/lib/slow_blink/annotation.rb +0 -47
  51. data/lib/slow_blink/enumeration.rb +0 -90
  52. data/lib/slow_blink/incremental_annotation.rb +0 -151
  53. data/lib/slow_blink/log.rb +0 -51
  54. data/lib/slow_blink/message/sequence.rb +0 -98
  55. data/lib/slow_blink/name_with_id.rb +0 -49
  56. data/lib/slow_blink/namespace.rb +0 -143
  57. data/lib/slow_blink/sequence.rb +0 -57
  58. data/test/tc_field.rb +0 -94
  59. data/test/tc_group.rb +0 -114
  60. data/test/tc_incr_annote.rb +0 -22
  61. data/test/tc_namespace.rb +0 -8
  62. data/test/tc_types.rb +0 -218
@@ -0,0 +1,411 @@
1
+ /* Copyright (c) 2016 Cameron Harper
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ * this software and associated documentation files (the "Software"), to deal in
5
+ * the Software without restriction, including without limitation the rights to
6
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ * the Software, and to permit persons to whom the Software is furnished to do so,
8
+ * subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all
11
+ * copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+ *
20
+ *
21
+ * */
22
+
23
+ #ifndef BLINK_COMPACT_H
24
+ #define BLINK_COMPACT_H
25
+
26
+ /**
27
+ * @defgroup blink_compact blink_compact
28
+ * @ingroup ublink
29
+ *
30
+ * Compact form encode/decode functions
31
+ *
32
+ * @{
33
+ * */
34
+
35
+ #ifdef __cplusplus
36
+ extern "C" {
37
+ #endif
38
+
39
+ /* includes ***********************************************************/
40
+
41
+ #include <stdint.h>
42
+ #include <stdbool.h>
43
+
44
+ /* typedefs ***********************************************************/
45
+
46
+ struct blink_stream;
47
+
48
+ typedef struct blink_stream * blink_stream_t;
49
+
50
+ /* functions **********************************************************/
51
+
52
+ /**
53
+ * Encode a null
54
+ *
55
+ * @param[in] out output stream
56
+ *
57
+ * @return null was encoded
58
+ * @retval true
59
+ * @retval false
60
+ *
61
+ * */
62
+ bool BLINK_Compact_encodeNull(blink_stream_t out);
63
+
64
+ /**
65
+ * Encode a present symbol
66
+ *
67
+ * @param[in] out output stream
68
+ *
69
+ * @return present was encoded
70
+ * @retval true
71
+ * @retval false
72
+ *
73
+ * */
74
+ bool BLINK_Compact_encodePresent(blink_stream_t out);
75
+
76
+ /**
77
+ * Decode `bool`
78
+ *
79
+ * @param[in] in input stream
80
+ * @param[out] out decoded value
81
+ * @param[out] isNull set to `true` if `in` decodes to NULL
82
+ *
83
+ * @return value was decoded
84
+ * @retval true
85
+ * @retval false
86
+ *
87
+ * */
88
+ bool BLINK_Compact_decodeBool(blink_stream_t in, bool *out, bool *isNull);
89
+
90
+ /**
91
+ * Decode `u8`
92
+ *
93
+ * @param[in] in input stream
94
+ * @param[out] out decoded value
95
+ * @param[out] isNull set to `true` if `in` decodes to NULL
96
+ *
97
+ * @return value was decoded
98
+ * @retval true
99
+ * @retval false
100
+ *
101
+ * */
102
+ bool BLINK_Compact_decodeU8(blink_stream_t in, uint8_t *out, bool *isNull);
103
+
104
+ /**
105
+ * Decode `u16`
106
+ *
107
+ * @param[in] in input stream
108
+ * @param[out] out decoded value
109
+ * @param[out] isNull set to `true` if `in` decodes to NULL
110
+ *
111
+ * @return value was decoded
112
+ * @retval true
113
+ * @retval false
114
+ *
115
+ * */
116
+ bool BLINK_Compact_decodeU16(blink_stream_t in, uint16_t *out, bool *isNull);
117
+
118
+ /**
119
+ * Decode `u32`
120
+ *
121
+ * @param[in] in input stream
122
+ * @param[out] out decoded value
123
+ * @param[out] isNull set to `true` if `in` decodes to NULL
124
+ *
125
+ * @return value was decoded
126
+ * @retval true
127
+ * @retval false
128
+ *
129
+ * */
130
+ bool BLINK_Compact_decodeU32(blink_stream_t in, uint32_t *out, bool *isNull);
131
+
132
+ /**
133
+ * Decode `u64`
134
+ *
135
+ * @param[in] in input stream
136
+ * @param[out] out decoded value
137
+ * @param[out] isNull set to `true` if `in` decodes to NULL
138
+ *
139
+ * @return value was decoded
140
+ * @retval true
141
+ * @retval false
142
+ *
143
+ * */
144
+ bool BLINK_Compact_decodeU64(blink_stream_t in, uint64_t *out, bool *isNull);
145
+
146
+ /**
147
+ * Decode `i8`
148
+ *
149
+ * @param[in] in input stream
150
+ * @param[out] out decoded value
151
+ * @param[out] isNull set to `true` if `in` decodes to NULL
152
+ *
153
+ * @return value was decoded
154
+ * @retval true
155
+ * @retval false
156
+ *
157
+ * */
158
+ bool BLINK_Compact_decodeI8(blink_stream_t in, int8_t *out, bool *isNull);
159
+
160
+ /**
161
+ * Decode `i16`
162
+ *
163
+ * @param[in] in input stream
164
+ * @param[out] out decoded value
165
+ * @param[out] isNull set to `true` if `in` decodes to NULL
166
+ *
167
+ * @return value was decoded
168
+ * @retval true
169
+ * @retval false
170
+ *
171
+ * */
172
+ bool BLINK_Compact_decodeI16(blink_stream_t in, int16_t *out, bool *isNull);
173
+
174
+ /**
175
+ * Decode `i32`
176
+ *
177
+ * @param[in] in input stream
178
+ * @param[out] out decoded value
179
+ * @param[out] isNull set to `true` if `in` decodes to NULL
180
+ *
181
+ * @return value was decoded
182
+ * @retval true
183
+ * @retval false
184
+ *
185
+ * */
186
+ bool BLINK_Compact_decodeI32(blink_stream_t in, int32_t *out, bool *isNull);
187
+
188
+ /**
189
+ * Decode `i64`
190
+ *
191
+ * @param[in] in input stream
192
+ * @param[out] out decoded value
193
+ * @param[out] isNull set to `true` if `in` decodes to NULL
194
+ *
195
+ * @return value was decoded
196
+ * @retval true
197
+ * @retval false
198
+ *
199
+ * */
200
+ bool BLINK_Compact_decodeI64(blink_stream_t in, int64_t *out, bool *isNull);
201
+
202
+ /**
203
+ * Decode `decimal`
204
+ *
205
+ * @param[in] in input stream
206
+ * @param[out] mantissa decoded mantissa
207
+ * @param[out] exponent decoded exponent
208
+ * @param[out] isNull set to `true` if `in` decodes to NULL
209
+ *
210
+ * @return value was decoded
211
+ * @retval true
212
+ * @retval false
213
+ *
214
+ * */
215
+ bool BLINK_Compact_decodeDecimal(blink_stream_t in, int64_t *mantissa, int8_t *exponent, bool *isNull);
216
+
217
+ /**
218
+ * Decode `f64`
219
+ *
220
+ * @param[in] in input stream
221
+ * @param[out] out value
222
+ * @param[out] isNull set to `true` if `in` decodes to NULL
223
+ *
224
+ * @return value was decoded
225
+ * @retval true
226
+ * @retval false
227
+ *
228
+ * */
229
+ bool BLINK_Compact_decodeF64(blink_stream_t in, double *out, bool *isNull);
230
+
231
+ /**
232
+ * Decode a present field
233
+ *
234
+ * @param[in] in input stream
235
+ * @param[out] out set to `true` if present
236
+ *
237
+ * @return value was decoded
238
+ * @retval true
239
+ * @retval false
240
+ *
241
+ * */
242
+ bool BLINK_Compact_decodePresent(blink_stream_t in, bool *out);
243
+
244
+ /**
245
+ * Encode `bool`
246
+ *
247
+ * @param[in] in input value
248
+ * @param[in] out output stream
249
+ *
250
+ * @return value was encoded
251
+ * @retval true
252
+ * @retval false
253
+ *
254
+ * */
255
+ bool BLINK_Compact_encodeBool(bool in, blink_stream_t out);
256
+
257
+ /**
258
+ * Encode `u8`
259
+ *
260
+ * @param[in] in input value
261
+ * @param[in] out output stream
262
+ *
263
+ * @return value was encoded
264
+ * @retval true
265
+ * @retval false
266
+ *
267
+ * */
268
+ bool BLINK_Compact_encodeU8(uint8_t in, blink_stream_t out);
269
+
270
+ /**
271
+ * Encode `u16`
272
+ *
273
+ * @param[in] in input value
274
+ * @param[in] out output stream
275
+ *
276
+ * @return value was encoded
277
+ * @retval true
278
+ * @retval false
279
+ *
280
+ * */
281
+ bool BLINK_Compact_encodeU16(uint16_t in, blink_stream_t out);
282
+
283
+ /**
284
+ * Encode `u32`
285
+ *
286
+ * @param[in] in input value
287
+ * @param[in] out output stream
288
+ *
289
+ * @return value was encoded
290
+ * @retval true
291
+ * @retval false
292
+ *
293
+ * */
294
+ bool BLINK_Compact_encodeU32(uint32_t in, blink_stream_t out);
295
+
296
+ /**
297
+ * Encode `u64`
298
+ *
299
+ * @param[in] in input value
300
+ * @param[in] out output stream
301
+ *
302
+ * @return value was encoded
303
+ * @retval true
304
+ * @retval false
305
+ *
306
+ * */
307
+ bool BLINK_Compact_encodeU64(uint64_t in, blink_stream_t out);
308
+
309
+ /**
310
+ * Encode `i8`
311
+ *
312
+ * @param[in] in input value
313
+ * @param[in] out output stream
314
+ *
315
+ * @return value was encoded
316
+ * @retval true
317
+ * @retval false
318
+ *
319
+ * */
320
+ bool BLINK_Compact_encodeI8(int8_t in, blink_stream_t out);
321
+
322
+ /**
323
+ * Encode `i16`
324
+ *
325
+ * @param[in] in input value
326
+ * @param[in] out output stream
327
+ *
328
+ * @return value was encoded
329
+ * @retval true
330
+ * @retval false
331
+ *
332
+ * */
333
+ bool BLINK_Compact_encodeI16(int16_t in, blink_stream_t out);
334
+
335
+ /**
336
+ * Encode `i32`
337
+ *
338
+ * @param[in] in input value
339
+ * @param[in] out output stream
340
+ *
341
+ * @return value was encoded
342
+ * @retval true
343
+ * @retval false
344
+ *
345
+ * */
346
+ bool BLINK_Compact_encodeI32(int32_t in, blink_stream_t out);
347
+
348
+ /**
349
+ * Encode `i64`
350
+ *
351
+ * @param[in] in input value
352
+ * @param[in] out output stream
353
+ *
354
+ * @return value was encoded
355
+ * @retval true
356
+ * @retval false
357
+ *
358
+ * */
359
+ bool BLINK_Compact_encodeI64(int64_t in, blink_stream_t out);
360
+
361
+ /**
362
+ * Encode `f64`
363
+ *
364
+ * @param[in] in input value
365
+ * @param[in] out output stream
366
+ *
367
+ * @return value was encoded
368
+ * @retval true
369
+ * @retval false
370
+ *
371
+ * */
372
+ bool BLINK_Compact_encodeF64(double in, blink_stream_t out);
373
+
374
+ /**
375
+ * Encode `decimal`
376
+ *
377
+ * @param[in] mantissa
378
+ * @param[in] exponent
379
+ * @param[in] out output stream
380
+ *
381
+ * @return value was encoded
382
+ * @retval true
383
+ * @retval false
384
+ *
385
+ * */
386
+ bool BLINK_Compact_encodeDecimal(int64_t mantissa, int8_t exponent, blink_stream_t out);
387
+
388
+ /**
389
+ * Calculate encoded size of unsigned integer
390
+ *
391
+ * @param[in] value unsigned integer
392
+ * @return encoded size in bytes
393
+ *
394
+ * */
395
+ uint8_t BLINK_Compact_sizeofUnsigned(uint64_t value);
396
+
397
+ /**
398
+ * Calculate encoded size of signed integer
399
+ *
400
+ * @param[in] value signed integer
401
+ * @return encoded size in bytes
402
+ *
403
+ * */
404
+ uint8_t BLINK_Compact_sizeofSigned(int64_t value);
405
+
406
+ #ifdef __cplusplus
407
+ }
408
+ #endif
409
+
410
+ /** @} */
411
+ #endif
@@ -0,0 +1,46 @@
1
+ /* Copyright (c) 2016 Cameron Harper
2
+ *
3
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ * this software and associated documentation files (the "Software"), to deal in
5
+ * the Software without restriction, including without limitation the rights to
6
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ * the Software, and to permit persons to whom the Software is furnished to do so,
8
+ * subject to the following conditions:
9
+ *
10
+ * The above copyright notice and this permission notice shall be included in all
11
+ * copies or substantial portions of the Software.
12
+ *
13
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+ *
20
+ *
21
+ * */
22
+ #ifndef BLINK_DEBUG_H
23
+ #define BLINK_DEBUG_H
24
+
25
+ #ifdef NDEBUG
26
+
27
+ #define BLINK_ERROR(...) /* BLINK_ERROR(...) */
28
+
29
+ #define BLINK_DEBUG(...) /* BLINK_DEBUG(...) */
30
+
31
+ #define BLINK_ASSERT(X) /* BLINK_ASSERT(X) */
32
+
33
+ #else
34
+
35
+ #include <assert.h>
36
+ #include <stdio.h>
37
+
38
+ #define BLINK_ERROR(...) do{fprintf(stderr, __VA_ARGS__);fprintf(stderr, "\n");}while(0);
39
+
40
+ #define BLINK_DEBUG(...) do{fprintf(stdout, "%s: ", __FUNCTION__);fprintf(stdout, __VA_ARGS__);fprintf(stdout, "\n");}while(0);
41
+
42
+ #define BLINK_ASSERT(X) assert((X));
43
+
44
+ #endif
45
+
46
+ #endif