Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • syck/rubyext.c

Object::Syck

Public Class Methods

compile(p1) click to toggle source

Convert YAML to bytecode

 
               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 <%lx> not found", 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;
}
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus