helly           Sat Jan 17 10:56:30 2004 EDT

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  Make inherited sxe classes work
  
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.107 php-src/ext/simplexml/simplexml.c:1.108
--- php-src/ext/simplexml/simplexml.c:1.107     Thu Jan 15 04:28:01 2004
+++ php-src/ext/simplexml/simplexml.c   Sat Jan 17 10:56:29 2004
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.107 2004/01/15 09:28:01 helly Exp $ */
+/* $Id: simplexml.c,v 1.108 2004/01/17 15:56:29 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -62,7 +62,7 @@
 {
        php_sxe_object *subnode;
 
-       subnode = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+       subnode = php_sxe_object_new(sxe->zo.ce TSRMLS_CC);
        subnode->document = sxe->document;
        subnode->document->refcount++;
        subnode->nsmapptr = sxe->nsmapptr;
@@ -598,7 +598,7 @@
                        xmlFree(contents);
                }
        } else {
-               subnode = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+               subnode = php_sxe_object_new(sxe_ref->zo.ce TSRMLS_CC);
                subnode->document = sxe_ref->document;
                subnode->document->refcount++;
                subnode->nsmapptr = sxe_ref->nsmapptr;
@@ -1111,7 +1111,7 @@
        xmlNodePtr nodep = NULL;
        xmlDocPtr docp = NULL;
 
-       clone = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+       clone = php_sxe_object_new(sxe->zo.ce TSRMLS_CC);
        clone->document = sxe->document;
        if (clone->document) {
                clone->document->refcount++;
@@ -1224,8 +1224,11 @@
        char           *filename;
        int             filename_len;
        xmlDocPtr       docp;
+       char           *classname = "";
+       int             classname_len = 0;
+       zend_class_entry *ce= sxe_class_entry;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, 
&filename_len) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &filename, 
&filename_len, &classname, &classname_len) == FAILURE) {
                return;
        }
 
@@ -1233,8 +1236,16 @@
        if (! docp) {
                RETURN_FALSE;
        }
+       
+       if (classname_len) {
+               zend_class_entry **pce;
+               if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == 
FAILURE) {
+                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not 
exist", classname);
+               }
+               ce = *pce;
+       }
 
-       sxe = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+       sxe = php_sxe_object_new(ce TSRMLS_CC);
        php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
        sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
        sxe->nsmapptr->nsmap = xmlHashCreate(10);
@@ -1254,8 +1265,11 @@
        char           *data;
        int             data_len;
        xmlDocPtr       docp;
+       char           *classname = "";
+       int             classname_len = 0;
+       zend_class_entry *ce= sxe_class_entry;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == 
FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len, 
&classname, &classname_len) == FAILURE) {
                return;
        }
 
@@ -1264,7 +1278,15 @@
                RETURN_FALSE;
        }
 
-       sxe = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+       if (classname_len) {
+               zend_class_entry **pce;
+               if (zend_lookup_class(classname, classname_len, &pce TSRMLS_CC) == 
FAILURE) {
+                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s does not 
exist", classname);
+               }
+               ce = *pce;
+       }
+
+       sxe = php_sxe_object_new(ce TSRMLS_CC);
        php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, docp TSRMLS_CC);
        sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
        sxe->nsmapptr->nsmap = xmlHashCreate(10);
@@ -1426,8 +1448,11 @@
        zval *node;
        php_libxml_node_object *object;
        xmlNodePtr              nodep = NULL;
+       char           *classname = "";
+       int             classname_len = 0;
+       zend_class_entry *ce= sxe_class_entry;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &node) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|s", &node, &classname, 
&classname_len) == FAILURE) {
                return;
        }
 
@@ -1445,7 +1470,15 @@
        }
 
        if (nodep && nodep->type == XML_ELEMENT_NODE) {
-               sxe = php_sxe_object_new(sxe_class_entry TSRMLS_CC);
+               if (classname_len) {
+                       zend_class_entry **pce;
+                       if (zend_lookup_class(classname, classname_len, &pce 
TSRMLS_CC) == FAILURE) {
+                               php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s 
does not exist", classname);
+                       }
+                       ce = *pce;
+               }
+       
+               sxe = php_sxe_object_new(ce TSRMLS_CC);
                sxe->document = object->document;
                php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc 
TSRMLS_CC);
                sxe->nsmapptr = emalloc(sizeof(simplexml_nsmap));
@@ -1532,7 +1565,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.107 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.108 $");
        php_info_print_table_row(2, "Schema support", 
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to