Ruby  2.0.0p451(2014-02-24revision45167)
yaml_private.h
Go to the documentation of this file.
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 
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)
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)
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 
153 #define CLEAR(context,string) \
154  ((string).pointer = (string).start, \
155  memset((string).start, 0, (string).end-(string).start))
156 
157 #define JOIN(context,string_a,string_b) \
158  ((yaml_string_join(&(string_a).start, &(string_a).pointer, \
159  &(string_a).end, &(string_b).start, \
160  &(string_b).pointer, &(string_b).end)) ? \
161  ((string_b).pointer = (string_b).start, \
162  1) : \
163  ((context)->error = YAML_MEMORY_ERROR, \
164  0))
165 
166 /*
167  * String check operations.
168  */
169 
170 /*
171  * Check the octet at the specified position.
172  */
173 
174 #define CHECK_AT(string,octet,offset) \
175  ((string).pointer[offset] == (yaml_char_t)(octet))
176 
177 /*
178  * Check the current octet in the buffer.
179  */
180 
181 #define CHECK(string,octet) CHECK_AT((string),(octet),0)
182 
183 /*
184  * Check if the character at the specified position is an alphabetical
185  * character, a digit, '_', or '-'.
186  */
187 
188 #define IS_ALPHA_AT(string,offset) \
189  (((string).pointer[offset] >= (yaml_char_t) '0' && \
190  (string).pointer[offset] <= (yaml_char_t) '9') || \
191  ((string).pointer[offset] >= (yaml_char_t) 'A' && \
192  (string).pointer[offset] <= (yaml_char_t) 'Z') || \
193  ((string).pointer[offset] >= (yaml_char_t) 'a' && \
194  (string).pointer[offset] <= (yaml_char_t) 'z') || \
195  (string).pointer[offset] == '_' || \
196  (string).pointer[offset] == '-')
197 
198 #define IS_ALPHA(string) IS_ALPHA_AT((string),0)
199 
200 /*
201  * Check if the character at the specified position is a digit.
202  */
203 
204 #define IS_DIGIT_AT(string,offset) \
205  (((string).pointer[offset] >= (yaml_char_t) '0' && \
206  (string).pointer[offset] <= (yaml_char_t) '9'))
207 
208 #define IS_DIGIT(string) IS_DIGIT_AT((string),0)
209 
210 /*
211  * Get the value of a digit.
212  */
213 
214 #define AS_DIGIT_AT(string,offset) \
215  ((string).pointer[offset] - (yaml_char_t) '0')
216 
217 #define AS_DIGIT(string) AS_DIGIT_AT((string),0)
218 
219 /*
220  * Check if the character at the specified position is a hex-digit.
221  */
222 
223 #define IS_HEX_AT(string,offset) \
224  (((string).pointer[offset] >= (yaml_char_t) '0' && \
225  (string).pointer[offset] <= (yaml_char_t) '9') || \
226  ((string).pointer[offset] >= (yaml_char_t) 'A' && \
227  (string).pointer[offset] <= (yaml_char_t) 'F') || \
228  ((string).pointer[offset] >= (yaml_char_t) 'a' && \
229  (string).pointer[offset] <= (yaml_char_t) 'f'))
230 
231 #define IS_HEX(string) IS_HEX_AT((string),0)
232 
233 /*
234  * Get the value of a hex-digit.
235  */
236 
237 #define AS_HEX_AT(string,offset) \
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) '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) '0'))
245 
246 #define AS_HEX(string) AS_HEX_AT((string),0)
247 
248 /*
249  * Check if the character is ASCII.
250  */
251 
252 #define IS_ASCII_AT(string,offset) \
253  ((string).pointer[offset] <= (yaml_char_t) '\x7F')
254 
255 #define IS_ASCII(string) IS_ASCII_AT((string),0)
256 
257 /*
258  * Check if the character can be printed unescaped.
259  */
260 
261 #define IS_PRINTABLE_AT(string,offset) \
262  (((string).pointer[offset] == 0x0A) /* . == #x0A */ \
263  || ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \
264  && (string).pointer[offset] <= 0x7E) \
265  || ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \
266  && (string).pointer[offset+1] >= 0xA0) \
267  || ((string).pointer[offset] > 0xC2 \
268  && (string).pointer[offset] < 0xED) \
269  || ((string).pointer[offset] == 0xED \
270  && (string).pointer[offset+1] < 0xA0) \
271  || ((string).pointer[offset] == 0xEE) \
272  || ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \
273  && !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \
274  && (string).pointer[offset+2] == 0xBF) \
275  && !((string).pointer[offset+1] == 0xBF \
276  && ((string).pointer[offset+2] == 0xBE \
277  || (string).pointer[offset+2] == 0xBF))))
278 
279 #define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0)
280 
281 /*
282  * Check if the character at the specified position is NUL.
283  */
284 
285 #define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset))
286 
287 #define IS_Z(string) IS_Z_AT((string),0)
288 
289 /*
290  * Check if the character at the specified position is BOM.
291  */
292 
293 #define IS_BOM_AT(string,offset) \
294  (CHECK_AT((string),'\xEF',(offset)) \
295  && CHECK_AT((string),'\xBB',(offset)+1) \
296  && CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */
297 
298 #define IS_BOM(string) IS_BOM_AT(string,0)
299 
300 /*
301  * Check if the character at the specified position is space.
302  */
303 
304 #define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset))
305 
306 #define IS_SPACE(string) IS_SPACE_AT((string),0)
307 
308 /*
309  * Check if the character at the specified position is tab.
310  */
311 
312 #define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset))
313 
314 #define IS_TAB(string) IS_TAB_AT((string),0)
315 
316 /*
317  * Check if the character at the specified position is blank (space or tab).
318  */
319 
320 #define IS_BLANK_AT(string,offset) \
321  (IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset)))
322 
323 #define IS_BLANK(string) IS_BLANK_AT((string),0)
324 
325 /*
326  * Check if the character at the specified position is a line break.
327  */
328 
329 #define IS_BREAK_AT(string,offset) \
330  (CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \
331  || CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \
332  || (CHECK_AT((string),'\xC2',(offset)) \
333  && CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \
334  || (CHECK_AT((string),'\xE2',(offset)) \
335  && CHECK_AT((string),'\x80',(offset)+1) \
336  && CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \
337  || (CHECK_AT((string),'\xE2',(offset)) \
338  && CHECK_AT((string),'\x80',(offset)+1) \
339  && CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */
340 
341 #define IS_BREAK(string) IS_BREAK_AT((string),0)
342 
343 #define IS_CRLF_AT(string,offset) \
344  (CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1))
345 
346 #define IS_CRLF(string) IS_CRLF_AT((string),0)
347 
348 /*
349  * Check if the character is a line break or NUL.
350  */
351 
352 #define IS_BREAKZ_AT(string,offset) \
353  (IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset)))
354 
355 #define IS_BREAKZ(string) IS_BREAKZ_AT((string),0)
356 
357 /*
358  * Check if the character is a line break, space, or NUL.
359  */
360 
361 #define IS_SPACEZ_AT(string,offset) \
362  (IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
363 
364 #define IS_SPACEZ(string) IS_SPACEZ_AT((string),0)
365 
366 /*
367  * Check if the character is a line break, space, tab, or NUL.
368  */
369 
370 #define IS_BLANKZ_AT(string,offset) \
371  (IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
372 
373 #define IS_BLANKZ(string) IS_BLANKZ_AT((string),0)
374 
375 /*
376  * Determine the width of the character.
377  */
378 
379 #define WIDTH_AT(string,offset) \
380  (((string).pointer[offset] & 0x80) == 0x00 ? 1 : \
381  ((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \
382  ((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \
383  ((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
384 
385 #define WIDTH(string) WIDTH_AT((string),0)
386 
387 /*
388  * Move the string pointer to the next character.
389  */
390 
391 #define MOVE(string) ((string).pointer += WIDTH((string)))
392 
393 /*
394  * Copy a character and move the pointers of both strings.
395  */
396 
397 #define COPY(string_a,string_b) \
398  ((*(string_b).pointer & 0x80) == 0x00 ? \
399  (*((string_a).pointer++) = *((string_b).pointer++)) : \
400  (*(string_b).pointer & 0xE0) == 0xC0 ? \
401  (*((string_a).pointer++) = *((string_b).pointer++), \
402  *((string_a).pointer++) = *((string_b).pointer++)) : \
403  (*(string_b).pointer & 0xF0) == 0xE0 ? \
404  (*((string_a).pointer++) = *((string_b).pointer++), \
405  *((string_a).pointer++) = *((string_b).pointer++), \
406  *((string_a).pointer++) = *((string_b).pointer++)) : \
407  (*(string_b).pointer & 0xF8) == 0xF0 ? \
408  (*((string_a).pointer++) = *((string_b).pointer++), \
409  *((string_a).pointer++) = *((string_b).pointer++), \
410  *((string_a).pointer++) = *((string_b).pointer++), \
411  *((string_a).pointer++) = *((string_b).pointer++)) : 0)
412 
413 /*
414  * Stack and queue management.
415  */
416 
417 YAML_DECLARE(int)
418 yaml_stack_extend(void **start, void **top, void **end);
419 
420 YAML_DECLARE(int)
421 yaml_queue_extend(void **start, void **head, void **tail, void **end);
422 
423 #define STACK_INIT(context,stack,size) \
424  (((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
425  ((stack).top = (stack).start, \
426  (stack).end = (stack).start+(size), \
427  1) : \
428  ((context)->error = YAML_MEMORY_ERROR, \
429  0))
430 
431 #define STACK_DEL(context,stack) \
432  (yaml_free((stack).start), \
433  (stack).start = (stack).top = (stack).end = 0)
434 
435 #define STACK_EMPTY(context,stack) \
436  ((void)(context), \
437  ((stack).start == (stack).top))
438 
439 #define STACK_LIMIT(context,stack,size) \
440  ((stack).top - (stack).start < (size) ? \
441  1 : \
442  ((context)->error = YAML_MEMORY_ERROR, \
443  0))
444 
445 #define PUSH(context,stack,value) \
446  (((stack).top != (stack).end \
447  || yaml_stack_extend((void **)&(stack).start, \
448  (void **)&(stack).top, (void **)&(stack).end)) ? \
449  (*((stack).top++) = value, \
450  1) : \
451  ((context)->error = YAML_MEMORY_ERROR, \
452  0))
453 
454 #define POP(context,stack) \
455  (*(--(stack).top))
456 
457 #define QUEUE_INIT(context,queue,size) \
458  (((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \
459  ((queue).head = (queue).tail = (queue).start, \
460  (queue).end = (queue).start+(size), \
461  1) : \
462  ((context)->error = YAML_MEMORY_ERROR, \
463  0))
464 
465 #define QUEUE_DEL(context,queue) \
466  (yaml_free((queue).start), \
467  (queue).start = (queue).head = (queue).tail = (queue).end = 0)
468 
469 #define QUEUE_EMPTY(context,queue) \
470  ((queue).head == (queue).tail)
471 
472 #define ENQUEUE(context,queue,value) \
473  (((queue).tail != (queue).end \
474  || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
475  (void **)&(queue).tail, (void **)&(queue).end)) ? \
476  (*((queue).tail++) = value, \
477  1) : \
478  ((context)->error = YAML_MEMORY_ERROR, \
479  0))
480 
481 #define DEQUEUE(context,queue) \
482  (*((queue).head++))
483 
484 #define QUEUE_INSERT(context,queue,index,value) \
485  (((queue).tail != (queue).end \
486  || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
487  (void **)&(queue).tail, (void **)&(queue).end)) ? \
488  (memmove((queue).head+(index)+1,(queue).head+(index), \
489  ((queue).tail-(queue).head-(index))*sizeof(*(queue).start)), \
490  *((queue).head+(index)) = value, \
491  (queue).tail++, \
492  1) : \
493  ((context)->error = YAML_MEMORY_ERROR, \
494  0))
495 
496 /*
497  * Token initializers.
498  */
499 
500 #define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \
501  (memset(&(token), 0, sizeof(yaml_token_t)), \
502  (token).type = (token_type), \
503  (token).start_mark = (token_start_mark), \
504  (token).end_mark = (token_end_mark))
505 
506 #define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \
507  (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \
508  (token).data.stream_start.encoding = (token_encoding))
509 
510 #define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \
511  (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
512 
513 #define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \
514  (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \
515  (token).data.alias.value = (token_value))
516 
517 #define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \
518  (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \
519  (token).data.anchor.value = (token_value))
520 
521 #define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \
522  (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \
523  (token).data.tag.handle = (token_handle), \
524  (token).data.tag.suffix = (token_suffix))
525 
526 #define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \
527  (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \
528  (token).data.scalar.value = (token_value), \
529  (token).data.scalar.length = (token_length), \
530  (token).data.scalar.style = (token_style))
531 
532 #define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \
533  (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
534  (token).data.version_directive.major = (token_major), \
535  (token).data.version_directive.minor = (token_minor))
536 
537 #define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \
538  (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
539  (token).data.tag_directive.handle = (token_handle), \
540  (token).data.tag_directive.prefix = (token_prefix))
541 
542 /*
543  * Event initializers.
544  */
545 
546 #define EVENT_INIT(event,event_type,event_start_mark,event_end_mark) \
547  (memset(&(event), 0, sizeof(yaml_event_t)), \
548  (event).type = (event_type), \
549  (event).start_mark = (event_start_mark), \
550  (event).end_mark = (event_end_mark))
551 
552 #define STREAM_START_EVENT_INIT(event,event_encoding,start_mark,end_mark) \
553  (EVENT_INIT((event),YAML_STREAM_START_EVENT,(start_mark),(end_mark)), \
554  (event).data.stream_start.encoding = (event_encoding))
555 
556 #define STREAM_END_EVENT_INIT(event,start_mark,end_mark) \
557  (EVENT_INIT((event),YAML_STREAM_END_EVENT,(start_mark),(end_mark)))
558 
559 #define DOCUMENT_START_EVENT_INIT(event,event_version_directive, \
560  event_tag_directives_start,event_tag_directives_end,event_implicit,start_mark,end_mark) \
561  (EVENT_INIT((event),YAML_DOCUMENT_START_EVENT,(start_mark),(end_mark)), \
562  (event).data.document_start.version_directive = (event_version_directive), \
563  (event).data.document_start.tag_directives.start = (event_tag_directives_start), \
564  (event).data.document_start.tag_directives.end = (event_tag_directives_end), \
565  (event).data.document_start.implicit = (event_implicit))
566 
567 #define DOCUMENT_END_EVENT_INIT(event,event_implicit,start_mark,end_mark) \
568  (EVENT_INIT((event),YAML_DOCUMENT_END_EVENT,(start_mark),(end_mark)), \
569  (event).data.document_end.implicit = (event_implicit))
570 
571 #define ALIAS_EVENT_INIT(event,event_anchor,start_mark,end_mark) \
572  (EVENT_INIT((event),YAML_ALIAS_EVENT,(start_mark),(end_mark)), \
573  (event).data.alias.anchor = (event_anchor))
574 
575 #define SCALAR_EVENT_INIT(event,event_anchor,event_tag,event_value,event_length, \
576  event_plain_implicit, event_quoted_implicit,event_style,start_mark,end_mark) \
577  (EVENT_INIT((event),YAML_SCALAR_EVENT,(start_mark),(end_mark)), \
578  (event).data.scalar.anchor = (event_anchor), \
579  (event).data.scalar.tag = (event_tag), \
580  (event).data.scalar.value = (event_value), \
581  (event).data.scalar.length = (event_length), \
582  (event).data.scalar.plain_implicit = (event_plain_implicit), \
583  (event).data.scalar.quoted_implicit = (event_quoted_implicit), \
584  (event).data.scalar.style = (event_style))
585 
586 #define SEQUENCE_START_EVENT_INIT(event,event_anchor,event_tag, \
587  event_implicit,event_style,start_mark,end_mark) \
588  (EVENT_INIT((event),YAML_SEQUENCE_START_EVENT,(start_mark),(end_mark)), \
589  (event).data.sequence_start.anchor = (event_anchor), \
590  (event).data.sequence_start.tag = (event_tag), \
591  (event).data.sequence_start.implicit = (event_implicit), \
592  (event).data.sequence_start.style = (event_style))
593 
594 #define SEQUENCE_END_EVENT_INIT(event,start_mark,end_mark) \
595  (EVENT_INIT((event),YAML_SEQUENCE_END_EVENT,(start_mark),(end_mark)))
596 
597 #define MAPPING_START_EVENT_INIT(event,event_anchor,event_tag, \
598  event_implicit,event_style,start_mark,end_mark) \
599  (EVENT_INIT((event),YAML_MAPPING_START_EVENT,(start_mark),(end_mark)), \
600  (event).data.mapping_start.anchor = (event_anchor), \
601  (event).data.mapping_start.tag = (event_tag), \
602  (event).data.mapping_start.implicit = (event_implicit), \
603  (event).data.mapping_start.style = (event_style))
604 
605 #define MAPPING_END_EVENT_INIT(event,start_mark,end_mark) \
606  (EVENT_INIT((event),YAML_MAPPING_END_EVENT,(start_mark),(end_mark)))
607 
608 /*
609  * Document initializer.
610  */
611 
612 #define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \
613  document_version_directive,document_tag_directives_start, \
614  document_tag_directives_end,document_start_implicit, \
615  document_end_implicit,document_start_mark,document_end_mark) \
616  (memset(&(document), 0, sizeof(yaml_document_t)), \
617  (document).nodes.start = (document_nodes_start), \
618  (document).nodes.end = (document_nodes_end), \
619  (document).nodes.top = (document_nodes_start), \
620  (document).version_directive = (document_version_directive), \
621  (document).tag_directives.start = (document_tag_directives_start), \
622  (document).tag_directives.end = (document_tag_directives_end), \
623  (document).start_implicit = (document_start_implicit), \
624  (document).end_implicit = (document_end_implicit), \
625  (document).start_mark = (document_start_mark), \
626  (document).end_mark = (document_end_mark))
627 
628 /*
629  * Node initializers.
630  */
631 
632 #define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \
633  (memset(&(node), 0, sizeof(yaml_node_t)), \
634  (node).type = (node_type), \
635  (node).tag = (node_tag), \
636  (node).start_mark = (node_start_mark), \
637  (node).end_mark = (node_end_mark))
638 
639 #define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \
640  node_style,start_mark,end_mark) \
641  (NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \
642  (node).data.scalar.value = (node_value), \
643  (node).data.scalar.length = (node_length), \
644  (node).data.scalar.style = (node_style))
645 
646 #define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \
647  node_style,start_mark,end_mark) \
648  (NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \
649  (node).data.sequence.items.start = (node_items_start), \
650  (node).data.sequence.items.end = (node_items_end), \
651  (node).data.sequence.items.top = (node_items_start), \
652  (node).data.sequence.style = (node_style))
653 
654 #define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \
655  node_style,start_mark,end_mark) \
656  (NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \
657  (node).data.mapping.pairs.start = (node_pairs_start), \
658  (node).data.mapping.pairs.end = (node_pairs_end), \
659  (node).data.mapping.pairs.top = (node_pairs_start), \
660  (node).data.mapping.style = (node_style))
661 
#define tail
Definition: st.c:108
yaml_parser_fetch_more_tokens(yaml_parser_t *parser)
Definition: scanner.c:800
yaml_malloc(size_t size)
Definition: api.c:31
yaml_char_t * end
Definition: yaml_private.h:113
Public interface for libyaml.
The parser structure.
Definition: yaml.h:1081
yaml_realloc(void *ptr, size_t size)
Definition: api.c:41
unsigned char yaml_char_t
The character type (UTF-8 octet).
Definition: yaml.h:78
yaml_char_t * pointer
Definition: yaml_private.h:114
#define head
Definition: st.c:107
yaml_char_t * start
Definition: yaml_private.h:112
yaml_free(void *ptr)
Definition: api.c:51
yaml_string_extend(yaml_char_t **start, yaml_char_t **pointer, yaml_char_t **end)
Definition: api.c:74
yaml_stack_extend(void **start, void **top, void **end)
Definition: api.c:118
#define YAML_DECLARE(type)
The public API declaration.
Definition: yaml.h:38
#define const
Definition: strftime.c:102
yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
Definition: reader.c:142
yaml_strdup(const yaml_char_t *)
Definition: api.c:61
unsigned int top
Definition: nkf.c:4309
int size
Definition: encoding.c:52
yaml_queue_extend(void **start, void **head, void **tail, void **end)
Definition: api.c:136
yaml_string_join(yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end, yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end)
Definition: api.c:95