Module: Object::Syck

Defined in:
rubyext.c

Defined Under Namespace

Classes: BadAlias, DefaultKey, DomainType, Emitter, Map, MergeKey, Node, Object, Out, Parser, PrivateType, Resolver, Scalar, Seq

Constant Summary collapse

DefaultResolver =
oDefaultResolver
GenericResolver =
oGenericResolver

Class Method Summary collapse

Class Method Details

.compileObject

Convert YAML to bytecode


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'rubyext.c', line 99

VALUE
rb_syck_compile(VALUE self, VALUE port)
{
    SYMID oid;
    int taint;
    char *ret;
    VALUE bc;
    bytestring_t *sav = NULL;
    void *data = NULL;

    SyckParser *parser = syck_new_parser();
    taint = syck_parser_assign_io(parser, &port);
    syck_parser_handler( parser, syck_yaml2byte_handler );
    syck_parser_error_handler( parser, NULL );
    syck_parser_implicit_typing( parser, 0 );
    syck_parser_taguri_expansion( parser, 0 );
    oid = syck_parse( parser );
    if (!syck_lookup_sym( parser, oid, &data )) {
  rb_raise(rb_eSyntaxError, "root node <%p> not found", (void *)oid);
    }
    sav = data;

    ret = S_ALLOCA_N( char, strlen( sav->buffer ) + 3 );
    ret[0] = '\0';
    strcat( ret, "D\n" );
    strcat( ret, sav->buffer );

    syck_free_parser( parser );

    bc = rb_str_new2( ret );
    if ( taint )      OBJ_TAINT( bc );
    return bc;
}