psych 3.0.0.beta2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +20 -0
  4. data/CHANGELOG.rdoc +576 -0
  5. data/Gemfile +3 -0
  6. data/Mavenfile +7 -0
  7. data/README.md +73 -0
  8. data/Rakefile +46 -0
  9. data/bin/console +7 -0
  10. data/bin/setup +6 -0
  11. data/ext/psych/.gitignore +11 -0
  12. data/ext/psych/depend +3 -0
  13. data/ext/psych/extconf.rb +39 -0
  14. data/ext/psych/psych.c +34 -0
  15. data/ext/psych/psych.h +17 -0
  16. data/ext/psych/psych_emitter.c +554 -0
  17. data/ext/psych/psych_emitter.h +8 -0
  18. data/ext/psych/psych_parser.c +568 -0
  19. data/ext/psych/psych_parser.h +6 -0
  20. data/ext/psych/psych_to_ruby.c +39 -0
  21. data/ext/psych/psych_to_ruby.h +8 -0
  22. data/ext/psych/psych_yaml_tree.c +24 -0
  23. data/ext/psych/psych_yaml_tree.h +8 -0
  24. data/ext/psych/yaml/LICENSE +19 -0
  25. data/ext/psych/yaml/api.c +1392 -0
  26. data/ext/psych/yaml/config.h +10 -0
  27. data/ext/psych/yaml/dumper.c +394 -0
  28. data/ext/psych/yaml/emitter.c +2329 -0
  29. data/ext/psych/yaml/loader.c +444 -0
  30. data/ext/psych/yaml/parser.c +1374 -0
  31. data/ext/psych/yaml/reader.c +469 -0
  32. data/ext/psych/yaml/scanner.c +3576 -0
  33. data/ext/psych/yaml/writer.c +141 -0
  34. data/ext/psych/yaml/yaml.h +1971 -0
  35. data/ext/psych/yaml/yaml_private.h +662 -0
  36. data/lib/psych.rb +511 -0
  37. data/lib/psych/class_loader.rb +102 -0
  38. data/lib/psych/coder.rb +95 -0
  39. data/lib/psych/core_ext.rb +19 -0
  40. data/lib/psych/exception.rb +14 -0
  41. data/lib/psych/handler.rb +250 -0
  42. data/lib/psych/handlers/document_stream.rb +23 -0
  43. data/lib/psych/handlers/recorder.rb +40 -0
  44. data/lib/psych/json/ruby_events.rb +20 -0
  45. data/lib/psych/json/stream.rb +17 -0
  46. data/lib/psych/json/tree_builder.rb +13 -0
  47. data/lib/psych/json/yaml_events.rb +30 -0
  48. data/lib/psych/nodes.rb +78 -0
  49. data/lib/psych/nodes/alias.rb +19 -0
  50. data/lib/psych/nodes/document.rb +61 -0
  51. data/lib/psych/nodes/mapping.rb +57 -0
  52. data/lib/psych/nodes/node.rb +56 -0
  53. data/lib/psych/nodes/scalar.rb +68 -0
  54. data/lib/psych/nodes/sequence.rb +82 -0
  55. data/lib/psych/nodes/stream.rb +38 -0
  56. data/lib/psych/omap.rb +5 -0
  57. data/lib/psych/parser.rb +52 -0
  58. data/lib/psych/scalar_scanner.rb +149 -0
  59. data/lib/psych/set.rb +5 -0
  60. data/lib/psych/stream.rb +38 -0
  61. data/lib/psych/streaming.rb +28 -0
  62. data/lib/psych/syntax_error.rb +22 -0
  63. data/lib/psych/tree_builder.rb +97 -0
  64. data/lib/psych/versions.rb +9 -0
  65. data/lib/psych/visitors.rb +7 -0
  66. data/lib/psych/visitors/depth_first.rb +27 -0
  67. data/lib/psych/visitors/emitter.rb +52 -0
  68. data/lib/psych/visitors/json_tree.rb +25 -0
  69. data/lib/psych/visitors/to_ruby.rb +401 -0
  70. data/lib/psych/visitors/visitor.rb +20 -0
  71. data/lib/psych/visitors/yaml_tree.rb +551 -0
  72. data/lib/psych/y.rb +10 -0
  73. data/psych.gemspec +64 -0
  74. metadata +175 -0
