XML-ED
view release on metacpan or search on metacpan
lib/XML/ED/Bare.xs view on Meta::CPAN
HV *package = gv_stashpv("XML::ED::NodeSet", GV_ADD);
SV *newarrayref = (SV *)sv_bless(newRV_noinc((SV*)newarray), package);
hv_store( output, "_data", 5, newarrayref, 0);
for ( i = 0; i < length; i++ ) {
SV **cur = hv_fetch( output, curnode->name, curnode->namelen, 0 );
SV *ob = cxml2obj();
av_push( newarray, ob );
if ( i != ( length - 1 ) ) curnode = curnode->next;
}
curnode = curnode->parent;
}
if ( numatts ) {
curatt = curnode->firstatt;
for ( i = 0; i < numatts; i++ ) {
HV *atth = newHV();
SV *atthref = newRV_noinc( (SV *) atth );
hv_store( output, curatt->name, curatt->namelen, atthref, 0 );
attval = newSVpvn( curatt->value, curatt->vallen );
SvUTF8_on(attval);
hv_store( atth, "value", 5, attval, vhash );
attatt = newSViv( 1 );
hv_store( atth, "_att", 4, attatt, ahash );
if( i != ( numatts - 1 ) ) curatt = curatt->next;
}
}
return outputref;
}
struct parserc *parser = 0;
MODULE = XML::ED::Bare PACKAGE = XML::ED::Bare
SV *
xml2obj()
CODE:
curnode = parser->pcurnode;
if ( curnode->err ) RETVAL = newSViv( curnode->err );
else RETVAL = cxml2obj();
OUTPUT:
RETVAL
void
c_parse(text)
char * text
CODE:
rootpos = text;
PERL_HASH(vhash, "value", 5);
PERL_HASH(Vhash, "_value", 6);
PERL_HASH(ahash, "_att", 4);
PERL_HASH(chash, "comment", 7);
PERL_HASH(phash, "_pos", 4);
PERL_HASH(ihash, "_i", 2 );
PERL_HASH(zhash, "_z", 2 );
PERL_HASH(nhash, "_n", 2 );
PERL_HASH(cdhash, "_cdata", 6 );
PERL_HASH(typehash, "_type", 5 );
parser = (struct parserc *) malloc( sizeof( struct parserc ) );
root = parserc_parse( parser, text );
SV *
get_root()
CODE:
RETVAL = newSVuv( PTR2UV( root ) );
OUTPUT:
RETVAL
void
free_tree_c( rootsv )
SV *rootsv
CODE:
struct nodec *rootnode;
rootnode = INT2PTR( struct nodec *, SvUV( rootsv ) );
del_nodec( rootnode );
( run in 1.016 second using v1.01-cache-2.11-cpan-39bf76dae61 )