|
Lines 2-10
Link Here
|
| 2 |
/* |
2 |
/* |
| 3 |
* rubyext.c |
3 |
* rubyext.c |
| 4 |
* |
4 |
* |
| 5 |
* $Author: ocean $ |
5 |
* $Author: ocean $ |
| 6 |
* $Date: 2005/12/20 04:13:26 $ |
6 |
* $Date: 2006/02/03 10:28:27 $ |
| 7 |
* |
7 |
* |
| 8 |
* Copyright (C) 2003-2005 why the lucky stiff |
8 |
* Copyright (C) 2003-2005 why the lucky stiff |
| 9 |
*/ |
9 |
*/ |
| 10 |
|
10 |
|
|
Lines 48-57
Link Here
|
| 48 |
|
48 |
|
| 49 |
/* |
49 |
/* |
| 50 |
* symbols and constants |
50 |
* symbols and constants |
| 51 |
*/ |
51 |
*/ |
| 52 |
static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver; |
52 |
static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver, s_each; |
| 53 |
static ID s_tags, s_domain, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set; |
53 |
static ID s_tags, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set; |
| 54 |
static VALUE sym_model, sym_generic, sym_input, sym_bytecode; |
54 |
static VALUE sym_model, sym_generic, sym_input, sym_bytecode; |
| 55 |
static VALUE sym_scalar, sym_seq, sym_map; |
55 |
static VALUE sym_scalar, sym_seq, sym_map; |
| 56 |
static VALUE sym_1quote, sym_2quote, sym_fold, sym_literal, sym_plain, sym_inline; |
56 |
static VALUE sym_1quote, sym_2quote, sym_fold, sym_literal, sym_plain, sym_inline; |
| 57 |
static VALUE cDate, cNode, cMap, cSeq, cScalar, cOut, cParser, cResolver, cPrivateType, cDomainType, cYObject, cBadAlias, cDefaultKey, cMergeKey, cEmitter; |
57 |
static VALUE cDate, cNode, cMap, cSeq, cScalar, cOut, cParser, cResolver, cPrivateType, cDomainType, cYObject, cBadAlias, cDefaultKey, cMergeKey, cEmitter; |
|
Lines 114-129
Link Here
|
| 114 |
syck_parser_taguri_expansion( parser, 0 ); |
114 |
syck_parser_taguri_expansion( parser, 0 ); |
| 115 |
oid = syck_parse( parser ); |
115 |
oid = syck_parse( parser ); |
| 116 |
syck_lookup_sym( parser, oid, (char **)&sav ); |
116 |
syck_lookup_sym( parser, oid, (char **)&sav ); |
| 117 |
|
117 |
|
| 118 |
ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 ); |
118 |
ret = S_ALLOCA_N( char, strlen( sav->buffer ) + 3 ); |
| 119 |
ret[0] = '\0'; |
119 |
ret[0] = '\0'; |
| 120 |
strcat( ret, "D\n" ); |
120 |
strcat( ret, "D\n" ); |
| 121 |
strcat( ret, sav->buffer ); |
121 |
strcat( ret, sav->buffer ); |
| 122 |
|
122 |
|
| 123 |
syck_free_parser( parser ); |
123 |
syck_free_parser( parser ); |
| 124 |
|
124 |
|
| 125 |
bc = rb_str_new2( ret ); S_FREE( ret ); |
125 |
bc = rb_str_new2( ret ); |
| 126 |
if ( taint ) OBJ_TAINT( bc ); |
126 |
if ( taint ) OBJ_TAINT( bc ); |
| 127 |
return bc; |
127 |
return bc; |
| 128 |
} |
128 |
} |
| 129 |
|
129 |
|
|
Lines 1042-1055
Link Here
|
| 1042 |
{ |
1042 |
{ |
| 1043 |
VALUE ivname = rb_ary_entry( vars, 0 ); |
1043 |
VALUE ivname = rb_ary_entry( vars, 0 ); |
| 1044 |
char *ivn; |
1044 |
char *ivn; |
| 1045 |
StringValue( ivname ); |
1045 |
StringValue( ivname ); |
| 1046 |
ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 ); |
1046 |
ivn = S_ALLOCA_N( char, RSTRING(ivname)->len + 2 ); |
| 1047 |
ivn[0] = '@'; |
1047 |
ivn[0] = '@'; |
| 1048 |
ivn[1] = '\0'; |
1048 |
ivn[1] = '\0'; |
| 1049 |
strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len ); |
1049 |
strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len ); |
| 1050 |
rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) ); |
1050 |
rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) ); |
| 1051 |
S_FREE( ivn ); |
|
|
| 1052 |
return Qnil; |
1051 |
return Qnil; |
| 1053 |
} |
1052 |
} |
| 1054 |
|
1053 |
|
| 1055 |
/* |
1054 |
/* |
|
Lines 1134-1141
Link Here
|
| 1134 |
target_class = cYObject; |
1133 |
target_class = cYObject; |
| 1135 |
type = subclass; |
1134 |
type = subclass; |
| 1136 |
subclass = cYObject; |
1135 |
subclass = cYObject; |
| 1137 |
} |
1136 |
} |
|
|
1137 |
else /* workaround for SEGV. real fix please */ |
| 1138 |
{ |
| 1139 |
rb_raise( rb_eTypeError, "invalid subclass" ); |
| 1140 |
} |
| 1138 |
} |
1141 |
} |
| 1139 |
break; |
1142 |
break; |
| 1140 |
} |
1143 |
} |
| 1141 |
} |
1144 |
} |
|
Lines 1156-1163
Link Here
|
| 1156 |
obj = rb_funcall( target_class, s_yaml_new, 3, subclass, type, val ); |
1159 |
obj = rb_funcall( target_class, s_yaml_new, 3, subclass, type, val ); |
| 1157 |
} |
1160 |
} |
| 1158 |
else if ( !NIL_P( target_class ) ) |
1161 |
else if ( !NIL_P( target_class ) ) |
| 1159 |
{ |
1162 |
{ |
|
|
1163 |
if ( subclass == rb_cBignum ) |
| 1164 |
{ |
| 1165 |
obj = rb_str2inum( val, 10 ); /* for yaml dumped by 1.8.3 [ruby-core:6159] */ |
| 1166 |
} |
| 1167 |
else |
| 1168 |
{ |
| 1160 |
obj = rb_obj_alloc( subclass ); |
1169 |
obj = rb_obj_alloc( subclass ); |
|
|
1170 |
} |
| 1171 |
|
| 1161 |
if ( rb_respond_to( obj, s_yaml_initialize ) ) |
1172 |
if ( rb_respond_to( obj, s_yaml_initialize ) ) |
| 1162 |
{ |
1173 |
{ |
| 1163 |
rb_funcall( obj, s_yaml_initialize, 2, type, val ); |
1174 |
rb_funcall( obj, s_yaml_initialize, 2, type, val ); |
| 1164 |
} |
1175 |
} |