psych 3.3.2 → 5.1.0

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