46
* this is a wrapper function that does the type evaluation for the
46
* this is a wrapper function that does the type evaluation for the
47
47
* node. this makes the code a little more readable in the .XS
49
* the code is not really portable, but i think we'll avoid some
49
* the code is not really portable, but i think we'll avoid some
50
50
* memory leak problems that way.
404
404
case XML_DTD_NODE:
405
405
if ( node->doc != NULL ) {
406
if ( node->doc->extSubset != (xmlDtdPtr)node
406
if ( node->doc->extSubset != (xmlDtdPtr)node
407
407
&& node->doc->intSubset != (xmlDtdPtr)node ) {
408
408
xs_warn( "PmmFreeNode: XML_DTD_NODE\n");
409
409
node->doc = NULL;
429
429
the subtree if it is not required any more.
432
PmmREFCNT_dec( ProxyNodePtr node )
432
PmmREFCNT_dec( ProxyNodePtr node )
434
434
xmlNodePtr libnode = NULL;
435
ProxyNodePtr owner = NULL;
435
ProxyNodePtr owner = NULL;
438
438
if ( node != NULL ) {
503
PmmNodeToSv( xmlNodePtr node, ProxyNodePtr owner )
503
PmmNodeToSv( xmlNodePtr node, ProxyNodePtr owner )
505
505
ProxyNodePtr dfProxy= NULL;
506
506
SV * retval = &PL_sv_undef;
516
516
xs_warn("PmmNodeToSv: return new perl node of class:\n");
517
517
xs_warn( CLASS );
519
if ( node->_private != NULL ) {
519
if ( node->_private != NULL ) {
520
520
dfProxy = PmmNewNode(node);
521
521
/* fprintf(stderr, " at 0x%08.8X\n", dfProxy); */
617
PmmSvNodeExt( SV* perlnode, int copy )
617
PmmSvNodeExt( SV* perlnode, int copy )
619
619
xmlNodePtr retval = NULL;
620
620
ProxyNodePtr proxy = NULL;
643
643
else if ( sv_derived_from( perlnode, "XML::GDOME::Node" ) ) {
644
644
GdomeNode* gnode = (GdomeNode*)SvIV((SV*)SvRV( perlnode ));
645
645
if ( gnode == NULL ) {
646
warn( "no XML::GDOME data found (datastructure empty)" );
646
warn( "no XML::GDOME data found (datastructure empty)" );
649
649
retval = gdome_xml_n_get_xmlNode( gnode );
678
678
/* reverse to PmmSvOwner(). sets the owner of the current node. this
679
679
* will increase the proxy count of the owner.
682
682
PmmSetSvOwner( SV* perlnode, SV* extra )
684
if ( perlnode != NULL && perlnode != &PL_sv_undef ) {
684
if ( perlnode != NULL && perlnode != &PL_sv_undef ) {
685
685
PmmOWNER( SvPROXYNODE(perlnode)) = PmmNODE( SvPROXYNODE(extra) );
686
686
PmmREFCNT_inc( SvPROXYNODE(extra) );
687
687
/* fprintf(stderr, "REFCNT incremented on new owner: 0x%08.8X\n", SvPROXYNODE(extra)); */
695
695
* this functions fixes the reference counts for an entire subtree.
696
696
* it is very important to fix an entire subtree after node operations
697
697
* where the documents or the owner node may get changed. this method is
698
* aware about nodes that already belong to a certain owner node.
698
* aware about nodes that already belong to a certain owner node.
700
700
* the method uses the internal methods PmmFixNode and PmmChildNodes to
701
701
* do the real updates.
703
703
* in the worst case this traverses the subtree twice during a node
704
704
* operation. this case is only given when the node has to be
705
* adopted by the document. Since the ownerdocument and the effective
705
* adopted by the document. Since the ownerdocument and the effective
706
706
* owner may differ this double traversing makes sense.
709
PmmFixOwner( ProxyNodePtr nodetofix, ProxyNodePtr parent )
709
PmmFixOwner( ProxyNodePtr nodetofix, ProxyNodePtr parent )
711
711
ProxyNodePtr oldParent = NULL;
726
726
if ( PmmOWNER(nodetofix) != NULL ) {
727
727
oldParent = PmmOWNERPO(nodetofix);
730
730
/* The owner data is only fixed if the node is neither a
731
731
* fragment nor a document. Also no update will happen if
732
732
* the node is already his owner or the owner has not
744
744
PmmOWNER(nodetofix) = NULL;
747
747
if ( oldParent != NULL && oldParent != nodetofix )
748
748
PmmREFCNT_dec(oldParent);
750
750
if ( PmmNODE(nodetofix)->type != XML_ATTRIBUTE_NODE
751
751
&& PmmNODE(nodetofix)->properties != NULL ) {
752
752
PmmFixOwnerList( (xmlNodePtr)PmmNODE(nodetofix)->properties,
877
877
retval = NEWSV(0,0);
878
878
sv_setref_pv( retval, CLASS, (void*)dfProxy );
879
PmmREFCNT_inc(dfProxy);
879
PmmREFCNT_inc(dfProxy);
880
880
/* fprintf(stderr, "REFCNT incremented on new context: 0x%08.8X\n", dfProxy); */
883
883
xs_warn( "PmmContextSv: no node found!\n" );
1052
1052
* encodeString returns an UTF-8 encoded String
1053
1053
* while the encodig has the name of the encoding of string
1056
1056
PmmEncodeString( const char *encoding, const xmlChar *string, STRLEN len ){
1057
1057
xmlCharEncoding enc;
1058
1058
xmlChar *ret = NULL;
1060
1060
if ( string != NULL ) {
1061
1061
if( encoding != NULL ) {
1062
1062
xs_warn("PmmEncodeString: encoding to UTF-8 from:\n");
1093
1093
retval = newSVpvn( (const char *)string, (STRLEN) xmlStrlen(string) );
1095
1095
if ( enc == XML_CHAR_ENCODING_UTF8 ) {
1096
/* create an UTF8 string. */
1096
/* create an UTF8 string. */
1097
1097
#ifdef HAVE_UTF8
1098
1098
xs_warn("C2Sv: set UTF8-SV-flag\n");
1099
1099
SvUTF8_on(retval);
1121
1121
xs_warn( "SV2C: use UTF8\n" );
1122
1122
if( !DO_UTF8(scalar) && encoding != NULL ) {
1124
if ( encoding != NULL ) {
1124
if ( encoding != NULL ) {
1126
1126
xs_warn( "SV2C: domEncodeString!\n" );
1127
1127
ts= PmmEncodeString( (const char *)encoding, string, len );
1165
1165
decoded = PmmFastDecodeString( PmmNodeEncoding(real_doc),
1166
1166
(const xmlChar *)string,
1167
(const xmlChar *)real_doc->encoding,
1167
(const xmlChar *)real_doc->encoding,
1170
1170
xs_warn( "push decoded string into SV" );
1247
1247
xs_warn("nodeSv2C: no encoding !!\n");
1249
return Sv2C( scalar, NULL );
1249
return Sv2C( scalar, NULL );
1253
PmmNodeToGdomeSv( xmlNodePtr node )
1253
PmmNodeToGdomeSv( xmlNodePtr node )
1255
1255
SV * retval = &PL_sv_undef;
1270
1270
CLASS = "XML::GDOME::Attr";
1272
1272
case GDOME_TEXT_NODE:
1273
CLASS = "XML::GDOME::Text";
1273
CLASS = "XML::GDOME::Text";
1275
1275
case GDOME_CDATA_SECTION_NODE:
1276
CLASS = "XML::GDOME::CDATASection";
1276
CLASS = "XML::GDOME::CDATASection";
1278
1278
case GDOME_ENTITY_REFERENCE_NODE:
1279
CLASS = "XML::GDOME::EntityReference";
1279
CLASS = "XML::GDOME::EntityReference";
1281
1281
case GDOME_ENTITY_NODE:
1282
CLASS = "XML::GDOME::Entity";
1282
CLASS = "XML::GDOME::Entity";
1284
1284
case GDOME_PROCESSING_INSTRUCTION_NODE:
1285
CLASS = "XML::GDOME::ProcessingInstruction";
1285
CLASS = "XML::GDOME::ProcessingInstruction";
1287
1287
case GDOME_COMMENT_NODE:
1288
CLASS = "XML::GDOME::Comment";
1288
CLASS = "XML::GDOME::Comment";
1290
1290
case GDOME_DOCUMENT_TYPE_NODE:
1291
CLASS = "XML::GDOME::DocumentType";
1291
CLASS = "XML::GDOME::DocumentType";
1293
1293
case GDOME_DOCUMENT_FRAGMENT_NODE:
1294
CLASS = "XML::GDOME::DocumentFragment";
1294
CLASS = "XML::GDOME::DocumentFragment";
1296
1296
case GDOME_NOTATION_NODE:
1297
CLASS = "XML::GDOME::Notation";
1297
CLASS = "XML::GDOME::Notation";
1299
1299
case GDOME_DOCUMENT_NODE:
1300
CLASS = "XML::GDOME::Document";
1300
CLASS = "XML::GDOME::Document";