Ruby  1.9.3p448(2013-06-27revision41675)
rubyext.c
Go to the documentation of this file.
1 /* -*- indent-tabs-mode: nil -*- */
2 /*
3  * rubyext.c
4  *
5  * $Author: nobu $
6  *
7  * Copyright (C) 2003-2005 why the lucky stiff
8  */
9 
10 #include "ruby/ruby.h"
11 #include "ruby/encoding.h"
12 #include "syck.h"
13 #include <sys/types.h>
14 #include <time.h>
15 
16 typedef struct RVALUE {
17  union {
18 #if 0
19  struct {
20  unsigned long flags; /* always 0 for freed obj */
21  struct RVALUE *next;
22  } free;
23 #endif
24  struct RBasic basic;
25  struct RObject object;
26  struct RClass klass;
27  /*struct RFloat flonum;*/
28  /*struct RString string;*/
29  struct RArray array;
30  /*struct RRegexp regexp;*/
31  struct RHash hash;
32  /*struct RData data;*/
33  struct RStruct rstruct;
34  /*struct RBignum bignum;*/
35  /*struct RFile file;*/
36  } as;
37 } RVALUE;
38 
39 typedef struct {
40  long hash;
41  char *buffer;
42  long length;
43  long remaining;
44  int printed;
45 } bytestring_t;
46 
47 #define RUBY_DOMAIN "ruby.yaml.org,2002"
48 
49 /*
50  * symbols and constants
51  */
59 
60 /*
61  * my private collection of numerical oddities.
62  */
63 static double S_zero(void) { return 0.0; }
64 static double S_one(void) { return 1.0; }
65 static double S_inf(void) { return S_one() / S_zero(); }
66 static double S_nan(void) { return S_zero() / S_zero(); }
67 
69 
70 /*
71  * handler prototypes
72  */
74 void rb_syck_err_handler _((SyckParser *, const char *));
76 void rb_syck_output_handler _((SyckEmitter *, char *, long));
80 VALUE syck_seq_alloc _((VALUE class));
81 VALUE syck_map_alloc _((VALUE class));
82 
83 struct parser_xtra {
84  VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */
87  int taint;
88 };
89 
90 struct emitter_xtra {
94 };
95 
96 /*
97  * Convert YAML to bytecode
98  */
99 VALUE
101 {
102  SYMID oid;
103  int taint;
104  char *ret;
105  VALUE bc;
106  bytestring_t *sav = NULL;
107  void *data = NULL;
108 
109  SyckParser *parser = syck_new_parser();
110  taint = syck_parser_assign_io(parser, &port);
112  syck_parser_error_handler( parser, NULL );
113  syck_parser_implicit_typing( parser, 0 );
114  syck_parser_taguri_expansion( parser, 0 );
115  oid = syck_parse( parser );
116  if (!syck_lookup_sym( parser, oid, &data )) {
117  rb_raise(rb_eSyntaxError, "root node <%p> not found", (void *)oid);
118  }
119  sav = data;
120 
121  ret = S_ALLOCA_N( char, strlen( sav->buffer ) + 3 );
122  ret[0] = '\0';
123  strcat( ret, "D\n" );
124  strcat( ret, sav->buffer );
125 
126  syck_free_parser( parser );
127 
128  bc = rb_str_new2( ret );
129  if ( taint ) OBJ_TAINT( bc );
130  return bc;
131 }
132 
133 /*
134  * read from io.
135  */
136 long
137 rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
138 {
139  long len = 0;
140 
141  ASSERT( str != NULL );
142  max_size -= skip;
143 
144  if ( max_size <= 0 ) max_size = 0;
145  else
146  {
147  /*
148  * call io#read.
149  */
150  VALUE src = (VALUE)str->ptr;
151  VALUE n = LONG2NUM(max_size);
152  VALUE str2 = rb_funcall2(src, s_read, 1, &n);
153  if (!NIL_P(str2))
154  {
155  StringValue(str2);
156  len = RSTRING_LEN(str2);
157  memcpy( buf + skip, RSTRING_PTR(str2), len );
158  }
159  }
160  len += skip;
161  buf[len] = '\0';
162  return len;
163 }
164 
165 /*
166  * determine: are we reading from a string or io?
167  * (returns tainted? boolean)
168  */
169 int
171 {
172  int taint = Qtrue;
173  VALUE tmp, port = *pport;
174  if (!NIL_P(tmp = rb_check_string_type(port))) {
175  taint = OBJ_TAINTED(port); /* original taintedness */
176  port = tmp;
177  syck_parser_str( parser, RSTRING_PTR(port), RSTRING_LEN(port), NULL );
178  }
179  else if (rb_respond_to(port, s_read)) {
180  if (rb_respond_to(port, s_binmode)) {
181  rb_funcall2(port, s_binmode, 0, 0);
182  }
183  syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read );
184  }
185  else {
186  rb_raise(rb_eTypeError, "instance of IO needed");
187  }
188  *pport = port;
189  return taint;
190 }
191 
192 /*
193  * Get value in hash by key, forcing an empty hash if nil.
194  */
195 VALUE
197 {
198  VALUE val = rb_hash_aref( hsh, key );
199  if ( NIL_P( val ) )
200  {
201  val = rb_hash_new();
202  rb_hash_aset(hsh, key, val);
203  }
204  return val;
205 }
206 
207 /*
208  * creating timestamps
209  */
210 struct mktime_arg {
211  const char *str;
212  long len;
213 };
214 
215 VALUE
217 {
218  struct mktime_arg *arg = (struct mktime_arg *)varg;
219  VALUE time;
220  const char *str = arg->str;
221  long len = arg->len;
222  const char *ptr = str;
223  VALUE year = INT2FIX(0);
224  VALUE mon = INT2FIX(0);
225  VALUE day = INT2FIX(0);
226  VALUE hour = INT2FIX(0);
227  VALUE min = INT2FIX(0);
228  VALUE sec = INT2FIX(0);
229  long usec;
230 
231  /* Year*/
232  if ( ptr[0] != '\0' && len > 0 ) {
233  year = INT2FIX(strtol(ptr, NULL, 10));
234  }
235 
236  /* Month*/
237  ptr += 4;
238  if ( ptr[0] != '\0' && len > ptr - str ) {
239  while ( !ISDIGIT( *ptr ) ) ptr++;
240  mon = INT2FIX(strtol(ptr, NULL, 10));
241  }
242 
243  /* Day*/
244  ptr += 2;
245  if ( ptr[0] != '\0' && len > ptr - str ) {
246  while ( !ISDIGIT( *ptr ) ) ptr++;
247  day = INT2FIX(strtol(ptr, NULL, 10));
248  }
249 
250  /* Hour*/
251  ptr += 2;
252  if ( ptr[0] != '\0' && len > ptr - str ) {
253  while ( !ISDIGIT( *ptr ) ) ptr++;
254  hour = INT2FIX(strtol(ptr, NULL, 10));
255  }
256 
257  /* Minute */
258  ptr += 2;
259  if ( ptr[0] != '\0' && len > ptr - str ) {
260  while ( !ISDIGIT( *ptr ) ) ptr++;
261  min = INT2FIX(strtol(ptr, NULL, 10));
262  }
263 
264  /* Second */
265  ptr += 2;
266  if ( ptr[0] != '\0' && len > ptr - str ) {
267  while ( !ISDIGIT( *ptr ) ) ptr++;
268  sec = INT2FIX(strtol(ptr, NULL, 10));
269  }
270 
271  /* Millisecond */
272  ptr += 2;
273  if ( len > ptr - str && *ptr == '.' )
274  {
275  char padded[] = "000000";
276  const int padding = (int)(sizeof(padded) - 1);
277  const char *end = ptr + 1;
278  const char *begin = end;
279  ptrdiff_t length;
280  while ( isdigit( *end ) ) end++;
281  if ((length = (end - begin)) > padding) length = padding;
282  MEMCPY(padded, begin, char, length);
283  usec = strtol(padded, NULL, 10);
284  }
285  else
286  {
287  usec = 0;
288  }
289 
290  /* Time Zone*/
291  while ( len > ptr - str && *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++;
292  if ( len > ptr - str && ( *ptr == '-' || *ptr == '+' ) )
293  {
294  time_t tz_offset = strtol(ptr, NULL, 10) * 3600;
295  VALUE tmp;
296 
297  while ( *ptr != ':' && *ptr != '\0' ) ptr++;
298  if ( *ptr == ':' )
299  {
300  ptr += 1;
301  if ( tz_offset < 0 )
302  {
303  tz_offset -= strtol(ptr, NULL, 10) * 60;
304  }
305  else
306  {
307  tz_offset += strtol(ptr, NULL, 10) * 60;
308  }
309  }
310 
311  /* Make TZ time*/
312  time = rb_funcall(rb_cTime, s_utc, 6, year, mon, day, hour, min, sec);
313  tmp = rb_funcall(time, s_to_i, 0);
314  tmp = rb_funcall(tmp, '-', 1, LONG2FIX(tz_offset));
315  return rb_funcall(rb_cTime, s_at, 2, tmp, LONG2NUM(usec));
316  }
317  else
318  {
319  /* Make UTC time*/
320  return rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, LONG2NUM(usec));
321  }
322 }
323 
324 VALUE
326 {
327  struct mktime_arg *arg = (struct mktime_arg *)varg;
328 
329  if (!cDateTime) {
330  /*
331  * Load Date module
332  */
333  rb_require("date");
334  cDateTime = rb_const_get(rb_cObject, rb_intern("DateTime"));
335  }
336  return rb_funcall(cDateTime, s_parse, 1, rb_str_new(arg->str, arg->len));
337 }
338 
339 VALUE
340 rb_syck_mktime(const char *str, long len)
341 {
342  struct mktime_arg a;
343 
344  a.str = str;
345  a.len = len;
347 }
348 
349 /*
350  * handles merging of an array of hashes
351  * (see http://www.yaml.org/type/merge/)
352  */
353 VALUE
355 {
356  VALUE tmp;
357  if ( !NIL_P(tmp = rb_check_convert_type(entry, T_HASH, "Hash", "to_hash")) )
358  {
359  entry = tmp;
360  rb_funcall( hsh, s_update, 1, entry );
361  }
362  return Qnil;
363 }
364 
365 /*
366  * default handler for ruby.yaml.org types
367  */
368 int
370 {
371  char *type_id = n->type_id;
372  int transferred = 0;
373  long i = 0;
374  VALUE obj = Qnil;
375 
376  if ( type_id != NULL && strncmp( type_id, "tag:yaml.org,2002:", 18 ) == 0 )
377  {
378  type_id += 18;
379  }
380 
381  switch (n->kind)
382  {
383  case syck_str_kind:
384  transferred = 1;
385  if ( type_id == NULL )
386  {
387  obj = rb_str_new( n->data.str->ptr, n->data.str->len );
388  }
389  else if ( strcmp( type_id, "null" ) == 0 )
390  {
391  obj = Qnil;
392  }
393  else if ( strcmp( type_id, "binary" ) == 0 )
394  {
395  VALUE arr;
396  obj = rb_str_new( n->data.str->ptr, n->data.str->len );
397  rb_funcall( obj, s_tr_bang, 2, rb_str_new2( "\n\t " ), rb_str_new2( "" ) );
398  arr = rb_funcall( obj, s_unpack, 1, rb_str_new2( "m" ) );
399  obj = rb_ary_shift( arr );
400  }
401  else if ( strcmp( type_id, "bool#yes" ) == 0 )
402  {
403  obj = Qtrue;
404  }
405  else if ( strcmp( type_id, "bool#no" ) == 0 )
406  {
407  obj = Qfalse;
408  }
409  else if ( strcmp( type_id, "int#hex" ) == 0 )
410  {
412  obj = rb_cstr2inum( n->data.str->ptr, 16 );
413  }
414  else if ( strcmp( type_id, "int#oct" ) == 0 )
415  {
417  obj = rb_cstr2inum( n->data.str->ptr, 8 );
418  }
419  else if ( strcmp( type_id, "int#base60" ) == 0 )
420  {
421  char *ptr, *end;
422  long sixty = 1;
423  long total = 0;
425  ptr = n->data.str->ptr;
426  end = n->data.str->ptr + n->data.str->len;
427  while ( end > ptr )
428  {
429  long bnum = 0;
430  char *colon = end - 1;
431  while ( colon >= ptr && *colon != ':' )
432  {
433  colon--;
434  }
435  if ( colon >= ptr && *colon == ':' ) *colon = '\0';
436 
437  bnum = strtol( colon + 1, NULL, 10 );
438  total += bnum * sixty;
439  sixty *= 60;
440  end = colon;
441  }
442  obj = INT2FIX(total);
443  }
444  else if ( strncmp( type_id, "int", 3 ) == 0 )
445  {
447  obj = rb_cstr2inum( n->data.str->ptr, 10 );
448  }
449  else if ( strcmp( type_id, "float#base60" ) == 0 )
450  {
451  char *ptr, *end;
452  long sixty = 1;
453  double total = 0.0;
455  ptr = n->data.str->ptr;
456  end = n->data.str->ptr + n->data.str->len;
457  while ( end > ptr )
458  {
459  double bnum = 0;
460  char *colon = end - 1;
461  while ( colon >= ptr && *colon != ':' )
462  {
463  colon--;
464  }
465  if ( colon >= ptr && *colon == ':' ) *colon = '\0';
466 
467  bnum = strtod( colon + 1, NULL );
468  total += bnum * sixty;
469  sixty *= 60;
470  end = colon;
471  }
472  obj = rb_float_new( total );
473  }
474  else if ( strcmp( type_id, "float#nan" ) == 0 )
475  {
476  obj = rb_float_new( S_nan() );
477  }
478  else if ( strcmp( type_id, "float#inf" ) == 0 )
479  {
480  obj = rb_float_new( S_inf() );
481  }
482  else if ( strcmp( type_id, "float#neginf" ) == 0 )
483  {
484  obj = rb_float_new( -S_inf() );
485  }
486  else if ( strncmp( type_id, "float", 5 ) == 0 )
487  {
488  double f;
490  f = strtod( n->data.str->ptr, NULL );
491  obj = rb_float_new( f );
492  }
493  else if ( strcmp( type_id, "timestamp#iso8601" ) == 0 )
494  {
495  obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
496  }
497  else if ( strcmp( type_id, "timestamp#spaced" ) == 0 )
498  {
499  obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
500  }
501  else if ( strcmp( type_id, "timestamp#ymd" ) == 0 )
502  {
503  char *ptr = n->data.str->ptr;
504  VALUE year, mon, day;
505 
506  /* Year*/
507  ptr[4] = '\0';
508  year = INT2FIX(strtol(ptr, NULL, 10));
509 
510  /* Month*/
511  ptr += 4;
512  while ( !ISDIGIT( *ptr ) ) ptr++;
513  mon = INT2FIX(strtol(ptr, NULL, 10));
514 
515  /* Day*/
516  ptr += 2;
517  while ( !ISDIGIT( *ptr ) ) ptr++;
518  day = INT2FIX(strtol(ptr, NULL, 10));
519 
520  if ( !cDate ) {
521  /*
522  * Load Date module
523  */
524  rb_require( "date" );
525  cDate = rb_const_get( rb_cObject, rb_intern("Date") );
526  }
527 
528  obj = rb_funcall( cDate, s_new, 3, year, mon, day );
529  }
530  else if ( strncmp( type_id, "timestamp", 9 ) == 0 )
531  {
532  obj = rb_syck_mktime( n->data.str->ptr, n->data.str->len );
533  }
534  else if ( strncmp( type_id, "merge", 5 ) == 0 )
535  {
536  obj = rb_funcall( cMergeKey, s_new, 0 );
537  }
538  else if ( strncmp( type_id, "default", 7 ) == 0 )
539  {
540  obj = rb_funcall( cDefaultKey, s_new, 0 );
541  }
542  else if ( n->data.str->style == scalar_plain &&
543  n->data.str->len > 1 &&
544  strncmp( n->data.str->ptr, ":", 1 ) == 0 )
545  {
547  rb_str_new2( "tag:ruby.yaml.org,2002:sym" ),
548  rb_str_new( n->data.str->ptr + 1, n->data.str->len - 1 ) );
549  }
550  else if ( strcmp( type_id, "str" ) == 0 )
551  {
552  obj = rb_str_new( n->data.str->ptr, n->data.str->len );
554  }
555  else
556  {
557  transferred = 0;
558  obj = rb_str_new( n->data.str->ptr, n->data.str->len );
559  }
560  break;
561 
562  case syck_seq_kind:
563  if ( type_id == NULL || strcmp( type_id, "seq" ) == 0 )
564  {
565  transferred = 1;
566  }
567  obj = rb_ary_new2( n->data.list->idx );
568  for ( i = 0; i < n->data.list->idx; i++ )
569  {
570  rb_ary_store( obj, i, syck_seq_read( n, i ) );
571  }
572  break;
573 
574  case syck_map_kind:
575  if ( type_id == NULL || strcmp( type_id, "map" ) == 0 )
576  {
577  transferred = 1;
578  }
579  obj = rb_hash_new();
580  for ( i = 0; i < n->data.pairs->idx; i++ )
581  {
582  VALUE k = syck_map_read( n, map_key, i );
583  VALUE v = syck_map_read( n, map_value, i );
584  int skip_aset = 0;
585 
586  /*
587  * Handle merge keys
588  */
589  if ( rb_obj_is_kind_of( k, cMergeKey ) )
590  {
591  VALUE tmp;
592  if ( !NIL_P(tmp = rb_check_convert_type(v, T_HASH, "Hash", "to_hash")) )
593  {
594  VALUE dup = rb_funcall( tmp, s_dup, 0 );
595  rb_funcall( dup, s_update, 1, obj );
596  obj = dup;
597  skip_aset = 1;
598  }
599  else if ( !NIL_P(tmp = rb_check_array_type(v)) )
600  {
601  VALUE end = rb_ary_pop( tmp );
602  VALUE tmph = rb_check_convert_type(end, T_HASH, "Hash", "to_hash");
603  if ( !NIL_P(tmph) )
604  {
605  VALUE dup = rb_funcall( tmph, s_dup, 0 );
606  tmp = rb_ary_reverse( tmp );
607  rb_ary_push( tmp, obj );
608  rb_block_call( tmp, s_each, 0, 0, syck_merge_i, dup );
609  obj = dup;
610  skip_aset = 1;
611  }
612  }
613  }
614  else if ( rb_obj_is_kind_of( k, cDefaultKey ) )
615  {
616  rb_funcall( obj, s_default_set, 1, v );
617  skip_aset = 1;
618  }
619 
620  if ( ! skip_aset )
621  {
622  rb_hash_aset( obj, k, v );
623  }
624  }
625  break;
626  }
627 
628  *ref = obj;
629  return transferred;
630 }
631 
632 static void syck_node_mark( SyckNode *n );
633 
634 /*
635  * {native mode} node handler
636  * - Converts data into native Ruby types
637  */
638 SYMID
640 {
641  VALUE obj = Qnil;
642  struct parser_xtra *bonus = (struct parser_xtra *)p->bonus;
643  VALUE resolver = bonus->resolver;
644  if ( NIL_P( resolver ) )
645  {
647  }
648 
649  /*
650  * Create node,
651  */
653 
654  /*
655  * ID already set, let's alter the symbol table to accept the new object
656  */
657  if (n->id > 0 && !NIL_P(obj))
658  {
659  MEMCPY((void *)n->id, (void *)obj, RVALUE, 1);
660  MEMZERO((void *)obj, RVALUE, 1);
661  obj = n->id;
662  }
663 
664  if ( bonus->taint) OBJ_TAINT( obj );
665  if ( bonus->proc != 0 ) rb_funcall(bonus->proc, s_call, 1, obj);
666 
667  rb_hash_aset(bonus->data, INT2FIX(RHASH_SIZE(bonus->data)), obj);
668  return obj;
669 }
670 
671 /*
672  * friendly errors.
673  */
674 void
676 {
677  char *endl = p->cursor;
678 
679  while ( *endl != '\0' && *endl != '\n' )
680  endl++;
681 
682  endl[0] = '\0';
683  rb_raise(rb_eArgError, "%s on line %d, col %"PRIdPTRDIFF": `%s'",
684  msg,
685  p->linect,
686  p->cursor - p->lineptr,
687  p->lineptr);
688 }
689 
690 /*
691  * provide bad anchor object to the parser.
692  */
693 SyckNode *
695 {
696  VALUE anchor_name = rb_str_new2( a );
697  SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name );
698  badanc->type_id = syck_strndup( "tag:ruby.yaml.org,2002:object:YAML::Syck::BadAlias", 53 );
699  return badanc;
700 }
701 
702 /*
703  * data loaded based on the model requested.
704  */
705 void
707 {
708  SyckParser *parser;
709  Data_Get_Struct(p, SyckParser, parser);
711  /* WARN: gonna be obsoleted soon!! */
712  if ( model == sym_generic )
713  {
715  }
716  syck_parser_implicit_typing( parser, 1 );
717  syck_parser_taguri_expansion( parser, 1 );
718 
719  if ( NIL_P( input ) )
720  {
721  input = rb_ivar_get( p, s_input );
722  }
723  if ( input == sym_bytecode )
724  {
726  }
727  else
728  {
730  }
733 }
734 
735 static int
736 syck_st_mark_nodes( char *key, SyckNode *n, char *arg )
737 {
738  if ( n != (void *)1 ) syck_node_mark( n );
739  return ST_CONTINUE;
740 }
741 
742 /*
743  * mark parser nodes
744  */
745 static void
747 {
748  struct parser_xtra *bonus = (struct parser_xtra *)parser->bonus;
749  rb_gc_mark_maybe(parser->root);
751  rb_gc_mark( bonus->data );
752  rb_gc_mark( bonus->proc );
753  rb_gc_mark( bonus->resolver );
754 
755  if ( parser->anchors != NULL )
756  {
757  st_foreach( parser->anchors, syck_st_mark_nodes, 0 );
758  }
759  if ( parser->bad_anchors != NULL )
760  {
762  }
763 }
764 
765 /*
766  * Free the parser and any bonus attachment.
767  */
768 void
770 {
771  S_FREE( p->bonus );
772  syck_free_parser(p);
773 }
774 
775 /*
776  * YAML::Syck::Parser.allocate
777  */
779 VALUE
781 {
782  VALUE pobj;
783  SyckParser *parser = syck_new_parser();
784 
785  parser->bonus = S_ALLOC( struct parser_xtra );
786  S_MEMZERO( parser->bonus, struct parser_xtra, 1 );
787 
788  pobj = Data_Wrap_Struct( class, syck_mark_parser, rb_syck_free_parser, parser );
789 
791 
792  return pobj;
793 }
794 
795 /*
796  * YAML::Syck::Parser.initialize( resolver, options )
797  */
798 static VALUE
800 {
801  VALUE options;
802  if (rb_scan_args(argc, argv, "01", &options) == 0)
803  {
804  options = rb_hash_new();
805  }
806  else
807  {
808  Check_Type(options, T_HASH);
809  }
810  rb_ivar_set(self, s_options, options);
811  rb_ivar_set(self, s_input, Qnil);
812  return self;
813 }
814 
815 /*
816  * YAML::Syck::Parser.bufsize = Integer
817  */
818 static VALUE
820 {
821  SyckParser *parser;
822 
823  if ( rb_respond_to( size, s_to_i ) ) {
824  int n = NUM2INT(rb_funcall(size, s_to_i, 0));
825  Data_Get_Struct(self, SyckParser, parser);
826  parser->bufsize = n;
827  }
828  return self;
829 }
830 
831 /*
832  * YAML::Syck::Parser.bufsize => Integer
833  */
834 static VALUE
836 {
837  SyckParser *parser;
838 
839  Data_Get_Struct(self, SyckParser, parser);
840  return INT2FIX( parser->bufsize );
841 }
842 
843 /*
844  * YAML::Syck::Parser.load( IO or String )
845  */
846 VALUE
848 {
849  VALUE port, proc, model, input;
850  SyckParser *parser;
851  struct parser_xtra *bonus;
852 
853  rb_scan_args(argc, argv, "11", &port, &proc);
854 
855  input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
856  model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
857  Data_Get_Struct(self, SyckParser, parser);
858  syck_set_model( self, input, model );
859 
860  bonus = (struct parser_xtra *)parser->bonus;
861  bonus->taint = syck_parser_assign_io(parser, &port);
862  bonus->data = rb_hash_new();
863  bonus->resolver = rb_attr_get( self, s_resolver );
864  if ( NIL_P( proc ) ) bonus->proc = 0;
865  else bonus->proc = proc;
866 
867  return syck_parse( parser );
868 }
869 
870 /*
871  * YAML::Syck::Parser.load_documents( IO or String ) { |doc| }
872  */
873 VALUE
875 {
876  VALUE port, proc, v, input, model;
877  SyckParser *parser;
878  struct parser_xtra *bonus;
879 
880  rb_scan_args(argc, argv, "1&", &port, &proc);
881 
882  input = rb_hash_aref( rb_attr_get( self, s_options ), sym_input );
883  model = rb_hash_aref( rb_attr_get( self, s_options ), sym_model );
884  Data_Get_Struct(self, SyckParser, parser);
885  syck_set_model( self, input, model );
886 
887  bonus = (struct parser_xtra *)parser->bonus;
888  bonus->taint = syck_parser_assign_io(parser, &port);
889  bonus->resolver = rb_attr_get( self, s_resolver );
890  bonus->proc = 0;
891 
892  while ( 1 )
893  {
894  /* Reset hash for tracking nodes */
895  bonus->data = rb_hash_new();
896 
897  /* Parse a document */
898  v = syck_parse( parser );
899  if ( parser->eof == 1 )
900  {
901  break;
902  }
903 
904  /* Pass document to block */
905  rb_funcall( proc, s_call, 1, v );
906  }
907 
908  return Qnil;
909 }
910 
911 /*
912  * YAML::Syck::Parser#set_resolver
913  */
914 VALUE
916 {
917  rb_ivar_set( self, s_resolver, resolver );
918  return self;
919 }
920 
921 /*
922  * YAML::Syck::Resolver.initialize
923  */
924 static VALUE
926 {
927  rb_ivar_set(self, s_tags, rb_hash_new());
928  return self;
929 }
930 
931 /*
932  * YAML::Syck::Resolver#add_type
933  */
934 VALUE
936 {
937  VALUE tags = rb_attr_get(self, s_tags);
938  rb_hash_aset( tags, taguri, cls );
939  return Qnil;
940 }
941 
942 /*
943  * YAML::Syck::Resolver#use_types_at
944  */
945 VALUE
947 {
948  rb_ivar_set( self, s_tags, hsh );
949  return Qnil;
950 }
951 
952 /*
953  * YAML::Syck::Resolver#detect_implicit
954  */
955 VALUE
957 {
958  return rb_str_new2( "" );
959 }
960 
961 /*
962  * YAML::Syck::Resolver#node_import
963  */
964 VALUE
966 {
967  SyckNode *n;
968  VALUE obj = Qnil;
969  int i = 0;
970  Data_Get_Struct(node, SyckNode, n);
971 
972  switch (n->kind)
973  {
974  case syck_str_kind:
975  obj = rb_str_new( n->data.str->ptr, n->data.str->len );
976  break;
977 
978  case syck_seq_kind:
979  obj = rb_ary_new2( n->data.list->idx );
980  for ( i = 0; i < n->data.list->idx; i++ )
981  {
982  rb_ary_store( obj, i, syck_seq_read( n, i ) );
983  }
984  break;
985 
986  case syck_map_kind:
987  obj = rb_hash_new();
988  for ( i = 0; i < n->data.pairs->idx; i++ )
989  {
990  VALUE k = syck_map_read( n, map_key, i );
991  VALUE v = syck_map_read( n, map_value, i );
992  int skip_aset = 0;
993 
994  /*
995  * Handle merge keys
996  */
997  if ( rb_obj_is_kind_of( k, cMergeKey ) )
998  {
999  if ( rb_obj_is_kind_of( v, rb_cHash ) )
1000  {
1001  VALUE dup = rb_funcall( v, s_dup, 0 );
1002  rb_funcall( dup, s_update, 1, obj );
1003  obj = dup;
1004  skip_aset = 1;
1005  }
1006  else if ( rb_obj_is_kind_of( v, rb_cArray ) )
1007  {
1008  VALUE end = rb_ary_pop( v );
1009  if ( rb_obj_is_kind_of( end, rb_cHash ) )
1010  {
1011  VALUE dup = rb_funcall( end, s_dup, 0 );
1012  v = rb_ary_reverse( v );
1013  rb_ary_push( v, obj );
1014  rb_block_call( v, s_each, 0, 0, syck_merge_i, dup );
1015  obj = dup;
1016  skip_aset = 1;
1017  }
1018  }
1019  }
1020  else if ( rb_obj_is_kind_of( k, cDefaultKey ) )
1021  {
1022  rb_funcall( obj, s_default_set, 1, v );
1023  skip_aset = 1;
1024  }
1025 
1026  if ( ! skip_aset )
1027  {
1028  rb_hash_aset( obj, k, v );
1029  }
1030  }
1031  break;
1032  }
1033 
1034  if ( n->type_id != NULL )
1035  {
1036  obj = rb_funcall( self, s_transfer, 2, rb_str_new2( n->type_id ), obj );
1037  }
1038  return obj;
1039 }
1040 
1041 /*
1042  * Set instance variables
1043  */
1044 VALUE
1046 {
1047  VALUE ivname = rb_ary_entry( vars, 0 );
1048  char *ivn;
1049  StringValue( ivname );
1050  ivn = S_ALLOCA_N( char, RSTRING_LEN(ivname) + 2 );
1051  ivn[0] = '@';
1052  ivn[1] = '\0';
1053  strncat( ivn, RSTRING_PTR(ivname), RSTRING_LEN(ivname) );
1054  rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
1055  return Qnil;
1056 }
1057 
1058 /*
1059  * YAML::Syck::Resolver#const_find
1060  */
1061 VALUE
1063 {
1064  VALUE tclass = rb_cObject;
1065  VALUE tparts = rb_str_split( const_name, "::" );
1066  int i = 0;
1067  for ( i = 0; i < RARRAY_LEN(tparts); i++ ) {
1068  VALUE tpart = rb_to_id( rb_ary_entry( tparts, i ) );
1069  if ( !rb_const_defined( tclass, tpart ) ) return Qnil;
1070  tclass = rb_const_get( tclass, tpart );
1071  }
1072  return tclass;
1073 }
1074 
1075 /*
1076  * YAML::Syck::Resolver#transfer
1077  */
1078 VALUE
1080 {
1081  if (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0)
1082  {
1083  type = rb_funcall( self, s_detect_implicit, 1, val );
1084  }
1085 
1086  if ( ! (NIL_P(type) || RSTRING_LEN(StringValue(type)) == 0) )
1087  {
1088  VALUE str_xprivate = rb_str_new2( "x-private" );
1089  VALUE colon = rb_str_new2( ":" );
1090  VALUE tags = rb_attr_get(self, s_tags);
1091  VALUE target_class = rb_hash_aref( tags, type );
1092  VALUE subclass = target_class;
1093  VALUE obj = Qnil;
1094 
1095  /*
1096  * Should no tag match exactly, check for subclass format
1097  */
1098  if ( NIL_P( target_class ) )
1099  {
1100  VALUE subclass_parts = rb_ary_new();
1101  VALUE parts = rb_str_split( type, ":" );
1102 
1103  while ( RARRAY_LEN(parts) > 1 )
1104  {
1105  VALUE partial;
1106  rb_ary_unshift( subclass_parts, rb_ary_pop( parts ) );
1107  partial = rb_ary_join( parts, colon );
1108  target_class = rb_hash_aref( tags, partial );
1109  if ( NIL_P( target_class ) )
1110  {
1111  rb_str_append( partial, colon );
1112  target_class = rb_hash_aref( tags, partial );
1113  }
1114 
1115  /*
1116  * Possible subclass found, see if it supports subclassing
1117  */
1118  if ( ! NIL_P( target_class ) )
1119  {
1120  subclass = target_class;
1121  if ( RARRAY_LEN(subclass_parts) > 0 && rb_respond_to( target_class, s_tag_subclasses ) &&
1122  RTEST( rb_funcall( target_class, s_tag_subclasses, 0 ) ) )
1123  {
1124  VALUE subclass_v;
1125  subclass = rb_ary_join( subclass_parts, colon );
1126  subclass = rb_funcall( target_class, s_tag_read_class, 1, subclass );
1127  subclass_v = syck_const_find( subclass );
1128 
1129  if ( subclass_v != Qnil )
1130  {
1131  subclass = subclass_v;
1132  }
1133  else if ( rb_cObject == target_class && subclass_v == Qnil )
1134  {
1135  target_class = cYObject;
1136  type = subclass;
1137  subclass = cYObject;
1138  }
1139  else /* workaround for SEGV. real fix please */
1140  {
1141  rb_raise( rb_eTypeError, "invalid subclass" );
1142  }
1143  }
1144  break;
1145  }
1146  }
1147  }
1148 
1149  /* rb_raise(rb_eTypeError, "invalid typing scheme: %s given",
1150  * scheme);
1151  */
1152 
1153  if ( rb_respond_to( target_class, s_call ) )
1154  {
1155  obj = rb_funcall( target_class, s_call, 2, type, val );
1156  }
1157  else
1158  {
1159  if ( rb_respond_to( target_class, s_yaml_new ) )
1160  {
1161  obj = rb_funcall( target_class, s_yaml_new, 3, subclass, type, val );
1162  }
1163  else if ( !NIL_P( target_class ) )
1164  {
1165  if ( subclass == rb_cBignum )
1166  {
1167  obj = rb_str2inum( val, 10 ); /* for yaml dumped by 1.8.3 [ruby-core:6159] */
1168  }
1169  else
1170  {
1171  obj = rb_obj_alloc( subclass );
1172  }
1173 
1174  if ( rb_respond_to( obj, s_yaml_initialize ) )
1175  {
1176  rb_funcall( obj, s_yaml_initialize, 2, type, val );
1177  }
1178  else if ( !NIL_P( obj ) && rb_obj_is_instance_of( val, rb_cHash ) )
1179  {
1180  rb_block_call( val, s_each, 0, 0, syck_set_ivars, obj );
1181  }
1182  }
1183  else
1184  {
1185  VALUE parts = rb_str_split( type, ":" );
1186  VALUE scheme = rb_ary_shift( parts );
1187  if ( rb_str_cmp( scheme, str_xprivate ) == 0 )
1188  {
1189  VALUE name = rb_ary_join( parts, colon );
1190  obj = rb_funcall( cPrivateType, s_new, 2, name, val );
1191  }
1192  else
1193  {
1194  VALUE domain = rb_ary_shift( parts );
1195  VALUE name = rb_ary_join( parts, colon );
1196  obj = rb_funcall( cDomainType, s_new, 3, domain, name, val );
1197  }
1198  }
1199  }
1200  val = obj;
1201  }
1202 
1203  return val;
1204 }
1205 
1206 /*
1207  * YAML::Syck::Resolver#tagurize
1208  */
1209 VALUE
1211 {
1212  VALUE tmp = rb_check_string_type(val);
1213 
1214  if ( !NIL_P(tmp) )
1215  {
1216  char *taguri = syck_type_id_to_uri( RSTRING_PTR(tmp) );
1217  val = rb_str_new2( taguri );
1218  S_FREE( taguri );
1219  }
1220 
1221  return val;
1222 }
1223 
1224 /*
1225  * YAML::Syck::DefaultResolver#detect_implicit
1226  */
1227 VALUE
1229 {
1230  const char *type_id;
1231  VALUE tmp = rb_check_string_type(val);
1232 
1233  if ( !NIL_P(tmp) )
1234  {
1235  val = tmp;
1236  type_id = syck_match_implicit( RSTRING_PTR(val), RSTRING_LEN(val) );
1237  return rb_str_new2( type_id );
1238  }
1239 
1240  return rb_str_new2( "" );
1241 }
1242 
1243 /*
1244  * YAML::Syck::DefaultResolver#node_import
1245  */
1246 VALUE
1248 {
1249  SyckNode *n;
1250  VALUE obj;
1251  Data_Get_Struct( node, SyckNode, n );
1252  if ( !yaml_org_handler( n, &obj ) )
1253  {
1254  obj = rb_funcall( self, s_transfer, 2, rb_str_new2( n->type_id ), obj );
1255  }
1256  return obj;
1257 }
1258 
1259 /*
1260  * YAML::Syck::GenericResolver#node_import
1261  */
1262 VALUE
1264 {
1265  SyckNode *n;
1266  int i = 0;
1267  VALUE t = Qnil, obj = Qnil, v = Qnil, style = Qnil;
1268  Data_Get_Struct(node, SyckNode, n);
1269 
1270  if ( n->type_id != NULL )
1271  {
1272  t = rb_str_new2(n->type_id);
1273  }
1274 
1275  switch (n->kind)
1276  {
1277  case syck_str_kind:
1278  {
1279  v = rb_str_new( n->data.str->ptr, n->data.str->len );
1281  if ( n->data.str->style == scalar_1quote )
1282  {
1283  style = sym_1quote;
1284  }
1285  else if ( n->data.str->style == scalar_2quote )
1286  {
1287  style = sym_2quote;
1288  }
1289  else if ( n->data.str->style == scalar_fold )
1290  {
1291  style = sym_fold;
1292  }
1293  else if ( n->data.str->style == scalar_literal )
1294  {
1295  style = sym_literal;
1296  }
1297  else if ( n->data.str->style == scalar_plain )
1298  {
1299  style = sym_plain;
1300  }
1301  obj = rb_funcall( cScalar, s_new, 3, t, v, style );
1302  }
1303  break;
1304 
1305  case syck_seq_kind:
1306  v = rb_ary_new2( syck_seq_count( n ) );
1307  for ( i = 0; i < syck_seq_count( n ); i++ )
1308  {
1309  rb_ary_store( v, i, syck_seq_read( n, i ) );
1310  }
1311  if ( n->data.list->style == seq_inline )
1312  {
1313  style = sym_inline;
1314  }
1315  obj = rb_funcall( cSeq, s_new, 3, t, v, style );
1316  rb_iv_set(obj, "@kind", sym_seq);
1317  break;
1318 
1319  case syck_map_kind:
1320  v = rb_hash_new();
1321  for ( i = 0; i < syck_map_count( n ); i++ )
1322  {
1323  rb_hash_aset( v, syck_map_read( n, map_key, i ), syck_map_read( n, map_value, i ) );
1324  }
1325  if ( n->data.pairs->style == map_inline )
1326  {
1327  style = sym_inline;
1328  }
1329  obj = rb_funcall( cMap, s_new, 3, t, v, style );
1330  rb_iv_set(obj, "@kind", sym_map);
1331  break;
1332  }
1333 
1334  return obj;
1335 }
1336 
1337 /*
1338  * YAML::Syck::BadAlias.initialize
1339  */
1340 VALUE
1342 {
1343  rb_iv_set( self, "@name", val );
1344  return self;
1345 }
1346 
1347 /*
1348  * YAML::Syck::BadAlias.<=>
1349  */
1350 VALUE
1352 {
1353  VALUE str1 = rb_ivar_get( alias1, s_name );
1354  VALUE str2 = rb_ivar_get( alias2, s_name );
1355  VALUE val = rb_funcall( str1, s_cmp, 1, str2 );
1356  return val;
1357 }
1358 
1359 /*
1360  * YAML::DomainType.initialize
1361  */
1362 VALUE
1363 syck_domaintype_initialize(VALUE self, VALUE domain, VALUE type_id, VALUE val)
1364 {
1365  rb_iv_set( self, "@domain", domain );
1366  rb_iv_set( self, "@type_id", type_id );
1367  rb_iv_set( self, "@value", val );
1368  return self;
1369 }
1370 
1371 /*
1372  * YAML::Object.initialize
1373  */
1374 VALUE
1376 {
1377  rb_iv_set( self, "@class", klass );
1378  rb_iv_set( self, "@ivars", ivars );
1379  return self;
1380 }
1381 
1382 /*
1383  * YAML::PrivateType.initialize
1384  */
1385 VALUE
1387 {
1388  rb_iv_set( self, "@type_id", type_id );
1389  rb_iv_set( self, "@value", val );
1390  return self;
1391 }
1392 
1393 /*
1394  * Mark node contents.
1395  */
1396 static void
1398 {
1399  int i;
1400  rb_gc_mark_maybe( n->id );
1401  switch ( n->kind )
1402  {
1403  case syck_seq_kind:
1404  for ( i = 0; i < n->data.list->idx; i++ )
1405  {
1406  rb_gc_mark( syck_seq_read( n, i ) );
1407  }
1408  break;
1409 
1410  case syck_map_kind:
1411  for ( i = 0; i < n->data.pairs->idx; i++ )
1412  {
1413  rb_gc_mark( syck_map_read( n, map_key, i ) );
1414  rb_gc_mark( syck_map_read( n, map_value, i ) );
1415  }
1416  break;
1417 
1418  case syck_str_kind:
1419  default:
1420  /* nothing */
1421  break;
1422  }
1423 #if 0 /* maybe needed */
1424  if ( n->shortcut ) syck_node_mark( n->shortcut ); /* caution: maybe cyclic */
1425 #endif
1426 }
1427 
1428 /*
1429  * YAML::Syck::Scalar.allocate
1430  */
1431 VALUE
1433 {
1434  SyckNode *node = syck_alloc_str();
1435  VALUE obj = Data_Wrap_Struct( class, syck_node_mark, syck_free_node, node );
1436  node->id = obj;
1437  return obj;
1438 }
1439 
1440 /*
1441  * YAML::Syck::Scalar.initialize
1442  */
1443 VALUE
1444 syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
1445 {
1446  rb_iv_set( self, "@kind", sym_scalar );
1447  rb_funcall( self, s_type_id_set, 1, type_id );
1448  rb_funcall( self, s_value_set, 1, val );
1449  rb_funcall( self, s_style_set, 1, style );
1450  return self;
1451 }
1452 
1453 /*
1454  * YAML::Syck::Scalar.style=
1455  */
1456 VALUE
1458 {
1459  SyckNode *node;
1460  Data_Get_Struct( self, SyckNode, node );
1461 
1462  if ( NIL_P( style ) )
1463  {
1464  node->data.str->style = scalar_none;
1465  }
1466  else if ( style == sym_1quote )
1467  {
1468  node->data.str->style = scalar_1quote;
1469  }
1470  else if ( style == sym_2quote )
1471  {
1472  node->data.str->style = scalar_2quote;
1473  }
1474  else if ( style == sym_fold )
1475  {
1476  node->data.str->style = scalar_fold;
1477  }
1478  else if ( style == sym_literal )
1479  {
1480  node->data.str->style = scalar_literal;
1481  }
1482  else if ( style == sym_plain )
1483  {
1484  node->data.str->style = scalar_plain;
1485  }
1486 
1487  rb_iv_set( self, "@style", style );
1488  return self;
1489 }
1490 
1491 /*
1492  * YAML::Syck::Scalar.value=
1493  */
1494 VALUE
1496 {
1497  SyckNode *node;
1498  Data_Get_Struct( self, SyckNode, node );
1499 
1500  StringValue( val );
1501  node->data.str->ptr = syck_strndup( RSTRING_PTR(val), RSTRING_LEN(val) );
1502  node->data.str->len = RSTRING_LEN(val);
1503  node->data.str->style = scalar_none;
1504 
1505  rb_iv_set( self, "@value", val );
1506  return val;
1507 }
1508 
1509 /*
1510  * YAML::Syck::Seq.allocate
1511  */
1512 VALUE
1514 {
1515  SyckNode *node;
1516  VALUE obj;
1517  node = syck_alloc_seq();
1518  obj = Data_Wrap_Struct( class, syck_node_mark, syck_free_node, node );
1519  node->id = obj;
1520  return obj;
1521 }
1522 
1523 /*
1524  * YAML::Syck::Seq.initialize
1525  */
1526 VALUE
1527 syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
1528 {
1529  SyckNode *node;
1530  Data_Get_Struct( self, SyckNode, node );
1531 
1532  rb_iv_set( self, "@kind", sym_seq );
1533  rb_funcall( self, s_type_id_set, 1, type_id );
1534  rb_funcall( self, s_value_set, 1, val );
1535  rb_funcall( self, s_style_set, 1, style );
1536  return self;
1537 }
1538 
1539 /*
1540  * YAML::Syck::Seq.value=
1541  */
1542 VALUE
1544 {
1545  SyckNode *node;
1546  Data_Get_Struct( self, SyckNode, node );
1547 
1548  val = rb_check_array_type( val );
1549  if ( !NIL_P( val ) ) {
1550  int i;
1551  syck_seq_empty( node );
1552  for ( i = 0; i < RARRAY_LEN( val ); i++ )
1553  {
1554  syck_seq_add( node, rb_ary_entry(val, i) );
1555  }
1556  }
1557 
1558  rb_iv_set( self, "@value", val );
1559  return val;
1560 }
1561 
1562 /*
1563  * YAML::Syck::Seq.add
1564  */
1565 VALUE
1567 {
1568  SyckNode *node;
1569  VALUE emitter = rb_ivar_get( self, s_emitter );
1570  Data_Get_Struct( self, SyckNode, node );
1571 
1572  if ( rb_respond_to( emitter, s_node_export ) ) {
1573  val = rb_funcall( emitter, s_node_export, 1, val );
1574  }
1575  syck_seq_add( node, val );
1576  rb_ary_push( rb_ivar_get( self, s_value ), val );
1577 
1578  return self;
1579 }
1580 
1581 /*
1582  * YAML::Syck::Seq.style=
1583  */
1584 VALUE
1586 {
1587  SyckNode *node;
1588  Data_Get_Struct( self, SyckNode, node );
1589 
1590  if ( style == sym_inline )
1591  {
1592  node->data.list->style = seq_inline;
1593  }
1594  else
1595  {
1596  node->data.list->style = seq_none;
1597  }
1598 
1599  rb_iv_set( self, "@style", style );
1600  return self;
1601 }
1602 
1603 /*
1604  * YAML::Syck::Map.allocate
1605  */
1606 VALUE
1608 {
1609  SyckNode *node;
1610  VALUE obj;
1611  node = syck_alloc_map();
1612  obj = Data_Wrap_Struct( class, syck_node_mark, syck_free_node, node );
1613  node->id = obj;
1614  return obj;
1615 }
1616 
1617 /*
1618  * YAML::Syck::Map.initialize
1619  */
1620 VALUE
1621 syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
1622 {
1623  SyckNode *node;
1624  Data_Get_Struct( self, SyckNode, node );
1625 
1626  if ( !NIL_P( val ) )
1627  {
1628  VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
1629  VALUE keys;
1630  int i;
1631  if ( NIL_P(hsh) )
1632  {
1633  rb_raise( rb_eTypeError, "wrong argument type" );
1634  }
1635 
1636  keys = rb_funcall( hsh, s_keys, 0 );
1637  for ( i = 0; i < RARRAY_LEN(keys); i++ )
1638  {
1639  VALUE key = rb_ary_entry(keys, i);
1640  syck_map_add( node, key, rb_hash_aref(hsh, key) );
1641  }
1642  }
1643 
1644  rb_iv_set( self, "@kind", sym_seq );
1645  rb_funcall( self, s_type_id_set, 1, type_id );
1646  rb_funcall( self, s_value_set, 1, val );
1647  rb_funcall( self, s_style_set, 1, style );
1648  return self;
1649 }
1650 
1651 /*
1652  * YAML::Syck::Map.value=
1653  */
1654 VALUE
1656 {
1657  SyckNode *node;
1658  Data_Get_Struct( self, SyckNode, node );
1659 
1660  if ( !NIL_P( val ) )
1661  {
1662  VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
1663  VALUE keys;
1664  int i;
1665  if ( NIL_P(hsh) )
1666  {
1667  rb_raise( rb_eTypeError, "wrong argument type" );
1668  }
1669 
1670  syck_map_empty( node );
1671  keys = rb_funcall( hsh, s_keys, 0 );
1672  for ( i = 0; i < RARRAY_LEN(keys); i++ )
1673  {
1674  VALUE key = rb_ary_entry(keys, i);
1675  syck_map_add( node, key, rb_hash_aref(hsh, key) );
1676  }
1677  }
1678 
1679  rb_iv_set( self, "@value", val );
1680  return val;
1681 }
1682 
1683 /*
1684  * YAML::Syck::Map.add
1685  */
1686 VALUE
1688 {
1689  SyckNode *node;
1690  VALUE emitter = rb_ivar_get( self, s_emitter );
1691  Data_Get_Struct( self, SyckNode, node );
1692 
1693  if ( rb_respond_to( emitter, s_node_export ) ) {
1694  key = rb_funcall( emitter, s_node_export, 1, key );
1695  val = rb_funcall( emitter, s_node_export, 1, val );
1696  }
1697  syck_map_add( node, key, val );
1698  rb_hash_aset( rb_ivar_get( self, s_value ), key, val );
1699 
1700  return self;
1701 }
1702 
1703 /*
1704  * YAML::Syck::Map.style=
1705  */
1706 VALUE
1708 {
1709  SyckNode *node;
1710  Data_Get_Struct( self, SyckNode, node );
1711 
1712  if ( style == sym_inline )
1713  {
1714  node->data.pairs->style = map_inline;
1715  }
1716  else
1717  {
1718  node->data.pairs->style = map_none;
1719  }
1720 
1721  rb_iv_set( self, "@style", style );
1722  return self;
1723 }
1724 
1725 #if 0
1726 /*
1727  * Cloning method for all node types
1728  */
1729 VALUE
1730 syck_node_init_copy(VALUE copy, VALUE orig)
1731 {
1732  SyckNode *copy_n;
1733  SyckNode *orig_n;
1734 
1735  if ( copy == orig )
1736  return copy;
1737 
1738  if ( TYPE( orig ) != T_DATA )
1739  {
1740  rb_raise( rb_eTypeError, "wrong argument type" );
1741  }
1742 
1743  Data_Get_Struct( orig, SyckNode, orig_n );
1744  Data_Get_Struct( copy, SyckNode, copy_n );
1745  MEMCPY( copy_n, orig_n, SyckNode, 1 );
1746  return copy;
1747 }
1748 #endif
1749 
1750 /*
1751  * YAML::Syck::Node#type_id=
1752  */
1753 VALUE
1755 {
1756  SyckNode *node;
1757  Data_Get_Struct( self, SyckNode, node );
1758 
1759  S_FREE( node->type_id );
1760 
1761  if ( !NIL_P( type_id ) ) {
1762  StringValue( type_id );
1763  node->type_id = syck_strndup( RSTRING_PTR(type_id), RSTRING_LEN(type_id) );
1764  }
1765 
1766  rb_iv_set( self, "@type_id", type_id );
1767  return type_id;
1768 }
1769 
1770 /*
1771  * YAML::Syck::Node.transform
1772  */
1773 VALUE
1775 {
1776  VALUE t;
1777  SyckNode *n = NULL;
1778  SyckNode *orig_n;
1779  Data_Get_Struct(self, SyckNode, orig_n);
1781 
1782  switch (orig_n->kind)
1783  {
1784  case syck_map_kind:
1785  {
1786  int i;
1787  DATA_PTR(t) = n = syck_alloc_map();
1788  for ( i = 0; i < orig_n->data.pairs->idx; i++ )
1789  {
1790  syck_map_add( n, rb_funcall( syck_map_read( orig_n, map_key, i ), s_transform, 0 ),
1791  rb_funcall( syck_map_read( orig_n, map_value, i ), s_transform, 0 ) );
1792  }
1793  }
1794  break;
1795 
1796  case syck_seq_kind:
1797  {
1798  int i;
1799  DATA_PTR(t) = n = syck_alloc_seq();
1800  for ( i = 0; i < orig_n->data.list->idx; i++ )
1801  {
1802  syck_seq_add( n, rb_funcall( syck_seq_read( orig_n, i ), s_transform, 0 ) );
1803  }
1804  }
1805  break;
1806 
1807  case syck_str_kind:
1808  DATA_PTR(t) = n = syck_new_str2( orig_n->data.str->ptr, orig_n->data.str->len, orig_n->data.str->style );
1809  break;
1810  }
1811 
1812  if ( orig_n->type_id != NULL )
1813  {
1814  n->type_id = syck_strndup( orig_n->type_id, strlen( orig_n->type_id ) );
1815  }
1816  if ( orig_n->anchor != NULL )
1817  {
1818  n->anchor = syck_strndup( orig_n->anchor, strlen( orig_n->anchor ) );
1819  }
1820  n->id = t;
1821  return rb_funcall( oDefaultResolver, s_node_import, 1, t );
1822 }
1823 
1824 /*
1825  * Emitter callback: assembles YAML document events from
1826  * Ruby symbols. This is a brilliant way to do it.
1827  * No one could possibly object.
1828  */
1829 void
1831 {
1832  SyckNode *n;
1833  Data_Get_Struct((VALUE)data, SyckNode, n);
1834 
1835  switch (n->kind)
1836  {
1837  case syck_map_kind:
1838  {
1839  int i;
1840  syck_emit_map( e, n->type_id, n->data.pairs->style );
1841  for ( i = 0; i < n->data.pairs->idx; i++ )
1842  {
1843  syck_emit_item( e, syck_map_read( n, map_key, i ) );
1844  syck_emit_item( e, syck_map_read( n, map_value, i ) );
1845  }
1846  syck_emit_end( e );
1847  }
1848  break;
1849 
1850  case syck_seq_kind:
1851  {
1852  int i;
1853  syck_emit_seq( e, n->type_id, n->data.list->style );
1854  for ( i = 0; i < n->data.list->idx; i++ )
1855  {
1856  syck_emit_item( e, syck_seq_read( n, i ) );
1857  }
1858  syck_emit_end( e );
1859  }
1860  break;
1861 
1862  case syck_str_kind:
1863  {
1864  syck_emit_scalar( e, n->type_id, n->data.str->style, 0, 0, 0, n->data.str->ptr, n->data.str->len );
1865  }
1866  break;
1867  }
1868 }
1869 
1870 /*
1871  * Handle output from the emitter
1872  */
1873 void
1874 rb_syck_output_handler(SyckEmitter * emitter, char *str, long len)
1875 {
1876  struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
1877  VALUE dest = bonus->port;
1878  if (TYPE(dest) == T_STRING) {
1879  rb_str_cat( dest, str, len );
1880  } else {
1881  rb_io_write( dest, rb_str_new( str, len ) );
1882  }
1883 }
1884 
1885 /*
1886  * Helper function for marking nodes in the anchor
1887  * symbol table.
1888  */
1889 void
1890 syck_out_mark(VALUE emitter, VALUE node)
1891 {
1892  SyckEmitter *emitterPtr;
1893  struct emitter_xtra *bonus;
1894  Data_Get_Struct(emitter, SyckEmitter, emitterPtr);
1895  bonus = (struct emitter_xtra *)emitterPtr->bonus;
1896  rb_ivar_set( node, s_emitter, emitter );
1897  /* syck_emitter_mark_node( emitterPtr, (st_data_t)node ); */
1898  if ( !NIL_P( bonus->oid ) ) {
1899  rb_hash_aset( bonus->data, bonus->oid, node );
1900  }
1901 }
1902 
1903 /*
1904  * Mark emitter values.
1905  */
1906 static void
1908 {
1909  struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus;
1910  rb_gc_mark( bonus->oid );
1911  rb_gc_mark( bonus->data );
1912  rb_gc_mark( bonus->port );
1913 }
1914 
1915 /*
1916  * Free the emitter and any bonus attachment.
1917  */
1918 void
1920 {
1921  S_FREE( e->bonus );
1922  syck_free_emitter(e);
1923 }
1924 
1925 /*
1926  * YAML::Syck::Emitter.allocate
1927  */
1929 VALUE
1931 {
1932  VALUE pobj;
1933  SyckEmitter *emitter = syck_new_emitter();
1934 
1935  emitter->bonus = S_ALLOC( struct emitter_xtra );
1936  S_MEMZERO( emitter->bonus, struct emitter_xtra, 1 );
1937 
1938  pobj = Data_Wrap_Struct( class, syck_mark_emitter, rb_syck_free_emitter, emitter );
1941 
1942  rb_ivar_set( pobj, s_out, rb_funcall( cOut, s_new, 1, pobj ) );
1943  return pobj;
1944 }
1945 
1946 static VALUE
1948 {
1949  VALUE hash;
1950  hash = rb_hash_new();
1951  rb_funcall(hash, rb_intern("compare_by_identity"), 0);
1952  return hash;
1953 }
1954 
1955 /*
1956  * YAML::Syck::Emitter.reset( options )
1957  */
1958 VALUE
1960 {
1961  VALUE options, tmp;
1962  SyckEmitter *emitter;
1963  struct emitter_xtra *bonus;
1964 
1965  Data_Get_Struct(self, SyckEmitter, emitter);
1966  bonus = (struct emitter_xtra *)emitter->bonus;
1967 
1968  bonus->oid = Qnil;
1969  bonus->port = rb_str_new2( "" );
1970  bonus->data = id_hash_new();
1971 
1972  if (rb_scan_args(argc, argv, "01", &options) == 0)
1973  {
1974  options = rb_hash_new();
1975  rb_ivar_set(self, s_options, options);
1976  }
1977  else if ( !NIL_P(tmp = rb_check_string_type(options)) )
1978  {
1979  bonus->port = tmp;
1980  }
1981  else if ( rb_respond_to( options, s_write ) )
1982  {
1983  bonus->port = options;
1984  }
1985  else
1986  {
1987  Check_Type(options, T_HASH);
1988  rb_ivar_set(self, s_options, options);
1989  }
1990 
1991  emitter->headless = 0;
1992  rb_ivar_set(self, s_level, INT2FIX(0));
1993  rb_ivar_set(self, s_resolver, Qnil);
1994  return self;
1995 }
1996 
1997 /*
1998  * YAML::Syck::Emitter.emit( object_id ) { |out| ... }
1999  */
2000 VALUE
2002 {
2003  VALUE oid, proc;
2004  SyckEmitter *emitter;
2005  struct emitter_xtra *bonus;
2006  SYMID symple;
2007  int level = FIX2INT(rb_ivar_get(self, s_level)) + 1;
2008  rb_ivar_set(self, s_level, INT2FIX(level));
2009 
2010  rb_scan_args(argc, argv, "1&", &oid, &proc);
2011  Data_Get_Struct(self, SyckEmitter, emitter);
2012  bonus = (struct emitter_xtra *)emitter->bonus;
2013 
2014  /* Calculate anchors, normalize nodes, build a simpler symbol table */
2015  bonus->oid = oid;
2016  if ( !NIL_P( oid ) && RTEST( rb_funcall( bonus->data, s_haskey, 1, oid ) ) ) {
2017  symple = rb_hash_aref( bonus->data, oid );
2018  } else {
2019  symple = rb_funcall( proc, s_call, 1, rb_ivar_get( self, s_out ) );
2020  }
2021  syck_emitter_mark_node( emitter, (st_data_t)symple );
2022 
2023  /* Second pass, build emitted string */
2024  level -= 1;
2025  rb_ivar_set(self, s_level, INT2FIX(level));
2026  if ( level == 0 )
2027  {
2028  syck_emit(emitter, (st_data_t)symple);
2029  syck_emitter_flush(emitter, 0);
2030 
2031  return bonus->port;
2032  }
2033 
2034  return symple;
2035 }
2036 
2037 /*
2038  * YAML::Syck::Emitter#node_export
2039  */
2040 VALUE
2042 {
2043  return rb_funcall( node, s_to_yaml, 1, self );
2044 }
2045 
2046 /*
2047  * YAML::Syck::Emitter#set_resolver
2048  */
2049 VALUE
2051 {
2052  rb_ivar_set( self, s_resolver, resolver );
2053  return self;
2054 }
2055 
2056 /*
2057  * YAML::Syck::Out::initialize
2058  */
2059 VALUE
2061 {
2062  rb_ivar_set( self, s_emitter, emitter );
2063  return self;
2064 }
2065 
2066 /*
2067  * YAML::Syck::Out::map
2068  */
2069 VALUE
2071 {
2072  VALUE type_id, style, map;
2073  if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
2074  style = Qnil;
2075  }
2076  map = rb_funcall( cMap, s_new, 3, type_id, rb_hash_new(), style );
2077  syck_out_mark( rb_ivar_get( self, s_emitter ), map );
2078  rb_yield( map );
2079  return map;
2080 }
2081 
2082 /*
2083  * YAML::Syck::Out::seq
2084  */
2085 VALUE
2087 {
2088  VALUE type_id, style, seq;
2089  if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) {
2090  style = Qnil;
2091  }
2092  seq = rb_funcall( cSeq, s_new, 3, type_id, rb_ary_new(), style );
2093  syck_out_mark( rb_ivar_get( self, s_emitter ), seq );
2094  rb_yield( seq );
2095  return seq;
2096 }
2097 
2098 /*
2099  * YAML::Syck::Out::scalar
2100 syck_out_scalar( self, type_id, str, style )
2101  VALUE self, type_id, str, style;
2102  */
2103 VALUE
2105 {
2106  VALUE type_id, str, style, scalar;
2107  rb_scan_args(argc, argv, "21", &type_id, &str, &style);
2108  scalar = rb_funcall( cScalar, s_new, 3, type_id, str, style );
2109  syck_out_mark( rb_ivar_get( self, s_emitter ), scalar );
2110  return scalar;
2111 }
2112 
2113 /*
2114  * Initialize Syck extension
2115  */
2116 void
2118 {
2119  VALUE rb_syck = rb_define_module_under( rb_cObject, "Syck" );
2120  rb_define_module_function( rb_syck, "compile", rb_syck_compile, 1 );
2121 
2122  /*
2123  * Global symbols
2124  */
2125  s_new = rb_intern("new");
2126  s_utc = rb_intern("utc");
2127  s_at = rb_intern("at");
2128  s_to_f = rb_intern("to_f");
2129  s_to_i = rb_intern("to_i");
2130  s_read = rb_intern("read");
2131  s_binmode = rb_intern("binmode");
2132  s_transfer = rb_intern("transfer");
2133  s_call = rb_intern("call");
2134  s_cmp = rb_intern("<=>");
2135  s_intern = rb_intern("intern");
2136  s_update = rb_intern("update");
2137  s_detect_implicit = rb_intern("detect_implicit");
2138  s_dup = rb_intern("dup");
2139  s_default_set = rb_intern("default=");
2140  s_match = rb_intern("match");
2141  s_push = rb_intern("push");
2142  s_haskey = rb_intern("has_key?");
2143  s_keys = rb_intern("keys");
2144  s_node_import = rb_intern("node_import");
2145  s_tr_bang = rb_intern("tr!");
2146  s_unpack = rb_intern("unpack");
2147  s_write = rb_intern("write");
2148  s_tag_read_class = rb_intern( "yaml_tag_read_class" );
2149  s_tag_subclasses = rb_intern( "yaml_tag_subclasses?" );
2150  s_emitter = rb_intern( "emitter" );
2151  s_set_resolver = rb_intern( "set_resolver" );
2152  s_node_export = rb_intern( "node_export" );
2153  s_to_yaml = rb_intern( "to_yaml" );
2154  s_transform = rb_intern( "transform" );
2155  s_yaml_new = rb_intern("yaml_new");
2156  s_yaml_initialize = rb_intern("yaml_initialize");
2157  s_each = rb_intern("each");
2158  s_parse = rb_intern("parse");
2159 
2160  s_tags = rb_intern("@tags");
2161  s_name = rb_intern("@name");
2162  s_options = rb_intern("@options");
2163  s_kind = rb_intern("@kind");
2164  s_type_id = rb_intern("@type_id");
2165  s_type_id_set = rb_intern("type_id=");
2166  s_resolver = rb_intern("@resolver");
2167  s_level = rb_intern( "@level" );
2168  s_style = rb_intern("@style");
2169  s_style_set = rb_intern("style=");
2170  s_value = rb_intern("@value");
2171  s_value_set = rb_intern("value=");
2172  s_out = rb_intern("@out");
2173  s_input = rb_intern("@input");
2174 
2175  sym_model = ID2SYM(rb_intern("Model"));
2176  sym_generic = ID2SYM(rb_intern("Generic"));
2177  sym_bytecode = ID2SYM(rb_intern("bytecode"));
2178  sym_map = ID2SYM(rb_intern("map"));
2179  sym_scalar = ID2SYM(rb_intern("scalar"));
2180  sym_seq = ID2SYM(rb_intern("seq"));
2181  sym_1quote = ID2SYM(rb_intern("quote1"));
2182  sym_2quote = ID2SYM(rb_intern("quote2"));
2183  sym_fold = ID2SYM(rb_intern("fold"));
2184  sym_literal = ID2SYM(rb_intern("literal"));
2185  sym_plain = ID2SYM(rb_intern("plain"));
2186  sym_inline = ID2SYM(rb_intern("inline"));
2187 
2188  /*
2189  * Define YAML::Syck::Resolver class
2190  */
2191  cResolver = rb_define_class_under( rb_syck, "Resolver", rb_cObject );
2192  rb_define_attr( cResolver, "tags", 1, 1 );
2195  rb_define_method( cResolver, "use_types_at", syck_resolver_use_types_at, 1 );
2196  rb_define_method( cResolver, "detect_implicit", syck_resolver_detect_implicit, 1 );
2200 
2202  oDefaultResolver = rb_funcall( cResolver, rb_intern( "new" ), 0 );
2205  rb_define_const( rb_syck, "DefaultResolver", oDefaultResolver );
2207  oGenericResolver = rb_funcall( cResolver, rb_intern( "new" ), 0 );
2209  rb_define_const( rb_syck, "GenericResolver", oGenericResolver );
2210 
2211  /*
2212  * Define YAML::Syck::Parser class
2213  */
2214  cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject );
2215  rb_define_attr( cParser, "options", 1, 1 );
2216  rb_define_attr( cParser, "resolver", 1, 1 );
2217  rb_define_attr( cParser, "input", 1, 1 );
2219  rb_define_method(cParser, "initialize", syck_parser_initialize, -1 );
2223  rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1);
2224  rb_define_method(cParser, "set_resolver", syck_parser_set_resolver, 1);
2225 
2226  /*
2227  * Define YAML::Syck::Node class
2228  */
2229  cNode = rb_define_class_under( rb_syck, "Node", rb_cObject );
2230  rb_undef( cNode, rb_intern("initialize_copy") );
2231  rb_define_attr( cNode, "emitter", 1, 1 );
2232  rb_define_attr( cNode, "resolver", 1, 1 );
2233  rb_define_attr( cNode, "kind", 1, 0 );
2234  rb_define_attr( cNode, "type_id", 1, 0 );
2235  rb_define_attr( cNode, "value", 1, 0 );
2236  rb_define_method( cNode, "type_id=", syck_node_type_id_set, 1 );
2237  rb_define_method( cNode, "transform", syck_node_transform, 0);
2238 
2239  /*
2240  * Define YAML::Syck::Scalar, YAML::Syck::Seq, YAML::Syck::Map --
2241  * all are the publicly usable variants of YAML::Syck::Node
2242  */
2243  cScalar = rb_define_class_under( rb_syck, "Scalar", cNode );
2245  rb_define_method( cScalar, "initialize", syck_scalar_initialize, 3 );
2248  cSeq = rb_define_class_under( rb_syck, "Seq", cNode );
2250  rb_define_method( cSeq, "initialize", syck_seq_initialize, 3 );
2251  rb_define_method( cSeq, "value=", syck_seq_value_set, 1 );
2252  rb_define_method( cSeq, "add", syck_seq_add_m, 1 );
2253  rb_define_method( cSeq, "style=", syck_seq_style_set, 1 );
2254  cMap = rb_define_class_under( rb_syck, "Map", cNode );
2256  rb_define_method( cMap, "initialize", syck_map_initialize, 3 );
2257  rb_define_method( cMap, "value=", syck_map_value_set, 1 );
2258  rb_define_method( cMap, "add", syck_map_add_m, 2 );
2259  rb_define_method( cMap, "style=", syck_map_style_set, 1 );
2260 
2261  /*
2262  * Define YAML::PrivateType class
2263  */
2264  cPrivateType = rb_define_class_under( rb_syck, "PrivateType", rb_cObject );
2265  rb_define_attr( cPrivateType, "type_id", 1, 1 );
2266  rb_define_attr( cPrivateType, "value", 1, 1 );
2268 
2269  /*
2270  * Define YAML::DomainType class
2271  */
2272  cDomainType = rb_define_class_under( rb_syck, "DomainType", rb_cObject );
2273  rb_define_attr( cDomainType, "domain", 1, 1 );
2274  rb_define_attr( cDomainType, "type_id", 1, 1 );
2275  rb_define_attr( cDomainType, "value", 1, 1 );
2277 
2278  /*
2279  * Define YAML::Object class
2280  */
2281  cYObject = rb_define_class_under( rb_syck, "Object", rb_cObject );
2282  rb_define_attr( cYObject, "class", 1, 1 );
2283  rb_define_attr( cYObject, "ivars", 1, 1 );
2285  rb_define_method( cYObject, "yaml_initialize", syck_yobject_initialize, 2);
2286 
2287  /*
2288  * Define YAML::Syck::BadAlias class
2289  */
2290  cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject );
2291  rb_define_attr( cBadAlias, "name", 1, 1 );
2295 
2296  /*
2297  * Define YAML::Syck::MergeKey class
2298  */
2299  cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject );
2300 
2301  /*
2302  * Define YAML::Syck::DefaultKey class
2303  */
2304  cDefaultKey = rb_define_class_under( rb_syck, "DefaultKey", rb_cObject );
2305 
2306  /*
2307  * Define YAML::Syck::Out classes
2308  */
2309  cOut = rb_define_class_under( rb_syck, "Out", rb_cObject );
2310  rb_define_attr( cOut, "emitter", 1, 1 );
2311  rb_define_method( cOut, "initialize", syck_out_initialize, 1 );
2312  rb_define_method( cOut, "map", syck_out_map, -1 );
2313  rb_define_method( cOut, "seq", syck_out_seq, -1 );
2314  rb_define_method( cOut, "scalar", syck_out_scalar, -1 );
2315 
2316  /*
2317  * Define YAML::Syck::Emitter class
2318  */
2319  cEmitter = rb_define_class_under( rb_syck, "Emitter", rb_cObject );
2320  rb_define_attr( cEmitter, "level", 1, 1 );
2322  rb_define_method( cEmitter, "initialize", syck_emitter_reset, -1 );
2323  rb_define_method( cEmitter, "reset", syck_emitter_reset, -1 );
2325  rb_define_method( cEmitter, "set_resolver", syck_emitter_set_resolver, 1);
2326  rb_define_method( cEmitter, "node_export", syck_emitter_node_export, 1);
2327 }
2328 
struct RVALUE RVALUE
static ID s_haskey
Definition: rubyext.c:52
static ID s_transfer
Definition: rubyext.c:52
#define RSTRING_LEN(string)
Definition: generator.h:45
void syck_parser_taguri_expansion(SyckParser *p, int flag)
Definition: syck.c:291
static ID s_each
Definition: rubyext.c:52
static VALUE sym_1quote
Definition: rubyext.c:56
#define ASSERT(f)
Definition: syck.h:38
VALUE rb_ary_unshift(VALUE ary, VALUE item)
Definition: array.c:939
SYMID root
Definition: syck.h:221
static ID s_keys
Definition: rubyext.c:52
void syck_map_empty(SyckNode *n)
Definition: node.c:181
static ID s_resolver
Definition: rubyext.c:52
VALUE rb_ary_pop(VALUE ary)
Definition: array.c:783
SYMID rb_syck_load_handler(SyckParser *p, SyckNode *n)
Definition: rubyext.c:639
void * bonus
Definition: syck.h:321
void rb_syck_output_handler(SyckEmitter *emitter, char *str, long len)
Definition: rubyext.c:1874
VALUE rb_ary_entry(VALUE ary, long offset)
Definition: array.c:956
VALUE syck_badalias_cmp(VALUE alias1, VALUE alias2)
Definition: rubyext.c:1351
VALUE mktime_do(VALUE varg)
Definition: rubyext.c:216
SyckNode * syck_alloc_seq(void)
Definition: node.c:67
static ID s_tag_read_class
Definition: rubyext.c:52
static VALUE cMap
Definition: rubyext.c:57
size_t strlen(const char *)
void syck_emitter_flush(SyckEmitter *e, long check_room)
Definition: emitter.c:322
int i
Definition: win32ole.c:776
VALUE syck_parser_load_documents(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:874
VALUE syck_map_add_m(VALUE self, VALUE key, VALUE val)
Definition: rubyext.c:1687
VALUE syck_genericresolver_node_import(VALUE self, VALUE node)
Definition: rubyext.c:1263
VALUE syck_resolver_add_type(VALUE self, VALUE taguri, VALUE cls)
Definition: rubyext.c:935
#define NUM2INT(x)
Definition: ruby.h:536
void syck_parser_error_handler(SyckParser *p, SyckErrorHandler hdlr)
Definition: syck.c:297
#define Data_Get_Struct(obj, type, sval)
Definition: ruby.h:835
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
Definition: class.c:1342
void syck_map_add(SyckNode *map, SYMID key, SYMID value)
Definition: node.c:197
int yaml_org_handler(SyckNode *n, VALUE *ref)
Definition: rubyext.c:369
static VALUE cDefaultKey
Definition: rubyext.c:57
struct _syck_node::@19::SyckSeq * list
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: name2ctype.h:23841
SyckNode * syck_new_str2(const char *str, long len, enum scalar_style style)
Definition: node.c:108
static double S_zero(void)
Definition: rubyext.c:63
static ID s_level
Definition: rubyext.c:52
VALUE rb_str_cat(VALUE, const char *, long)
Definition: string.c:1881
VALUE syck_resolver_node_import(VALUE self, VALUE node)
Definition: rubyext.c:965
#define st_foreach
Definition: regint.h:150
static ID s_to_i
Definition: rubyext.c:52
SYMID syck_parse(SyckParser *p)
Definition: syck.c:506
static VALUE sym_seq
Definition: rubyext.c:55
#define LONG2NUM(i)
Definition: cparse.c:72
#define Qtrue
Definition: ruby.h:366
static VALUE cResolver
Definition: rubyext.c:57
VALUE rb_cHash
Definition: hash.c:35
static VALUE cYObject
Definition: rubyext.c:57
union _syck_node::@19 data
Definition: syck.h:88
VALUE rb_ary_shift(VALUE ary)
Definition: array.c:832
#define rb_block_call(arg1, arg2, arg3, arg4, arg5, arg6)
Definition: ruby_missing.h:38
SyckEmitter * syck_new_emitter(void)
Definition: emitter.c:108
static VALUE sym_plain
Definition: rubyext.c:56
char * anchor
Definition: syck.h:117
VALUE syck_resolver_detect_implicit(VALUE self, VALUE val)
Definition: rubyext.c:956
struct RStruct rstruct
Definition: rubyext.c:33
VALUE rb_eTypeError
Definition: error.c:467
VALUE syck_scalar_alloc(VALUE class)
Definition: rubyext.c:1432
VALUE rb_ary_push(VALUE ary, VALUE item)
Definition: array.c:740
VALUE mktime_r(VALUE varg)
Definition: rubyext.c:325
static ID s_emitter
Definition: rubyext.c:52
static ID s_detect_implicit
Definition: rubyext.c:52
VALUE syck_out_seq(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:2086
char * syck_type_id_to_uri(const char *type_id)
Definition: implicit.c:1612
st_table * bad_anchors
Definition: syck.h:251
Definition: syck.h:83
static ID s_tr_bang
Definition: rubyext.c:52
static VALUE cOut
Definition: rubyext.c:57
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:638
static ID s_intern
Definition: rubyext.c:52
#define RSTRING_PTR(string)
Definition: generator.h:42
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:514
#define Check_Type(v, t)
Definition: ruby.h:459
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:1574
VALUE data
Definition: rubyext.c:84
VALUE rb_ivar_get(VALUE, ID)
Definition: variable.c:1026
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
Definition: encoding.c:727
static ID s_new
Definition: rubyext.c:52
SYMID syck_emitter_mark_node(SyckEmitter *e, st_data_t n)
Definition: emitter.c:1193
union RVALUE::@18 as
VALUE syck_resolver_use_types_at(VALUE self, VALUE hsh)
Definition: rubyext.c:946
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
Definition: object.c:525
#define T_HASH
Definition: ruby.h:421
int rb_const_defined(VALUE, ID)
Definition: variable.c:1847
static ID s_unpack
Definition: rubyext.c:52
long length
Definition: rubyext.c:42
#define RARRAY_LEN(ARRAY)
Definition: generator.h:39
#define DATA_PTR(dta)
Definition: ruby.h:795
void rb_include_module(VALUE klass, VALUE module)
Definition: class.c:662
void rb_gc_mark(VALUE ptr)
Definition: gc.c:1762
void syck_free_parser(SyckParser *p)
Definition: syck.c:249
VALUE port
Definition: rubyext.c:93
VALUE rb_io_write(VALUE, VALUE)
Definition: io.c:1224
int headless
Definition: syck.h:281
static ID s_value_set
Definition: rubyext.c:53
int rb_str_cmp(VALUE, VALUE)
Definition: string.c:2226
static VALUE syck_node_transform(VALUE)
Definition: rubyext.c:1774
long hash
Definition: rubyext.c:40
void * shortcut
Definition: syck.h:142
#define ISDIGIT(c)
static VALUE sym_generic
Definition: rubyext.c:54
char * buffer
Definition: rubyext.c:41
void rb_undef(VALUE, ID)
Definition: vm_method.c:602
int eof
Definition: syck.h:245
VALUE rb_eSyntaxError
Definition: error.c:482
rb_encoding * rb_utf8_encoding(void)
Definition: encoding.c:1125
VALUE syck_emitter_set_resolver(VALUE self, VALUE resolver)
Definition: rubyext.c:2050
VALUE syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
Definition: rubyext.c:1444
static int min(int a, int b)
void syck_parser_implicit_typing(SyckParser *p, int flag)
Definition: syck.c:285
static ID s_default_set
Definition: rubyext.c:52
#define ID2SYM(i)
Definition: cparse.c:63
VALUE data
Definition: rubyext.c:92
static VALUE syck_resolver_initialize(VALUE self)
Definition: rubyext.c:925
static ID s_out
Definition: rubyext.c:52
static ID s_yaml_initialize
Definition: rubyext.c:52
#define OBJ_TAINTED(x)
Definition: ruby.h:963
VALUE syck_privatetype_initialize(VALUE self, VALUE type_id, VALUE val)
Definition: rubyext.c:1386
static ID s_yaml_new
Definition: rubyext.c:52
char * syck_strndup(const char *buf, long len)
Definition: syck.c:34
void syck_emit_scalar(SyckEmitter *e, const char *tag, enum scalar_style force_style, int force_indent, int force_width, char keep_nl, const char *str, long len)
Definition: emitter.c:641
static VALUE oGenericResolver
Definition: rubyext.c:58
const char * syck_match_implicit(const char *str, size_t len)
Definition: implicit.c:48
static ID s_node_export
Definition: rubyext.c:52
void syck_free_emitter(SyckEmitter *e)
Definition: emitter.c:251
static VALUE cBadAlias
Definition: rubyext.c:57
VALUE syck_domaintype_initialize(VALUE self, VALUE domain, VALUE type_id, VALUE val)
Definition: rubyext.c:1363
long remaining
Definition: rubyext.c:43
#define Data_Wrap_Struct(klass, mark, free, sval)
Definition: ruby.h:817
Win32OLEIDispatch * p
Definition: win32ole.c:778
void rb_global_variable(VALUE *var)
Definition: gc.c:548
VALUE syck_resolver_transfer(VALUE self, VALUE type, VALUE val)
Definition: rubyext.c:1079
#define S_ALLOCA_N(type, n)
Definition: syck.h:52
struct RObject object
Definition: rubyext.c:25
static ID s_dup
Definition: rubyext.c:52
void syck_seq_add(SyckNode *arr, SYMID value)
Definition: node.c:320
static ID s_at
Definition: rubyext.c:52
static int syck_st_mark_nodes(char *key, SyckNode *n, char *arg)
Definition: rubyext.c:736
#define strtod(s, e)
Definition: util.h:76
#define S_FREE(n)
Definition: syck.h:50
static ID s_name
Definition: rubyext.c:53
void syck_emit_seq(SyckEmitter *e, const char *tag, enum seq_style style)
Definition: emitter.c:1000
static ID s_push
Definition: rubyext.c:52
void syck_parser_bad_anchor_handler(SyckParser *p, SyckBadAnchorHandler hdlr)
Definition: syck.c:304
VALUE syck_emitter_reset(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:1959
void rb_syck_err_handler(SyckParser *p, const char *msg)
Definition: rubyext.c:675
VALUE syck_emitter_s_alloc(VALUE class)
Definition: rubyext.c:1930
#define MEMZERO(p, type, n)
Definition: ruby.h:1052
VALUE rb_require(const char *)
Definition: load.c:652
static VALUE sym_map
Definition: rubyext.c:55
static void syck_mark_emitter(SyckEmitter *emitter)
Definition: rubyext.c:1907
Definition: syck.h:84
SyckParser * syck_new_parser(void)
Definition: syck.c:157
static ID s_style
Definition: rubyext.c:53
unsigned int input
Definition: nkf.c:3916
VALUE syck_emitter_emit(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:2001
static ID s_set_resolver
Definition: rubyext.c:52
static ID s_node_import
Definition: rubyext.c:52
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:1123
int syck_lookup_sym(SyckParser *p, SYMID id, void **datap)
Definition: syck.c:193
VALUE rb_syck_mktime(const char *str, long len)
Definition: rubyext.c:340
void syck_set_model(VALUE p, VALUE input, VALUE model)
Definition: rubyext.c:706
RUBY_EXTERN VALUE rb_cObject
Definition: ruby.h:1246
Definition: syck.h:93
void syck_emitter_handler(SyckEmitter *e, SyckEmitterHandler hdlr)
Definition: emitter.c:239
long syck_map_count(SyckNode *map)
Definition: node.c:251
VALUE resolver
Definition: rubyext.c:86
VALUE rb_ary_new(void)
Definition: array.c:339
static VALUE sym_literal
Definition: rubyext.c:56
size_t bufsize
Definition: syck.h:235
Definition: ruby.h:596
Definition: ruby.h:691
Definition: rubyext.c:16
VALUE syck_parser_s_alloc(VALUE class)
Definition: rubyext.c:780
#define NIL_P(v)
Definition: ruby.h:374
VALUE syck_resolver_tagurize(VALUE self, VALUE val)
Definition: rubyext.c:1210
static VALUE sym_fold
Definition: rubyext.c:56
static char msg[50]
Definition: strerror.c:8
VALUE syck_parser_load(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:847
static VALUE cParser
Definition: rubyext.c:57
static VALUE cMergeKey
Definition: rubyext.c:57
static VALUE cDomainType
Definition: rubyext.c:57
static VALUE cSeq
Definition: rubyext.c:57
void rb_define_const(VALUE, const char *, VALUE)
Definition: variable.c:1923
void rb_ary_store(VALUE ary, long idx, VALUE val)
Definition: array.c:635
VALUE syck_map_value_set(VALUE self, VALUE val)
Definition: rubyext.c:1655
VALUE syck_out_scalar(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:2104
long rb_syck_io_str_read(char *buf, SyckIoStr *str, long max_size, long skip)
Definition: rubyext.c:137
VALUE syck_map_alloc(VALUE class)
Definition: rubyext.c:1607
static ID s_match
Definition: rubyext.c:52
SYMID syck_seq_read(SyckNode *seq, long idx)
Definition: node.c:359
#define TYPE(x)
Definition: ruby.h:441
int argc
Definition: ruby.c:120
VALUE syck_seq_add_m(VALUE self, VALUE val)
Definition: rubyext.c:1566
static ID s_input
Definition: rubyext.c:52
#define Qfalse
Definition: ruby.h:365
SYMID syck_yaml2byte_handler(SyckParser *, SyckNode *)
Definition: yaml2byte.c:118
SYMID rb_syck_load_handler _((SyckParser *, SyckNode *))
#define MEMCPY(p1, p2, type, n)
Definition: ruby.h:1053
void syck_parser_handler(SyckParser *p, SyckNodeHandler hdlr)
Definition: syck.c:278
SyckNode * syck_alloc_map(void)
Definition: node.c:48
VALUE rb_obj_alloc(VALUE)
Definition: object.c:1600
arg
Definition: ripper.y:1283
VALUE rb_str_split(VALUE, const char *)
Definition: string.c:5983
void * bonus
Definition: syck.h:259
static ID s_to_f
Definition: rubyext.c:52
SYMID root_on_error
Definition: syck.h:221
static VALUE cEmitter
Definition: rubyext.c:57
const char * str
Definition: rubyext.c:211
#define PRIdPTRDIFF
Definition: ruby.h:155
struct RVALUE::@22::@23 free
VALUE syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
Definition: rubyext.c:1228
long len
Definition: rubyext.c:212
VALUE rb_const_get(VALUE, ID)
Definition: variable.c:1635
void syck_out_mark(VALUE emitter, VALUE node)
Definition: rubyext.c:1890
static ID s_update
Definition: rubyext.c:52
static VALUE sym_input
Definition: rubyext.c:54
static VALUE sym_scalar
Definition: rubyext.c:55
static VALUE scalar(VALUE self, VALUE value, VALUE anchor, VALUE tag, VALUE plain, VALUE quoted, VALUE style)
Definition: emitter.c:217
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
Definition: class.c:1357
void syck_parser_set_root_on_error(SyckParser *p, SYMID roer)
Definition: syck.c:148
VALUE rb_yield(VALUE)
Definition: vm_eval.c:781
VALUE syck_parser_set_resolver(VALUE self, VALUE resolver)
Definition: rubyext.c:915
#define T_DATA
Definition: ruby.h:428
void syck_free_node(SyckNode *n)
Definition: node.c:31
static ID s_kind
Definition: rubyext.c:53
VALUE rb_funcall2(VALUE, ID, int, const VALUE *)
Calls a method.
Definition: vm_eval.c:669
char * lineptr
Definition: syck.h:237
void syck_emit_end(SyckEmitter *e)
Definition: emitter.c:1152
VALUE proc
Definition: rubyext.c:85
static ID s_binmode
Definition: rubyext.c:52
void syck_seq_empty(SyckNode *n)
Definition: node.c:306
void syck_emit(SyckEmitter *e, st_data_t n)
Definition: emitter.c:356
static ID s_options
Definition: rubyext.c:53
struct RHash hash
Definition: rubyext.c:31
VALUE rb_hash_new(void)
Definition: hash.c:229
VALUE rb_iv_set(VALUE, const char *, VALUE)
Definition: variable.c:2228
VALUE syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
Definition: rubyext.c:1621
static VALUE cDate
Definition: rubyext.c:57
Definition: ruby.h:845
static double S_nan(void)
Definition: rubyext.c:66
VALUE syck_seq_style_set(VALUE self, VALUE style)
Definition: rubyext.c:1585
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:1415
VALUE rb_ivar_set(VALUE, ID, VALUE)
Definition: variable.c:1038
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:3913
unsigned long ID
Definition: ruby.h:89
void syck_parser_str(SyckParser *p, char *ptr, long len, SyckIoStrRead read)
Definition: syck.c:337
#define NULL
int printed
Definition: rubyext.c:44
#define Qnil
Definition: ruby.h:367
VALUE syck_get_hash_aref(VALUE hsh, VALUE key)
Definition: rubyext.c:196
static double S_inf(void)
Definition: rubyext.c:65
static ID s_to_yaml
Definition: rubyext.c:52
int type
Definition: tcltklib.c:107
static int options(unsigned char *cp)
Definition: nkf.c:5883
VALUE syck_set_ivars(VALUE vars, VALUE obj)
Definition: rubyext.c:1045
#define OBJ_TAINT(x)
Definition: ruby.h:964
unsigned long VALUE
Definition: ruby.h:88
VALUE syck_badalias_initialize(VALUE self, VALUE val)
Definition: rubyext.c:1341
VALUE syck_seq_value_set(VALUE self, VALUE val)
Definition: rubyext.c:1543
#define RHASH_SIZE(hsh)
Definition: generator.h:28
long syck_seq_count(SyckNode *seq)
Definition: node.c:340
#define FIX2INT(x)
Definition: ruby.h:538
VALUE syck_map_style_set(VALUE self, VALUE style)
Definition: rubyext.c:1707
static ID s_read
Definition: rubyext.c:52
void Init_syck()
Definition: rubyext.c:2117
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
Definition: eval.c:634
register unsigned int len
Definition: name2ctype.h:22210
char * cursor
Definition: syck.h:237
void syck_emit_map(SyckEmitter *e, const char *tag, enum map_style style)
Definition: emitter.c:1022
VALUE syck_out_map(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:2070
static ID s_type_id_set
Definition: rubyext.c:53
static VALUE sym_2quote
Definition: rubyext.c:56
long st_data_t
Definition: syck.h:69
long strtol(const char *nptr, char **endptr, int base)
Definition: strtol.c:7
int rb_respond_to(VALUE, ID)
Definition: vm_method.c:1231
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:606
VALUE rb_float_new(double)
Definition: numeric.c:582
void syck_output_handler(SyckEmitter *e, SyckOutputHandler hdlr)
Definition: emitter.c:245
static ID s_write
Definition: rubyext.c:52
VALUE rb_obj_is_instance_of(VALUE, VALUE)
Definition: object.c:480
int size
Definition: encoding.c:51
static ID s_utc
Definition: rubyext.c:52
#define INT2FIX(i)
Definition: ruby.h:225
VALUE syck_seq_alloc(VALUE class)
Definition: rubyext.c:1513
VALUE rb_cBignum
Definition: bignum.c:27
VALUE rb_str2inum(VALUE str, int base)
Definition: bignum.c:858
void rb_syck_free_parser(SyckParser *p)
Definition: rubyext.c:769
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
Definition: object.c:2093
void rb_define_attr(VALUE klass, const char *name, int read, int write)
Defines (a) public accessor method(s) for an attribute.
Definition: class.c:1397
static void syck_node_mark(SyckNode *n)
Definition: rubyext.c:1397
SyckNode * syck_new_map(SYMID key, SYMID value)
Definition: node.c:170
VALUE rb_check_array_type(VALUE ary)
Definition: array.c:472
struct RVALUE * next
Definition: gc.c:284
VALUE rb_hash_aref(VALUE hash, VALUE key)
Definition: hash.c:508
void syck_emit_item(SyckEmitter *e, st_data_t n)
Definition: emitter.c:1044
VALUE rb_syck_compile(VALUE self, VALUE port)
Definition: rubyext.c:100
VALUE syck_scalar_style_set(VALUE self, VALUE style)
Definition: rubyext.c:1457
static ID s_tag_subclasses
Definition: rubyext.c:52
static VALUE syck_parser_initialize(int argc, VALUE *argv, VALUE self)
Definition: rubyext.c:799
VALUE rb_check_string_type(VALUE)
Definition: string.c:1449
SyckNode * syck_alloc_str(void)
Definition: node.c:85
uint8_t key[16]
Definition: random.c:1284
struct _syck_node::@19::SyckStr * str
#define LONG2FIX(i)
Definition: ruby.h:226
void syck_parser_set_input_type(SyckParser *p, enum syck_parser_input input_type)
Definition: syck.c:311
#define RTEST(v)
Definition: ruby.h:373
VALUE syck_emitter_node_export(VALUE self, VALUE node)
Definition: rubyext.c:2041
#define T_STRING
Definition: ruby.h:418
static VALUE id_hash_new(void)
Definition: rubyext.c:1947
VALUE syck_defaultresolver_node_import(VALUE self, VALUE node)
Definition: rubyext.c:1247
v
Definition: win32ole.c:790
void syck_str_blow_away_commas(SyckNode *n)
Definition: node.c:145
enum syck_kind_tag kind
Definition: syck.h:113
VALUE rb_cArray
Definition: array.c:27
static ID s_call
Definition: rubyext.c:52
static unsigned int hash(const char *str, unsigned int len)
Definition: lex.c:56
SyckNode * rb_syck_bad_anchor_handler(SyckParser *p, char *a)
Definition: rubyext.c:694
VALUE rb_ary_join(VALUE ary, VALUE sep)
Definition: array.c:1705
#define S_ALLOC(type)
Definition: syck.h:48
VALUE rb_ary_new2(long capa)
Definition: array.c:332
static VALUE cScalar
Definition: rubyext.c:57
static ID s_cmp
Definition: rubyext.c:52
static VALUE sym_bytecode
Definition: rubyext.c:54
void rb_gc_mark_maybe(VALUE obj)
Definition: gc.c:1739
const char * name
Definition: nkf.c:208
char * ptr
Definition: syck.h:200
VALUE syck_yobject_initialize(VALUE self, VALUE klass, VALUE ivars)
Definition: rubyext.c:1375
VALUE rb_ary_reverse(VALUE ary)
Definition: array.c:1858
Definition: ruby.h:602
static ID s_style_set
Definition: rubyext.c:53
SYMID id
Definition: syck.h:111
VALUE syck_out_initialize(VALUE self, VALUE emitter)
Definition: rubyext.c:2060
static VALUE oDefaultResolver
Definition: rubyext.c:58
static ID s_value
Definition: rubyext.c:53
int taint
Definition: rubyext.c:87
VALUE syck_node_type_id_set(VALUE self, VALUE type_id)
Definition: rubyext.c:1754
Definition: ruby.h:731
int syck_parser_assign_io(SyckParser *parser, VALUE *pport)
Definition: rubyext.c:170
static ID s_type_id
Definition: rubyext.c:53
static VALUE sym_inline
Definition: rubyext.c:56
static VALUE cDateTime
Definition: rubyext.c:57
struct RArray array
Definition: rubyext.c:29
int linect
Definition: syck.h:239
static ID s_parse
Definition: rubyext.c:53
VALUE syck_scalar_value_set(VALUE self, VALUE val)
Definition: rubyext.c:1495
struct RBasic basic
Definition: rubyext.c:24
static VALUE sym_model
Definition: rubyext.c:54
static VALUE cNode
Definition: rubyext.c:57
void rb_syck_free_emitter(SyckEmitter *e)
Definition: rubyext.c:1919
#define rb_intern(str)
void rb_syck_emitter_handler(SyckEmitter *e, st_data_t data)
Definition: rubyext.c:1830
char * type_id
Definition: syck.h:115
st_table * anchors
Definition: syck.h:251
struct RClass klass
Definition: rubyext.c:26
Definition: ruby.h:630
static VALUE syck_parser_bufsize_get(VALUE self)
Definition: rubyext.c:835
VALUE flags
Definition: gc.c:283
VALUE syck_const_find(VALUE const_name)
Definition: rubyext.c:1062
RUBY_EXTERN VALUE rb_cTime
Definition: ruby.h:1280
SYMID syck_map_read(SyckNode *map, enum map_part p, long idx)
Definition: node.c:277
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Definition: class.c:1209
VALUE rb_str_append(VALUE, VALUE)
Definition: string.c:2039
VALUE rb_str_new2(const char *)
VALUE syck_merge_i(VALUE entry, VALUE hsh)
Definition: rubyext.c:354
#define SYMID
Definition: syck.h:72
static double S_one(void)
Definition: rubyext.c:64
ID rb_to_id(VALUE)
Definition: string.c:7732
VALUE rb_eArgError
Definition: error.c:468
VALUE rb_cstr2inum(const char *str, int base)
Definition: bignum.c:852
static VALUE cPrivateType
Definition: rubyext.c:57
VALUE syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
Definition: rubyext.c:1527
static ID s_tags
Definition: rubyext.c:53
struct _syck_node::@19::SyckMap * pairs
VALUE oid
Definition: rubyext.c:91
VALUE rb_attr_get(VALUE, ID)
Definition: variable.c:1032
char ** argv
Definition: ruby.c:121
static void syck_mark_parser(SyckParser *parser)
Definition: rubyext.c:746
#define StringValue(v)
Definition: ruby.h:466
static VALUE syck_parser_bufsize_set(VALUE self, VALUE size)
Definition: rubyext.c:819
#define S_MEMZERO(p, type, n)
Definition: syck.h:54
static ID s_transform
Definition: rubyext.c:52
VALUE rb_str_new(const char *, long)
Definition: string.c:410