Class | YAML::Syck::Node
In: | syck/rubyext.c
Parent: | Object

### Methods

initialize_copy transform type_id=

### Public Instance methods

initialize_copy(p1)

Cloning method for all node types

[Source]

    /*
     * Cloning method for all node types
     */
    VALUE
    syck_node_init_copy( copy, orig )
        VALUE copy, orig;
    {
        SyckNode *copy_n;
        SyckNode *orig_n;

        if ( copy == orig )
            return copy;

        if ( TYPE( orig ) != T_DATA ||
             RDATA( orig )->dfree != ( RUBY_DATA_FUNC )rb_syck_free_node )
        {
            rb_raise( rb_eTypeError, "wrong argument type" );
        }

        Data_Get_Struct( orig, SyckNode, orig_n );
        Data_Get_Struct( copy, SyckNode, copy_n );
        MEMCPY( copy_n, orig_n, SyckNode, 1 );
        return copy;
    }

transform()

YAML::Syck::Node.transform

[Source]

    /*
     * YAML::Syck::Node.transform
     */
    VALUE
    syck_node_transform( self )
        VALUE self;
    {
        VALUE t;
        SyckNode *n;
        SyckNode *orig_n;
        Data_Get_Struct(self, SyckNode, orig_n);

        switch (orig_n->kind)
        {
            case syck_map_kind:
                {
                    int i;
                    n = syck_alloc_map();
                    for ( i = 0; i < orig_n->data.pairs->idx; i++ )
                    {
                        syck_map_add( n, rb_funcall( syck_map_read( orig_n, map_key, i ), s_transform, 0 ),
                                         rb_funcall( syck_map_read( orig_n, map_value, i ), s_transform, 0 ) );
                    }
                }
            break;

            case syck_seq_kind:
                {
                    int i;
                    n = syck_alloc_seq();
                    for ( i = 0; i < orig_n->data.list->idx; i++ )
                    {
                        syck_seq_add( n, rb_funcall( syck_seq_read( orig_n, i ), s_transform, 0 ) );
                    }
                }
            break;

            case syck_str_kind:
                n = syck_new_str2( orig_n->data.str->ptr, orig_n->data.str->len, orig_n->data.str->style );
            break;
        }

        if ( orig_n->type_id != NULL )
        {
            n->type_id = syck_strndup( orig_n->type_id, strlen( orig_n->type_id ) );
        }
        if ( orig_n->anchor != NULL )
        {
            n->anchor = syck_strndup( orig_n->anchor, strlen( orig_n->anchor ) );
        }
        t = Data_Wrap_Struct( cNode, NULL, NULL, n );
        n->id = t;
        t = rb_funcall( oDefaultResolver, s_node_import, 1, t );
        syck_free_node( n );
        return t;
    }

type_id=(p1)

YAML::Syck::Node#type_id=

[Source]

    /*
     * YAML::Syck::Node#type_id=
     */
    VALUE
    syck_node_type_id_set( self, type_id )
        VALUE self, type_id;
    {
        SyckNode *node;
        Data_Get_Struct( self, SyckNode, node );

        if ( node->type_id != NULL ) S_FREE( node->type_id );

        if ( NIL_P( type_id ) ) {
            node->type_id = NULL;
        } else {
            node->type_id = StringValuePtr( type_id );
        }

        rb_iv_set( self, "@type_id", type_id );
        return type_id;
    }

[Validate]