@@ -0,0 +1,662 @@
1
+ #ifdef RUBY_EXTCONF_H
2
+ #include RUBY_EXTCONF_H
3
+ #endif
4
+
5
+ #if HAVE_CONFIG_H
6
+ #include <config.h>
7
+ #endif
8
+
9
+ #include <yaml.h>
10
+
11
+ #include <assert.h>
12
+ #include <limits.h>
13
+ #include <stddef.h>
14
+
15
+ #ifndef _MSC_VER
16
+ #include <stdint.h>
17
+ #else
18
+ #ifdef _WIN64
19
+ #define PTRDIFF_MAX _I64_MAX
20
+ #else
21
+ #define PTRDIFF_MAX INT_MAX
22
+ #endif
23
+ #endif
24
+
25
+ /*
26
+ * Memory management.
27
+ */
28
+
29
+ YAML_DECLARE(void *)
30
+ yaml_malloc(size_t size);
31
+
32
+ YAML_DECLARE(void *)
33
+ yaml_realloc(void *ptr, size_t size);
34
+
35
+ YAML_DECLARE(void)
36
+ yaml_free(void *ptr);
37
+
38
+ YAML_DECLARE(yaml_char_t *)
39
+ yaml_strdup(const yaml_char_t *);
40
+
41
+ /*
42
+ * Reader: Ensure that the buffer contains at least `length` characters.
43
+ */
44
+
45
+ YAML_DECLARE(int)
46
+ yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
47
+
48
+ /*
49
+ * Scanner: Ensure that the token stack contains at least one token ready.
50
+ */
51
+
52
+ YAML_DECLARE(int)
53
+ yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
54
+
55
+ /*
56
+ * The size of the input raw buffer.
57
+ */
58
+
59
+ #define INPUT_RAW_BUFFER_SIZE 16384
60
+
61
+ /*
62
+ * The size of the input buffer.
63
+ *
64
+ * It should be possible to decode the whole raw buffer.
65
+ */
66
+
67
+ #define INPUT_BUFFER_SIZE (INPUT_RAW_BUFFER_SIZE*3)
68
+
69
+ /*
70
+ * The size of the output buffer.
71
+ */
72
+
73
+ #define OUTPUT_BUFFER_SIZE 16384
74
+
75
+ /*
76
+ * The size of the output raw buffer.
77
+ *
78
+ * It should be possible to encode the whole output buffer.
79
+ */
80
+
81
+ #define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
82
+
83
+ /*
84
+ * The size of other stacks and queues.
85
+ */
86
+
87
+ #define INITIAL_STACK_SIZE 16
88
+ #define INITIAL_QUEUE_SIZE 16
89
+ #define INITIAL_STRING_SIZE 16
90
+
91
+ /*
92
+ * Buffer management.
93
+ */
94
+
95
+ #define BUFFER_INIT(context,buffer,size) \
96
+ (((buffer).start = yaml_malloc(size)) ? \
97
+ ((buffer).last = (buffer).pointer = (buffer).start, \
98
+ (buffer).end = (buffer).start+(size), \
99
+ 1) : \
100
+ ((context)->error = YAML_MEMORY_ERROR, \
101
+ 0))
102
+
103
+ #define BUFFER_DEL(context,buffer) \
104
+ (yaml_free((buffer).start), \
105
+ (buffer).start = (buffer).pointer = (buffer).end = 0)
106
+
107
+ /*
108
+ * String management.
109
+ */
110
+
111
+ typedef struct {
112
+ yaml_char_t *start;
113
+ yaml_char_t *end;
114
+ yaml_char_t *pointer;
115
+ } yaml_string_t;
116
+
117
+ YAML_DECLARE(int)
118
+ yaml_string_extend(yaml_char_t **start,
119
+ yaml_char_t **pointer, yaml_char_t **end);
120
+
121
+ YAML_DECLARE(int)
122
+ yaml_string_join(
123
+ yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
124
+ yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end);
125
+
126
+ #define NULL_STRING { NULL, NULL, NULL }
127
+
128
+ #define STRING(string,length) { (string), (string)+(length), (string) }
129
+
130
+ #define STRING_ASSIGN(value,string,length) \
131
+ ((value).start = (string), \
132
+ (value).end = (string)+(length), \
133
+ (value).pointer = (string))
134
+
135
+ #define STRING_INIT(context,string,size) \
136
+ (((string).start = yaml_malloc(size)) ? \
137
+ ((string).pointer = (string).start, \
138
+ (string).end = (string).start+(size), \
139
+ memset((string).start, 0, (size)), \
140
+ 1) : \
141
+ ((context)->error = YAML_MEMORY_ERROR, \
142
+ 0))
143
+
144
+ #define STRING_DEL(context,string) \
145
+ (yaml_free((string).start), \
146
+ (string).start = (string).pointer = (string).end = 0)
147
+
148
+ #define STRING_EXTEND(context,string) \
149
+ ((((string).pointer+5 < (string).end) \
150
+ || yaml_string_extend(&(string).start, \
151
+ &(string).pointer, &(string).end)) ? \
152
+ 1 : \
153
+ ((context)->error = YAML_MEMORY_ERROR, \
154
+ 0))
155
+
156
+ #define CLEAR(context,string) \
157
+ ((string).pointer = (string).start, \
158
+ memset((string).start, 0, (string).end-(string).start))
159
+
160
+ #define JOIN(context,string_a,string_b) \
161
+ ((yaml_string_join(&(string_a).start, &(string_a).pointer, \
162
+ &(string_a).end, &(string_b).start, \
163
+ &(string_b).pointer, &(string_b).end)) ? \
164
+ ((string_b).pointer = (string_b).start, \
165
+ 1) : \
166
+ ((context)->error = YAML_MEMORY_ERROR, \
167
+ 0))
168
+
169
+ /*
170
+ * String check operations.
171
+ */
172
+
173
+ /*
174
+ * Check the octet at the specified position.
175
+ */
176
+
177
+ #define CHECK_AT(string,octet,offset) \
178
+ ((string).pointer[offset] == (yaml_char_t)(octet))
179
+
180
+ /*
181
+ * Check the current octet in the buffer.
182
+ */
183
+
184
+ #define CHECK(string,octet) CHECK_AT((string),(octet),0)
185
+
186
+ /*
187
+ * Check if the character at the specified position is an alphabetical
188
+ * character, a digit, '_', or '-'.
189
+ */
190
+
191
+ #define IS_ALPHA_AT(string,offset) \
192
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
193
+ (string).pointer[offset] <= (yaml_char_t) '9') || \
194
+ ((string).pointer[offset] >= (yaml_char_t) 'A' && \
195
+ (string).pointer[offset] <= (yaml_char_t) 'Z') || \
196
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
197
+ (string).pointer[offset] <= (yaml_char_t) 'z') || \
198
+ (string).pointer[offset] == '_' || \
199
+ (string).pointer[offset] == '-')
200
+
201
+ #define IS_ALPHA(string) IS_ALPHA_AT((string),0)
202
+
203
+ /*
204
+ * Check if the character at the specified position is a digit.
205
+ */
206
+
207
+ #define IS_DIGIT_AT(string,offset) \
208
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
209
+ (string).pointer[offset] <= (yaml_char_t) '9'))
210
+
211
+ #define IS_DIGIT(string) IS_DIGIT_AT((string),0)
212
+
213
+ /*
214
+ * Get the value of a digit.
215
+ */
216
+
217
+ #define AS_DIGIT_AT(string,offset) \
218
+ ((string).pointer[offset] - (yaml_char_t) '0')
219
+
220
+ #define AS_DIGIT(string) AS_DIGIT_AT((string),0)
221
+
222
+ /*
223
+ * Check if the character at the specified position is a hex-digit.
224
+ */
225
+
226
+ #define IS_HEX_AT(string,offset) \
227
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
228
+ (string).pointer[offset] <= (yaml_char_t) '9') || \
229
+ ((string).pointer[offset] >= (yaml_char_t) 'A' && \
230
+ (string).pointer[offset] <= (yaml_char_t) 'F') || \
231
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
232
+ (string).pointer[offset] <= (yaml_char_t) 'f'))
233
+
234
+ #define IS_HEX(string) IS_HEX_AT((string),0)
235
+
236
+ /*
237
+ * Get the value of a hex-digit.
238
+ */
239
+
240
+ #define AS_HEX_AT(string,offset) \
241
+ (((string).pointer[offset] >= (yaml_char_t) 'A' && \
242
+ (string).pointer[offset] <= (yaml_char_t) 'F') ? \
243
+ ((string).pointer[offset] - (yaml_char_t) 'A' + 10) : \
244
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
245
+ (string).pointer[offset] <= (yaml_char_t) 'f') ? \
246
+ ((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
247
+ ((string).pointer[offset] - (yaml_char_t) '0'))
248
+
249
+ #define AS_HEX(string) AS_HEX_AT((string),0)
250
+
251
+ /*
252
+ * Check if the character is ASCII.
253
+ */
254
+
255
+ #define IS_ASCII_AT(string,offset) \
256
+ ((string).pointer[offset] <= (yaml_char_t) '\x7F')
257
+
258
+ #define IS_ASCII(string) IS_ASCII_AT((string),0)
259
+
260
+ /*
261
+ * Check if the character can be printed unescaped.
262
+ */
263
+
264
+ #define IS_PRINTABLE_AT(string,offset) \
265
+ (((string).pointer[offset] == 0x0A) /* . == #x0A */ \
266
+ || ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \
267
+ && (string).pointer[offset] <= 0x7E) \
268
+ || ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \
269
+ && (string).pointer[offset+1] >= 0xA0) \
270
+ || ((string).pointer[offset] > 0xC2 \
271
+ && (string).pointer[offset] < 0xED) \
272
+ || ((string).pointer[offset] == 0xED \
273
+ && (string).pointer[offset+1] < 0xA0) \
274
+ || ((string).pointer[offset] == 0xEE) \
275
+ || ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \
276
+ && !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \
277
+ && (string).pointer[offset+2] == 0xBF) \
278
+ && !((string).pointer[offset+1] == 0xBF \
279
+ && ((string).pointer[offset+2] == 0xBE \
280
+ || (string).pointer[offset+2] == 0xBF))))
281
+
282
+ #define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0)
283
+
284
+ /*
285
+ * Check if the character at the specified position is NUL.
286
+ */
287
+
288
+ #define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset))
289
+
290
+ #define IS_Z(string) IS_Z_AT((string),0)
291
+
292
+ /*
293
+ * Check if the character at the specified position is BOM.
294
+ */
295
+
296
+ #define IS_BOM_AT(string,offset) \
297
+ (CHECK_AT((string),'\xEF',(offset)) \
298
+ && CHECK_AT((string),'\xBB',(offset)+1) \
299
+ && CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */
300
+
301
+ #define IS_BOM(string) IS_BOM_AT(string,0)
302
+
303
+ /*
304
+ * Check if the character at the specified position is space.
305
+ */
306
+
307
+ #define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset))
308
+
309
+ #define IS_SPACE(string) IS_SPACE_AT((string),0)
310
+
311
+ /*
312
+ * Check if the character at the specified position is tab.
313
+ */
314
+
315
+ #define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset))
316
+
317
+ #define IS_TAB(string) IS_TAB_AT((string),0)
318
+
319
+ /*
320
+ * Check if the character at the specified position is blank (space or tab).
321
+ */
322
+
323
+ #define IS_BLANK_AT(string,offset) \
324
+ (IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset)))
325
+
326
+ #define IS_BLANK(string) IS_BLANK_AT((string),0)
327
+
328
+ /*
329
+ * Check if the character at the specified position is a line break.
330
+ */
331
+
332
+ #define IS_BREAK_AT(string,offset) \
333
+ (CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \
334
+ || CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \
335
+ || (CHECK_AT((string),'\xC2',(offset)) \
336
+ && CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \
337
+ || (CHECK_AT((string),'\xE2',(offset)) \
338
+ && CHECK_AT((string),'\x80',(offset)+1) \
339
+ && CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \
340
+ || (CHECK_AT((string),'\xE2',(offset)) \
341
+ && CHECK_AT((string),'\x80',(offset)+1) \
342
+ && CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */
343
+
344
+ #define IS_BREAK(string) IS_BREAK_AT((string),0)
345
+
346
+ #define IS_CRLF_AT(string,offset) \
347
+ (CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1))
348
+
349
+ #define IS_CRLF(string) IS_CRLF_AT((string),0)
350
+
351
+ /*
352
+ * Check if the character is a line break or NUL.
353
+ */
354
+
355
+ #define IS_BREAKZ_AT(string,offset) \
356
+ (IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset)))
357
+
358
+ #define IS_BREAKZ(string) IS_BREAKZ_AT((string),0)
359
+
360
+ /*
361
+ * Check if the character is a line break, space, or NUL.
362
+ */
363
+
364
+ #define IS_SPACEZ_AT(string,offset) \
365
+ (IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
366
+
367
+ #define IS_SPACEZ(string) IS_SPACEZ_AT((string),0)
368
+
369
+ /*
370
+ * Check if the character is a line break, space, tab, or NUL.
371
+ */
372
+
373
+ #define IS_BLANKZ_AT(string,offset) \
374
+ (IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
375
+
376
+ #define IS_BLANKZ(string) IS_BLANKZ_AT((string),0)
377
+
378
+ /*
379
+ * Determine the width of the character.
380
+ */
381
+
382
+ #define WIDTH_AT(string,offset) \
383
+ (((string).pointer[offset] & 0x80) == 0x00 ? 1 : \
384
+ ((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \
385
+ ((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \
386
+ ((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
387
+
388
+ #define WIDTH(string) WIDTH_AT((string),0)
389
+
390
+ /*
391
+ * Move the string pointer to the next character.
392
+ */
393
+
394
+ #define MOVE(string) ((string).pointer += WIDTH((string)))
395
+
396
+ /*
397
+ * Copy a character and move the pointers of both strings.
398
+ */
399
+
400
+ #define COPY(string_a,string_b) \
401
+ ((*(string_b).pointer & 0x80) == 0x00 ? \
402
+ (*((string_a).pointer++) = *((string_b).pointer++)) : \
403
+ (*(string_b).pointer & 0xE0) == 0xC0 ? \
404
+ (*((string_a).pointer++) = *((string_b).pointer++), \
405
+ *((string_a).pointer++) = *((string_b).pointer++)) : \
406
+ (*(string_b).pointer & 0xF0) == 0xE0 ? \
407
+ (*((string_a).pointer++) = *((string_b).pointer++), \
408
+ *((string_a).pointer++) = *((string_b).pointer++), \
409
+ *((string_a).pointer++) = *((string_b).pointer++)) : \
410
+ (*(string_b).pointer & 0xF8) == 0xF0 ? \
411
+ (*((string_a).pointer++) = *((string_b).pointer++), \
412
+ *((string_a).pointer++) = *((string_b).pointer++), \
413
+ *((string_a).pointer++) = *((string_b).pointer++), \
414
+ *((string_a).pointer++) = *((string_b).pointer++)) : 0)
415
+
416
+ /*
417
+ * Stack and queue management.
418
+ */
419
+
420
+ YAML_DECLARE(int)
421
+ yaml_stack_extend(void **start, void **top, void **end);
422
+
423
+ YAML_DECLARE(int)
424
+ yaml_queue_extend(void **start, void **head, void **tail, void **end);
425
+
426
+ #define STACK_INIT(context,stack,size) \
427
+ (((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
428
+ ((stack).top = (stack).start, \
429
+ (stack).end = (stack).start+(size), \
430
+ 1) : \
431
+ ((context)->error = YAML_MEMORY_ERROR, \
432
+ 0))
433
+
434
+ #define STACK_DEL(context,stack) \
435
+ (yaml_free((stack).start), \
436
+ (stack).start = (stack).top = (stack).end = 0)
437
+
438
+ #define STACK_EMPTY(context,stack) \
439
+ ((stack).start == (stack).top)
440
+
441
+ #define STACK_LIMIT(context,stack,size) \
442
+ ((stack).top - (stack).start < (size) ? \
443
+ 1 : \
444
+ ((context)->error = YAML_MEMORY_ERROR, \
445
+ 0))
446
+
447
+ #define PUSH(context,stack,value) \
448
+ (((stack).top != (stack).end \
449
+ || yaml_stack_extend((void **)&(stack).start, \
450
+ (void **)&(stack).top, (void **)&(stack).end)) ? \
451
+ (*((stack).top++) = value, \
452
+ 1) : \
453
+ ((context)->error = YAML_MEMORY_ERROR, \
454
+ 0))
455
+
456
+ #define POP(context,stack) \
457
+ (*(--(stack).top))
458
+
459
+ #define QUEUE_INIT(context,queue,size) \
460
+ (((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \
461
+ ((queue).head = (queue).tail = (queue).start, \
462
+ (queue).end = (queue).start+(size), \
463
+ 1) : \
464
+ ((context)->error = YAML_MEMORY_ERROR, \
465
+ 0))
466
+
467
+ #define QUEUE_DEL(context,queue) \
468
+ (yaml_free((queue).start), \
469
+ (queue).start = (queue).head = (queue).tail = (queue).end = 0)
470
+
471
+ #define QUEUE_EMPTY(context,queue) \
472
+ ((queue).head == (queue).tail)
473
+
474
+ #define ENQUEUE(context,queue,value) \
475
+ (((queue).tail != (queue).end \
476
+ || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
477
+ (void **)&(queue).tail, (void **)&(queue).end)) ? \
478
+ (*((queue).tail++) = value, \
479
+ 1) : \
480
+ ((context)->error = YAML_MEMORY_ERROR, \
481
+ 0))
482
+
483
+ #define DEQUEUE(context,queue) \
484
+ (*((queue).head++))
485
+
486
+ #define QUEUE_INSERT(context,queue,index,value) \
487
+ (((queue).tail != (queue).end \
488
+ || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
489
+ (void **)&(queue).tail, (void **)&(queue).end)) ? \
490
+ (memmove((queue).head+(index)+1,(queue).head+(index), \
491
+ ((queue).tail-(queue).head-(index))*sizeof(*(queue).start)), \
492
+ *((queue).head+(index)) = value, \
493
+ (queue).tail++, \
494
+ 1) : \
495
+ ((context)->error = YAML_MEMORY_ERROR, \
496
+ 0))
497
+
498
+ /*
499
+ * Token initializers.
500
+ */
501
+
502
+ #define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \
503
+ (memset(&(token), 0, sizeof(yaml_token_t)), \
504
+ (token).type = (token_type), \
505
+ (token).start_mark = (token_start_mark), \
506
+ (token).end_mark = (token_end_mark))
507
+
508
+ #define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \
509
+ (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \
510
+ (token).data.stream_start.encoding = (token_encoding))
511
+
512
+ #define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \
513
+ (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
514
+
515
+ #define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \
516
+ (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \
517
+ (token).data.alias.value = (token_value))
518
+
519
+ #define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \
520
+ (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \
521
+ (token).data.anchor.value = (token_value))
522
+
523
+ #define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \
524
+ (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \
525
+ (token).data.tag.handle = (token_handle), \
526
+ (token).data.tag.suffix = (token_suffix))
527
+
528
+ #define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \
529
+ (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \
530
+ (token).data.scalar.value = (token_value), \
531
+ (token).data.scalar.length = (token_length), \
532
+ (token).data.scalar.style = (token_style))
533
+
534
+ #define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \
535
+ (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
536
+ (token).data.version_directive.major = (token_major), \
537
+ (token).data.version_directive.minor = (token_minor))
538
+
539
+ #define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \
540
+ (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
541
+ (token).data.tag_directive.handle = (token_handle), \
542
+ (token).data.tag_directive.prefix = (token_prefix))
543
+
544
+ /*
545
+ * Event initializers.
546
+ */
547
+
548
+ #define EVENT_INIT(event,event_type,event_start_mark,event_end_mark) \
549
+ (memset(&(event), 0, sizeof(yaml_event_t)), \
550
+ (event).type = (event_type), \
551
+ (event).start_mark = (event_start_mark), \
552
+ (event).end_mark = (event_end_mark))
553
+
554
+ #define STREAM_START_EVENT_INIT(event,event_encoding,start_mark,end_mark) \
555
+ (EVENT_INIT((event),YAML_STREAM_START_EVENT,(start_mark),(end_mark)), \
556
+ (event).data.stream_start.encoding = (event_encoding))
557
+
558
+ #define STREAM_END_EVENT_INIT(event,start_mark,end_mark) \
559
+ (EVENT_INIT((event),YAML_STREAM_END_EVENT,(start_mark),(end_mark)))
560
+
561
+ #define DOCUMENT_START_EVENT_INIT(event,event_version_directive, \
562
+ event_tag_directives_start,event_tag_directives_end,event_implicit,start_mark,end_mark) \
563
+ (EVENT_INIT((event),YAML_DOCUMENT_START_EVENT,(start_mark),(end_mark)), \
564
+ (event).data.document_start.version_directive = (event_version_directive), \
565
+ (event).data.document_start.tag_directives.start = (event_tag_directives_start), \
566
+ (event).data.document_start.tag_directives.end = (event_tag_directives_end), \
567
+ (event).data.document_start.implicit = (event_implicit))
568
+
569
+ #define DOCUMENT_END_EVENT_INIT(event,event_implicit,start_mark,end_mark) \
570
+ (EVENT_INIT((event),YAML_DOCUMENT_END_EVENT,(start_mark),(end_mark)), \
571
+ (event).data.document_end.implicit = (event_implicit))
572
+
573
+ #define ALIAS_EVENT_INIT(event,event_anchor,start_mark,end_mark) \
574
+ (EVENT_INIT((event),YAML_ALIAS_EVENT,(start_mark),(end_mark)), \
575
+ (event).data.alias.anchor = (event_anchor))
576
+
577
+ #define SCALAR_EVENT_INIT(event,event_anchor,event_tag,event_value,event_length, \
578
+ event_plain_implicit, event_quoted_implicit,event_style,start_mark,end_mark) \
579
+ (EVENT_INIT((event),YAML_SCALAR_EVENT,(start_mark),(end_mark)), \
580
+ (event).data.scalar.anchor = (event_anchor), \
581
+ (event).data.scalar.tag = (event_tag), \
582
+ (event).data.scalar.value = (event_value), \
583
+ (event).data.scalar.length = (event_length), \
584
+ (event).data.scalar.plain_implicit = (event_plain_implicit), \
585
+ (event).data.scalar.quoted_implicit = (event_quoted_implicit), \
586
+ (event).data.scalar.style = (event_style))
587
+
588
+ #define SEQUENCE_START_EVENT_INIT(event,event_anchor,event_tag, \
589
+ event_implicit,event_style,start_mark,end_mark) \
590
+ (EVENT_INIT((event),YAML_SEQUENCE_START_EVENT,(start_mark),(end_mark)), \
591
+ (event).data.sequence_start.anchor = (event_anchor), \
592
+ (event).data.sequence_start.tag = (event_tag), \
593
+ (event).data.sequence_start.implicit = (event_implicit), \
594
+ (event).data.sequence_start.style = (event_style))
595
+
596
+ #define SEQUENCE_END_EVENT_INIT(event,start_mark,end_mark) \
597
+ (EVENT_INIT((event),YAML_SEQUENCE_END_EVENT,(start_mark),(end_mark)))
598
+
599
+ #define MAPPING_START_EVENT_INIT(event,event_anchor,event_tag, \
600
+ event_implicit,event_style,start_mark,end_mark) \
601
+ (EVENT_INIT((event),YAML_MAPPING_START_EVENT,(start_mark),(end_mark)), \
602
+ (event).data.mapping_start.anchor = (event_anchor), \
603
+ (event).data.mapping_start.tag = (event_tag), \
604
+ (event).data.mapping_start.implicit = (event_implicit), \
605
+ (event).data.mapping_start.style = (event_style))
606
+
607
+ #define MAPPING_END_EVENT_INIT(event,start_mark,end_mark) \
608
+ (EVENT_INIT((event),YAML_MAPPING_END_EVENT,(start_mark),(end_mark)))
609
+
610
+ /*
611
+ * Document initializer.
612
+ */
613
+
614
+ #define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \
615
+ document_version_directive,document_tag_directives_start, \
616
+ document_tag_directives_end,document_start_implicit, \
617
+ document_end_implicit,document_start_mark,document_end_mark) \
618
+ (memset(&(document), 0, sizeof(yaml_document_t)), \
619
+ (document).nodes.start = (document_nodes_start), \
620
+ (document).nodes.end = (document_nodes_end), \
621
+ (document).nodes.top = (document_nodes_start), \
622
+ (document).version_directive = (document_version_directive), \
623
+ (document).tag_directives.start = (document_tag_directives_start), \
624
+ (document).tag_directives.end = (document_tag_directives_end), \
625
+ (document).start_implicit = (document_start_implicit), \
626
+ (document).end_implicit = (document_end_implicit), \
627
+ (document).start_mark = (document_start_mark), \
628
+ (document).end_mark = (document_end_mark))
629
+
630
+ /*
631
+ * Node initializers.
632
+ */
633
+
634
+ #define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \
635
+ (memset(&(node), 0, sizeof(yaml_node_t)), \
636
+ (node).type = (node_type), \
637
+ (node).tag = (node_tag), \
638
+ (node).start_mark = (node_start_mark), \
639
+ (node).end_mark = (node_end_mark))
640
+
641
+ #define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \
642
+ node_style,start_mark,end_mark) \
643
+ (NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \
644
+ (node).data.scalar.value = (node_value), \
645
+ (node).data.scalar.length = (node_length), \
646
+ (node).data.scalar.style = (node_style))
647
+
648
+ #define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \
649
+ node_style,start_mark,end_mark) \
650
+ (NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \
651
+ (node).data.sequence.items.start = (node_items_start), \
652
+ (node).data.sequence.items.end = (node_items_end), \
653
+ (node).data.sequence.items.top = (node_items_start), \
654
+ (node).data.sequence.style = (node_style))
655
+
656
+ #define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \
657
+ node_style,start_mark,end_mark) \
658
+ (NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \
659
+ (node).data.mapping.pairs.start = (node_pairs_start), \
660
+ (node).data.mapping.pairs.end = (node_pairs_end), \
661
+ (node).data.mapping.pairs.top = (node_pairs_start), \
662
+ (node).data.mapping.style = (node_style))