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