diff options
Diffstat (limited to 'ext/syck/rubyext.c')
-rw-r--r-- | ext/syck/rubyext.c | 229 |
1 files changed, 68 insertions, 161 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index 4c66e30f2..ec2fe8b5e 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -97,8 +97,7 @@ struct emitter_xtra { * Convert YAML to bytecode */ VALUE -rb_syck_compile(self, port) - VALUE self, port; +rb_syck_compile(VALUE self, VALUE port) { SYMID oid; int taint; @@ -164,9 +163,7 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) * (returns tainted? boolean) */ int -syck_parser_assign_io(parser, pport) - SyckParser *parser; - VALUE *pport; +syck_parser_assign_io(SyckParser *parser, VALUE *pport) { int taint = Qtrue; VALUE tmp, port = *pport; @@ -192,8 +189,7 @@ syck_parser_assign_io(parser, pport) * Get value in hash by key, forcing an empty hash if nil. */ VALUE -syck_get_hash_aref(hsh, key) - VALUE hsh, key; +syck_get_hash_aref(VALUE hsh, VALUE key) { VALUE val = rb_hash_aref( hsh, key ); if ( NIL_P( val ) ) @@ -208,9 +204,7 @@ syck_get_hash_aref(hsh, key) * creating timestamps */ SYMID -rb_syck_mktime(str, len) - char *str; - long len; +rb_syck_mktime(char *str, long len) { VALUE time; char *ptr = str; @@ -315,8 +309,7 @@ rb_syck_mktime(str, len) * (see http://www.yaml.org/type/merge/) */ VALUE -syck_merge_i( entry, hsh ) - VALUE entry, hsh; +syck_merge_i(VALUE entry, VALUE hsh ) { VALUE tmp; if ( !NIL_P(tmp = rb_check_convert_type(entry, T_HASH, "Hash", "to_hash")) ) @@ -331,9 +324,7 @@ syck_merge_i( entry, hsh ) * default handler for ruby.yaml.org types */ int -yaml_org_handler( n, ref ) - SyckNode *n; - VALUE *ref; +yaml_org_handler( SyckNode *n, VALUE *ref ) { char *type_id = n->type_id; int transferred = 0; @@ -602,9 +593,7 @@ static void syck_node_mark( SyckNode *n ); * - Converts data into native Ruby types */ SYMID -rb_syck_load_handler(p, n) - SyckParser *p; - SyckNode *n; +rb_syck_load_handler(SyckParser *p, SyckNode *n) { VALUE obj = Qnil; struct parser_xtra *bonus = (struct parser_xtra *)p->bonus; @@ -640,9 +629,7 @@ rb_syck_load_handler(p, n) * friendly errors. */ void -rb_syck_err_handler(p, msg) - SyckParser *p; - char *msg; +rb_syck_err_handler(SyckParser *p, char *msg) { char *endl = p->cursor; @@ -661,9 +648,7 @@ rb_syck_err_handler(p, msg) * provide bad anchor object to the parser. */ SyckNode * -rb_syck_bad_anchor_handler(p, a) - SyckParser *p; - char *a; +rb_syck_bad_anchor_handler(SyckParser *p, char *a) { VALUE anchor_name = rb_str_new2( a ); SyckNode *badanc = syck_new_map( rb_str_new2( "name" ), anchor_name ); @@ -675,8 +660,7 @@ rb_syck_bad_anchor_handler(p, a) * data loaded based on the model requested. */ void -syck_set_model( p, input, model ) - VALUE p, input, model; +syck_set_model(VALUE p, VALUE input, VALUE model) { SyckParser *parser; Data_Get_Struct(p, SyckParser, parser); @@ -716,8 +700,7 @@ syck_st_mark_nodes( char *key, SyckNode *n, char *arg ) * mark parser nodes */ static void -syck_mark_parser(parser) - SyckParser *parser; +syck_mark_parser(SyckParser *parser) { struct parser_xtra *bonus = (struct parser_xtra *)parser->bonus; rb_gc_mark_maybe(parser->root); @@ -740,8 +723,7 @@ syck_mark_parser(parser) * Free the parser and any bonus attachment. */ void -rb_syck_free_parser(p) - SyckParser *p; +rb_syck_free_parser(SyckParser *p) { S_FREE( p->bonus ); syck_free_parser(p); @@ -752,8 +734,7 @@ rb_syck_free_parser(p) */ VALUE syck_parser_s_alloc _((VALUE)); VALUE -syck_parser_s_alloc(class) - VALUE class; +syck_parser_s_alloc(VALUE class) { VALUE pobj; SyckParser *parser = syck_new_parser(); @@ -772,10 +753,7 @@ syck_parser_s_alloc(class) * YAML::Syck::Parser.initialize( resolver, options ) */ static VALUE -syck_parser_initialize(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; +syck_parser_initialize(int argc, VALUE *argv, VALUE self) { VALUE options; if (rb_scan_args(argc, argv, "01", &options) == 0) @@ -795,8 +773,7 @@ syck_parser_initialize(argc, argv, self) * YAML::Syck::Parser.bufsize = Integer */ static VALUE -syck_parser_bufsize_set( self, size ) - VALUE self, size; +syck_parser_bufsize_set(VALUE self, VALUE size) { SyckParser *parser; @@ -812,8 +789,7 @@ syck_parser_bufsize_set( self, size ) * YAML::Syck::Parser.bufsize => Integer */ static VALUE -syck_parser_bufsize_get( self ) - VALUE self; +syck_parser_bufsize_get(VALUE self) { SyckParser *parser; @@ -825,10 +801,7 @@ syck_parser_bufsize_get( self ) * YAML::Syck::Parser.load( IO or String ) */ VALUE -syck_parser_load(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; +syck_parser_load(int argc, VALUE *argv, VALUE self) { VALUE port, proc, model, input; SyckParser *parser; @@ -855,10 +828,7 @@ syck_parser_load(argc, argv, self) * YAML::Syck::Parser.load_documents( IO or String ) { |doc| } */ VALUE -syck_parser_load_documents(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; +syck_parser_load_documents(int argc, VALUE *argv, VALUE self) { VALUE port, proc, v, input, model; SyckParser *parser; @@ -899,8 +869,7 @@ syck_parser_load_documents(argc, argv, self) * YAML::Syck::Parser#set_resolver */ VALUE -syck_parser_set_resolver( self, resolver ) - VALUE self, resolver; +syck_parser_set_resolver(VALUE self, VALUE resolver) { rb_ivar_set( self, s_resolver, resolver ); return self; @@ -910,8 +879,7 @@ syck_parser_set_resolver( self, resolver ) * YAML::Syck::Resolver.initialize */ static VALUE -syck_resolver_initialize( self ) - VALUE self; +syck_resolver_initialize(VALUE self) { VALUE tags = rb_hash_new(); rb_ivar_set(self, s_tags, rb_hash_new()); @@ -922,8 +890,7 @@ syck_resolver_initialize( self ) * YAML::Syck::Resolver#add_type */ VALUE -syck_resolver_add_type( self, taguri, cls ) - VALUE self, taguri, cls; +syck_resolver_add_type(VALUE self, VALUE taguri, VALUE cls) { VALUE tags = rb_attr_get(self, s_tags); rb_hash_aset( tags, taguri, cls ); @@ -934,8 +901,7 @@ syck_resolver_add_type( self, taguri, cls ) * YAML::Syck::Resolver#use_types_at */ VALUE -syck_resolver_use_types_at( self, hsh ) - VALUE self, hsh; +syck_resolver_use_types_at(VALUE self, VALUE hsh) { rb_ivar_set( self, s_tags, hsh ); return Qnil; @@ -945,8 +911,7 @@ syck_resolver_use_types_at( self, hsh ) * YAML::Syck::Resolver#detect_implicit */ VALUE -syck_resolver_detect_implicit( self, val ) - VALUE self, val; +syck_resolver_detect_implicit(VALUE self, VALUE val) { char *type_id; return rb_str_new2( "" ); @@ -956,8 +921,7 @@ syck_resolver_detect_implicit( self, val ) * YAML::Syck::Resolver#node_import */ VALUE -syck_resolver_node_import( self, node ) - VALUE self, node; +syck_resolver_node_import(VALUE self, VALUE node) { SyckNode *n; VALUE obj; @@ -1037,8 +1001,7 @@ syck_resolver_node_import( self, node ) * Set instance variables */ VALUE -syck_set_ivars( vars, obj ) - VALUE vars, obj; +syck_set_ivars(VALUE vars, VALUE obj) { VALUE ivname = rb_ary_entry( vars, 0 ); char *ivn; @@ -1055,8 +1018,7 @@ syck_set_ivars( vars, obj ) * YAML::Syck::Resolver#const_find */ VALUE -syck_const_find( const_name ) - VALUE const_name; +syck_const_find(VALUE const_name) { VALUE tclass = rb_cObject; VALUE tparts = rb_str_split( const_name, "::" ); @@ -1073,8 +1035,7 @@ syck_const_find( const_name ) * YAML::Syck::Resolver#transfer */ VALUE -syck_resolver_transfer( self, type, val ) - VALUE self, type, val; +syck_resolver_transfer(VALUE self, VALUE type, VALUE val) { if (NIL_P(type) || RSTRING(StringValue(type))->len == 0) { @@ -1205,8 +1166,7 @@ syck_resolver_transfer( self, type, val ) * YAML::Syck::Resolver#tagurize */ VALUE -syck_resolver_tagurize( self, val ) - VALUE self, val; +syck_resolver_tagurize(VALUE self, VALUE val) { VALUE tmp = rb_check_string_type(val); @@ -1224,8 +1184,7 @@ syck_resolver_tagurize( self, val ) * YAML::Syck::DefaultResolver#detect_implicit */ VALUE -syck_defaultresolver_detect_implicit( self, val ) - VALUE self, val; +syck_defaultresolver_detect_implicit(VALUE self, VALUE val) { char *type_id; VALUE tmp = rb_check_string_type(val); @@ -1244,8 +1203,7 @@ syck_defaultresolver_detect_implicit( self, val ) * YAML::Syck::DefaultResolver#node_import */ VALUE -syck_defaultresolver_node_import( self, node ) - VALUE self, node; +syck_defaultresolver_node_import(VALUE self, VALUE node) { SyckNode *n; VALUE obj; @@ -1261,8 +1219,7 @@ syck_defaultresolver_node_import( self, node ) * YAML::Syck::GenericResolver#node_import */ VALUE -syck_genericresolver_node_import( self, node ) - VALUE self, node; +syck_genericresolver_node_import(VALUE self, VALUE node) { SyckNode *n; int i = 0; @@ -1339,8 +1296,7 @@ syck_genericresolver_node_import( self, node ) * YAML::Syck::BadAlias.initialize */ VALUE -syck_badalias_initialize( self, val ) - VALUE self, val; +syck_badalias_initialize(VALUE self, VALUE val) { rb_iv_set( self, "@name", val ); return self; @@ -1350,8 +1306,7 @@ syck_badalias_initialize( self, val ) * YAML::Syck::BadAlias.<=> */ VALUE -syck_badalias_cmp( alias1, alias2 ) - VALUE alias1, alias2; +syck_badalias_cmp(VALUE alias1, VALUE alias2) { VALUE str1 = rb_ivar_get( alias1, s_name ); VALUE str2 = rb_ivar_get( alias2, s_name ); @@ -1363,8 +1318,7 @@ syck_badalias_cmp( alias1, alias2 ) * YAML::DomainType.initialize */ VALUE -syck_domaintype_initialize( self, domain, type_id, val ) - VALUE self, domain, type_id, val; +syck_domaintype_initialize(VALUE self, VALUE domain, VALUE type_id, VALUE val) { rb_iv_set( self, "@domain", domain ); rb_iv_set( self, "@type_id", type_id ); @@ -1376,8 +1330,7 @@ syck_domaintype_initialize( self, domain, type_id, val ) * YAML::Object.initialize */ VALUE -syck_yobject_initialize( self, klass, ivars ) - VALUE self, klass, ivars; +syck_yobject_initialize(VALUE self, VALUE klass, VALUE ivars) { rb_iv_set( self, "@class", klass ); rb_iv_set( self, "@ivars", ivars ); @@ -1388,8 +1341,7 @@ syck_yobject_initialize( self, klass, ivars ) * YAML::PrivateType.initialize */ VALUE -syck_privatetype_initialize( self, type_id, val ) - VALUE self, type_id, val; +syck_privatetype_initialize(VALUE self, VALUE type_id, VALUE val) { rb_iv_set( self, "@type_id", type_id ); rb_iv_set( self, "@value", val ); @@ -1400,8 +1352,7 @@ syck_privatetype_initialize( self, type_id, val ) * Mark node contents. */ static void -syck_node_mark( n ) - SyckNode *n; +syck_node_mark(SyckNode *n) { int i; rb_gc_mark_maybe( n->id ); @@ -1431,8 +1382,7 @@ syck_node_mark( n ) * YAML::Syck::Scalar.allocate */ VALUE -syck_scalar_alloc( class ) - VALUE class; +syck_scalar_alloc(VALUE class) { SyckNode *node = syck_alloc_str(); VALUE obj = Data_Wrap_Struct( class, syck_node_mark, syck_free_node, node ); @@ -1444,8 +1394,7 @@ syck_scalar_alloc( class ) * YAML::Syck::Scalar.initialize */ VALUE -syck_scalar_initialize( self, type_id, val, style ) - VALUE self, type_id, val, style; +syck_scalar_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style) { rb_iv_set( self, "@kind", sym_scalar ); rb_funcall( self, s_type_id_set, 1, type_id ); @@ -1458,8 +1407,7 @@ syck_scalar_initialize( self, type_id, val, style ) * YAML::Syck::Scalar.style= */ VALUE -syck_scalar_style_set( self, style ) - VALUE self, style; +syck_scalar_style_set(VALUE self, VALUE style) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1497,8 +1445,7 @@ syck_scalar_style_set( self, style ) * YAML::Syck::Scalar.value= */ VALUE -syck_scalar_value_set( self, val ) - VALUE self, val; +syck_scalar_value_set(VALUE self, VALUE val) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1516,8 +1463,7 @@ syck_scalar_value_set( self, val ) * YAML::Syck::Seq.allocate */ VALUE -syck_seq_alloc( class ) - VALUE class; +syck_seq_alloc(VALUE class) { SyckNode *node; VALUE obj; @@ -1531,8 +1477,7 @@ syck_seq_alloc( class ) * YAML::Syck::Seq.initialize */ VALUE -syck_seq_initialize( self, type_id, val, style ) - VALUE self, type_id, val, style; +syck_seq_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1548,8 +1493,7 @@ syck_seq_initialize( self, type_id, val, style ) * YAML::Syck::Seq.value= */ VALUE -syck_seq_value_set( self, val ) - VALUE self, val; +syck_seq_value_set(VALUE self, VALUE val) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1572,8 +1516,7 @@ syck_seq_value_set( self, val ) * YAML::Syck::Seq.add */ VALUE -syck_seq_add_m( self, val ) - VALUE self, val; +syck_seq_add_m(VALUE self, VALUE val) { SyckNode *node; VALUE emitter = rb_ivar_get( self, s_emitter ); @@ -1592,8 +1535,7 @@ syck_seq_add_m( self, val ) * YAML::Syck::Seq.style= */ VALUE -syck_seq_style_set( self, style ) - VALUE self, style; +syck_seq_style_set(VALUE self, VALUE style) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1615,8 +1557,7 @@ syck_seq_style_set( self, style ) * YAML::Syck::Map.allocate */ VALUE -syck_map_alloc( class ) - VALUE class; +syck_map_alloc(VALUE class) { SyckNode *node; VALUE obj; @@ -1630,8 +1571,7 @@ syck_map_alloc( class ) * YAML::Syck::Map.initialize */ VALUE -syck_map_initialize( self, type_id, val, style ) - VALUE self, type_id, val, style; +syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1665,8 +1605,7 @@ syck_map_initialize( self, type_id, val, style ) * YAML::Syck::Map.value= */ VALUE -syck_map_value_set( self, val ) - VALUE self, val; +syck_map_value_set(VALUE self, VALUE val) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1698,8 +1637,7 @@ syck_map_value_set( self, val ) * YAML::Syck::Map.add */ VALUE -syck_map_add_m( self, key, val ) - VALUE self, key, val; +syck_map_add_m(VALUE self, VALUE key, VALUE val) { SyckNode *node; VALUE emitter = rb_ivar_get( self, s_emitter ); @@ -1719,8 +1657,7 @@ syck_map_add_m( self, key, val ) * YAML::Syck::Map.style= */ VALUE -syck_map_style_set( self, style ) - VALUE self, style; +syck_map_style_set(VALUE self, VALUE style) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1742,8 +1679,7 @@ syck_map_style_set( self, style ) * Cloning method for all node types */ VALUE -syck_node_init_copy( copy, orig ) - VALUE copy, orig; +syck_node_init_copy(VALUE copy, VALUE orig) { SyckNode *copy_n; SyckNode *orig_n; @@ -1766,8 +1702,7 @@ syck_node_init_copy( copy, orig ) * YAML::Syck::Node#type_id= */ VALUE -syck_node_type_id_set( self, type_id ) - VALUE self, type_id; +syck_node_type_id_set(VALUE self, VALUE type_id) { SyckNode *node; Data_Get_Struct( self, SyckNode, node ); @@ -1787,8 +1722,7 @@ syck_node_type_id_set( self, type_id ) * YAML::Syck::Node.transform */ VALUE -syck_node_transform( self ) - VALUE self; +syck_node_transform(VALUE self) { VALUE t; SyckNode *n; @@ -1844,9 +1778,7 @@ syck_node_transform( self ) * No one could possibly object. */ void -rb_syck_emitter_handler(e, data) - SyckEmitter *e; - st_data_t data; +rb_syck_emitter_handler(SyckEmitter *e, st_data_t data) { SyckNode *n; Data_Get_Struct((VALUE)data, SyckNode, n); @@ -1890,10 +1822,7 @@ rb_syck_emitter_handler(e, data) * Handle output from the emitter */ void -rb_syck_output_handler( emitter, str, len ) - SyckEmitter *emitter; - char *str; - long len; +rb_syck_output_handler(SyckEmitter * emitter, char *str, long len) { struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus; VALUE dest = bonus->port; @@ -1909,8 +1838,7 @@ rb_syck_output_handler( emitter, str, len ) * symbol table. */ void -syck_out_mark( emitter, node ) - VALUE emitter, node; +syck_out_mark(VALUE emitter, VALUE node) { SyckEmitter *emitterPtr; struct emitter_xtra *bonus; @@ -1927,8 +1855,7 @@ syck_out_mark( emitter, node ) * Mark emitter values. */ static void -syck_mark_emitter(emitter) - SyckEmitter *emitter; +syck_mark_emitter(SyckEmitter *emitter) { struct emitter_xtra *bonus = (struct emitter_xtra *)emitter->bonus; rb_gc_mark( bonus->oid ); @@ -1940,8 +1867,7 @@ syck_mark_emitter(emitter) * Free the emitter and any bonus attachment. */ void -rb_syck_free_emitter(e) - SyckEmitter *e; +rb_syck_free_emitter(SyckEmitter *e) { S_FREE( e->bonus ); syck_free_emitter(e); @@ -1952,8 +1878,7 @@ rb_syck_free_emitter(e) */ VALUE syck_emitter_s_alloc _((VALUE)); VALUE -syck_emitter_s_alloc(class) - VALUE class; +syck_emitter_s_alloc(VALUE class) { VALUE pobj; SyckEmitter *emitter = syck_new_emitter(); @@ -1973,10 +1898,7 @@ syck_emitter_s_alloc(class) * YAML::Syck::Emitter.reset( options ) */ VALUE -syck_emitter_reset( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; +syck_emitter_reset(int argc, VALUE *argv, VALUE self) { VALUE options, tmp; SyckEmitter *emitter; @@ -2018,10 +1940,7 @@ syck_emitter_reset( argc, argv, self ) * YAML::Syck::Emitter.emit( object_id ) { |out| ... } */ VALUE -syck_emitter_emit( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; +syck_emitter_emit(int argc, VALUE *argv, VALUE self) { VALUE oid, proc; char *anchor_name; @@ -2062,8 +1981,7 @@ syck_emitter_emit( argc, argv, self ) * YAML::Syck::Emitter#node_export */ VALUE -syck_emitter_node_export( self, node ) - VALUE self, node; +syck_emitter_node_export(VALUE self, VALUE node) { return rb_funcall( node, s_to_yaml, 1, self ); } @@ -2072,8 +1990,7 @@ syck_emitter_node_export( self, node ) * YAML::Syck::Emitter#set_resolver */ VALUE -syck_emitter_set_resolver( self, resolver ) - VALUE self, resolver; +syck_emitter_set_resolver(VALUE self, VALUE resolver) { rb_ivar_set( self, s_resolver, resolver ); return self; @@ -2083,8 +2000,7 @@ syck_emitter_set_resolver( self, resolver ) * YAML::Syck::Out::initialize */ VALUE -syck_out_initialize( self, emitter ) - VALUE self, emitter; +syck_out_initialize(VALUE self, VALUE emitter) { rb_ivar_set( self, s_emitter, emitter ); return self; @@ -2094,10 +2010,7 @@ syck_out_initialize( self, emitter ) * YAML::Syck::Out::map */ VALUE -syck_out_map( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; +syck_out_map(int argc, VALUE *argv, VALUE self) { VALUE type_id, style, map; if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) { @@ -2113,10 +2026,7 @@ syck_out_map( argc, argv, self ) * YAML::Syck::Out::seq */ VALUE -syck_out_seq( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; +syck_out_seq(int argc, VALUE *argv, VALUE self) { VALUE type_id, style, seq; if (rb_scan_args(argc, argv, "11", &type_id, &style) == 1) { @@ -2134,10 +2044,7 @@ syck_out_scalar( self, type_id, str, style ) VALUE self, type_id, str, style; */ VALUE -syck_out_scalar( argc, argv, self ) - int argc; - VALUE *argv; - VALUE self; +syck_out_scalar(int argc, VALUE *argv, VALUE self) { VALUE type_id, str, style, scalar; if (rb_scan_args(argc, argv, "21", &type_id, &str, &style) == 2) { |