rrichards               Sun Feb 15 12:07:35 2004 EDT

  Modified files:              
    /php-src/ext/dom    processinginstruction.c php_dom.c 
                        domimplementation.c dom_fe.h documenttype.c 
                        document.c 
  Log:
  allow certain methods to be called statically again:
     domdocument (all load methods)
     domimplementation (all methods)
  switch to zend_parse_method_parameters for consistancy
  insure object parameters are correct class types
  convert zvals to correct type if needed for property writes
  fix a few segfaults found while testing
  
http://cvs.php.net/diff.php/php-src/ext/dom/processinginstruction.c?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/dom/processinginstruction.c
diff -u php-src/ext/dom/processinginstruction.c:1.9 
php-src/ext/dom/processinginstruction.c:1.10
--- php-src/ext/dom/processinginstruction.c:1.9 Sun Feb 15 05:54:37 2004
+++ php-src/ext/dom/processinginstruction.c     Sun Feb 15 12:07:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: processinginstruction.c,v 1.9 2004/02/15 10:54:37 rrichards Exp $ */
+/* $Id: processinginstruction.c,v 1.10 2004/02/15 17:07:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -113,12 +113,11 @@
        
        if ((content = xmlNodeGetContent(nodep)) != NULL) {
                ZVAL_STRING(*retval, content, 1);
+               xmlFree(content);
        } else {
                ZVAL_EMPTY_STRING(*retval);
        }
 
-       xmlFree(content);
-
        return SUCCESS;
 }
 
http://cvs.php.net/diff.php/php-src/ext/dom/php_dom.c?r1=1.51&r2=1.52&ty=u
Index: php-src/ext/dom/php_dom.c
diff -u php-src/ext/dom/php_dom.c:1.51 php-src/ext/dom/php_dom.c:1.52
--- php-src/ext/dom/php_dom.c:1.51      Wed Feb  4 09:15:16 2004
+++ php-src/ext/dom/php_dom.c   Sun Feb 15 12:07:34 2004
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_dom.c,v 1.51 2004/02/04 14:15:16 iliaa Exp $ */
+/* $Id: php_dom.c,v 1.52 2004/02/15 17:07:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -758,7 +758,6 @@
 
        if (intern->ptr != NULL && ((php_libxml_node_ptr *)intern->ptr)->node != NULL) 
{
                if (((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type != 
XML_DOCUMENT_NODE && ((xmlNodePtr) ((php_libxml_node_ptr *)intern->ptr)->node)->type 
!= XML_HTML_DOCUMENT_NODE) {
-                       // php_libxml_node_free_resource(dom_object_get_node(intern) 
TSRMLS_CC);
                        php_libxml_node_decrement_resource((php_libxml_node_object *) 
intern TSRMLS_CC);
                } else {
                        php_libxml_decrement_node_ptr((php_libxml_node_object *) 
intern TSRMLS_CC);
@@ -1070,7 +1069,7 @@
        int retval = 0;
 
        if (!(strcmp (version, "1.0") && strcmp (version,"2.0") && strcmp(version, 
""))) {
-               if ((!strcasecmp(feature, "Core") && strcmp (version, "1.0")) || 
!strcasecmp(feature, "XML"))
+               if ((!strcasecmp(feature, "Core") && !strcmp (version, "1.0")) || 
!strcasecmp(feature, "XML"))
                        retval = 1;
        }
 
http://cvs.php.net/diff.php/php-src/ext/dom/domimplementation.c?r1=1.11&r2=1.12&ty=u
Index: php-src/ext/dom/domimplementation.c
diff -u php-src/ext/dom/domimplementation.c:1.11 
php-src/ext/dom/domimplementation.c:1.12
--- php-src/ext/dom/domimplementation.c:1.11    Thu Jan  8 03:15:16 2004
+++ php-src/ext/dom/domimplementation.c Sun Feb 15 12:07:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: domimplementation.c,v 1.11 2004/01/08 08:15:16 andi Exp $ */
+/* $Id: domimplementation.c,v 1.12 2004/02/15 17:07:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -35,10 +35,10 @@
 */
 
 zend_function_entry php_dom_domimplementation_class_functions[] = {
-       PHP_FALIAS(hasFeature, dom_domimplementation_has_feature, NULL)
-       PHP_FALIAS(createDocumentType, dom_domimplementation_create_document_type, 
NULL)
-       PHP_FALIAS(createDocument, dom_domimplementation_create_document, NULL)
-       PHP_FALIAS(getFeature, dom_domimplementation_get_feature, NULL)
+       PHP_ME(domimplementation, getFeature, NULL, 
ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
+       PHP_ME(domimplementation, hasFeature, NULL, 
ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
+       PHP_ME(domimplementation, createDocumentType, NULL, 
ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
+       PHP_ME(domimplementation, createDocument, NULL, 
ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
        {NULL, NULL, NULL}
 };
 
@@ -49,7 +49,7 @@
 URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-5CED94D7
 Since: 
 */
-PHP_FUNCTION(dom_domimplementation_has_feature)
+PHP_METHOD(domimplementation, hasFeature)
 {
        int feature_len, version_len;
        char *feature, *version;
@@ -71,11 +71,11 @@
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocType
 Since: DOM Level 2
 */
-PHP_FUNCTION(dom_domimplementation_create_document_type)
+PHP_METHOD(domimplementation, createDocumentType)
 {
        zval *rv = NULL;
        xmlDtd *doctype;
-       int ret, name_len, publicid_len, systemid_len;
+       int ret, name_len = 0, publicid_len = 0, systemid_len = 0;
        char *name, *publicid, *systemid;
        xmlChar *pch1 = NULL, *pch2 = NULL, *localname = NULL;
        xmlURIPtr uri;
@@ -125,7 +125,7 @@
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Level-2-Core-DOM-createDocument
 Since: DOM Level 2
 */
-PHP_FUNCTION(dom_domimplementation_create_document)
+PHP_METHOD(domimplementation, createDocument)
 {
        zval *node = NULL, *rv = NULL;
        xmlDoc *docp;
@@ -137,7 +137,7 @@
        char *prefix = NULL, *localname = NULL;
        dom_object *doctobj;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sso", &uri, &uri_len, 
&name, &name_len, &node) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssO", &uri, &uri_len, 
&name, &name_len, &node, dom_documenttype_class_entry) == FAILURE) {
                return;
        }
 
@@ -228,7 +228,7 @@
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#DOMImplementation3-getFeature
 Since: DOM Level 3
 */
-PHP_FUNCTION(dom_domimplementation_get_feature)
+PHP_METHOD(domimplementation, getFeature)
 {
  DOM_NOT_IMPLEMENTED();
 }
http://cvs.php.net/diff.php/php-src/ext/dom/dom_fe.h?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/dom/dom_fe.h
diff -u php-src/ext/dom/dom_fe.h:1.8 php-src/ext/dom/dom_fe.h:1.9
--- php-src/ext/dom/dom_fe.h:1.8        Thu Jan  8 12:32:03 2004
+++ php-src/ext/dom/dom_fe.h    Sun Feb 15 12:07:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: dom_fe.h,v 1.8 2004/01/08 17:32:03 sniper Exp $ */
+/* $Id: dom_fe.h,v 1.9 2004/02/15 17:07:34 rrichards Exp $ */
 #ifndef DOM_FE_H
 #define DOM_FE_H
 
@@ -93,10 +93,10 @@
 PHP_FUNCTION(dom_domimplementationsource_get_domimplementations);
 
 /* domimplementation methods */
-PHP_FUNCTION(dom_domimplementation_has_feature);
-PHP_FUNCTION(dom_domimplementation_create_document_type);
-PHP_FUNCTION(dom_domimplementation_create_document);
-PHP_FUNCTION(dom_domimplementation_get_feature);
+PHP_METHOD(domimplementation, hasFeature);
+PHP_METHOD(domimplementation, createDocumentType);
+PHP_METHOD(domimplementation, createDocument);
+PHP_METHOD(domimplementation, getFeature);
 
 /* domdocumentfragment methods */
 PHP_FUNCTION(dom_documentfragment_documentfragment);
@@ -121,16 +121,16 @@
 PHP_FUNCTION(dom_document_rename_node);
 PHP_FUNCTION(dom_document_document);
        /* convienience methods */
-PHP_FUNCTION(dom_document_load);
+PHP_METHOD(domdocument, load);
 PHP_FUNCTION(dom_document_save);
-PHP_FUNCTION(dom_document_loadxml);
+PHP_METHOD(domdocument, loadXML);
 PHP_FUNCTION(dom_document_savexml);
 PHP_FUNCTION(dom_document_validate);
 PHP_FUNCTION(dom_document_xinclude);
 
 #if defined(LIBXML_HTML_ENABLED)
-PHP_FUNCTION(dom_document_load_html);
-PHP_FUNCTION(dom_document_load_html_file);
+PHP_METHOD(domdocument, loadHTML);
+PHP_METHOD(domdocument, loadHTMLFile);
 PHP_FUNCTION(dom_document_save_html);
 PHP_FUNCTION(dom_document_save_html_file);
 #endif  /* defined(LIBXML_HTML_ENABLED) */
http://cvs.php.net/diff.php/php-src/ext/dom/documenttype.c?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/dom/documenttype.c
diff -u php-src/ext/dom/documenttype.c:1.9 php-src/ext/dom/documenttype.c:1.10
--- php-src/ext/dom/documenttype.c:1.9  Thu Jan  8 03:15:16 2004
+++ php-src/ext/dom/documenttype.c      Sun Feb 15 12:07:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: documenttype.c,v 1.9 2004/01/08 08:15:16 andi Exp $ */
+/* $Id: documenttype.c,v 1.10 2004/02/15 17:07:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -154,7 +154,7 @@
 
        ALLOC_ZVAL(*retval);
        if (dtdptr->SystemID) {
-               ZVAL_STRING(*retval, (char *) (dtdptr->ExternalID), 1);
+               ZVAL_STRING(*retval, (char *) (dtdptr->SystemID), 1);
        } else {
                ZVAL_EMPTY_STRING(*retval);
        }
http://cvs.php.net/diff.php/php-src/ext/dom/document.c?r1=1.47&r2=1.48&ty=u
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.47 php-src/ext/dom/document.c:1.48
--- php-src/ext/dom/document.c:1.47     Thu Jan 22 16:16:05 2004
+++ php-src/ext/dom/document.c  Sun Feb 15 12:07:34 2004
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c,v 1.47 2004/01/22 21:16:05 rrichards Exp $ */
+/* $Id: document.c,v 1.48 2004/02/15 17:07:34 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -66,16 +66,16 @@
        PHP_FALIAS(adoptNode, dom_document_adopt_node, NULL)
        PHP_FALIAS(normalizeDocument, dom_document_normalize_document, NULL)
        PHP_FALIAS(renameNode, dom_document_rename_node, NULL)
-       PHP_FALIAS(load, dom_document_load, NULL)
+       PHP_ME(domdocument, load, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
        PHP_FALIAS(save, dom_document_save, NULL)
-       PHP_FALIAS(loadXML, dom_document_loadxml, NULL)
+       PHP_ME(domdocument, loadXML, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
        PHP_FALIAS(saveXML, dom_document_savexml, NULL)
        PHP_FALIAS(domdocument, dom_document_document, NULL)
        PHP_FALIAS(validate, dom_document_validate, NULL)
        PHP_FALIAS(xinclude, dom_document_xinclude, NULL)
 #if defined(LIBXML_HTML_ENABLED)
-       PHP_FALIAS(loadHTML, dom_document_load_html, NULL)
-       PHP_FALIAS(loadHTMLFile, dom_document_load_html_file, NULL)
+       PHP_ME(domdocument, loadHTML, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
+       PHP_ME(domdocument, loadHTMLFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_ALLOW_STATIC)
        PHP_FALIAS(saveHTML, dom_document_save_html, NULL)
        PHP_FALIAS(saveHTMLFile, dom_document_save_html_file, NULL)
 #endif  /* defined(LIBXML_HTML_ENABLED) */
@@ -209,11 +209,21 @@
 
 int dom_document_encoding_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        xmlDoc *docp;
        xmlCharEncodingHandlerPtr handler;
 
        docp = (xmlDocPtr) dom_object_get_node(obj);
 
+       if (newval->type != IS_STRING) {
+               if(newval->refcount > 1) {
+                       value_copy = *newval;
+                       zval_copy_ctor(&value_copy);
+                       newval = &value_copy;
+               }
+               convert_to_string(newval);
+       }
+
        handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
 
     if (handler != NULL) {
@@ -222,11 +232,14 @@
                        xmlFree((xmlChar *)docp->encoding);
                }
                docp->encoding = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval));
-               return SUCCESS;
     } else {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Document 
Encoding");
     }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
@@ -254,10 +267,19 @@
 
 int dom_document_standalone_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        xmlDoc *docp;
        int standalone;
 
        docp = (xmlDocPtr) dom_object_get_node(obj);
+
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_long(newval);
+
        standalone = Z_LVAL_P(newval);
     if (standalone > 0) {
         docp->standalone = 1;
@@ -269,6 +291,10 @@
         docp->standalone = 0;
     }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
@@ -301,6 +327,7 @@
 
 int dom_document_version_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        xmlDoc *docp;
 
        docp = (xmlDocPtr) dom_object_get_node(obj);
@@ -308,8 +335,21 @@
                xmlFree((xmlChar *) docp->version );
        }
 
+       if (newval->type != IS_STRING) {
+               if(newval->refcount > 1) {
+                       value_copy = *newval;
+                       zval_copy_ctor(&value_copy);
+                       newval = &value_copy;
+               }
+               convert_to_string(newval);
+       }
+
        docp->version = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval));
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
@@ -336,13 +376,25 @@
 
 int dom_document_strict_error_checking_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->stricterror = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
@@ -367,13 +419,25 @@
 
 int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->formatoutput = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 /* }}} */
@@ -397,13 +461,25 @@
 
 int dom_document_validate_on_parse_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->validateonparse = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 /* }}} */
@@ -428,13 +504,25 @@
 
 int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->resolveexternals = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 /* }}} */
@@ -459,13 +547,25 @@
 
 int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->preservewhitespace = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 /* }}} */
@@ -490,13 +590,25 @@
 
 int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        dom_doc_props *doc_prop;
 
-       if (obj->document && newval->type == IS_BOOL) {
+       if(newval->refcount > 1) {
+               value_copy = *newval;
+               zval_copy_ctor(&value_copy);
+               newval = &value_copy;
+       }
+       convert_to_boolean(newval);
+
+       if (obj->document) {
                doc_prop = dom_get_doc_props(obj->document);
                doc_prop->substituteentities = Z_LVAL_P(newval);
        }
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 /* }}} */
@@ -527,6 +639,7 @@
 
 int dom_document_document_uri_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        xmlDoc *docp;
 
        docp = (xmlDocPtr) dom_object_get_node(obj);
@@ -534,8 +647,21 @@
                xmlFree((xmlChar *) docp->URL);
        }
 
+       if (newval->type != IS_STRING) {
+               if(newval->refcount > 1) {
+                       value_copy = *newval;
+                       zval_copy_ctor(&value_copy);
+                       newval = &value_copy;
+               }
+               convert_to_string(newval);
+       }
+
        docp->URL = xmlStrdup((const xmlChar *) Z_STRVAL_P(newval));
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
@@ -572,12 +698,17 @@
        int ret, name_len, value_len;
        char *name, *value = NULL;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &name, &name_len, 
&value, &value_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s", 
&id, dom_document_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
+       if (name_len == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Element name is 
required");
+               RETURN_FALSE;
+       }
+
        node = xmlNewDocNode(docp, NULL, name, value);
        if (!node) {
                RETURN_FALSE;
@@ -600,7 +731,11 @@
        dom_object *intern;
        int ret;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
&id, dom_document_class_entry) == FAILURE) {
+               return;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        node =  xmlNewDocFragment(docp);
        if (!node) {
@@ -625,12 +760,12 @@
        dom_object *intern;
        char *value;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) 
== FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &value, &value_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        node = xmlNewDocText(docp, (xmlChar *) value);
        if (!node) {
                RETURN_FALSE;
@@ -654,12 +789,12 @@
        dom_object *intern;
        char *value;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) 
== FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &value, &value_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        node = xmlNewDocComment(docp, (xmlChar *) value);
        if (!node) {
                RETURN_FALSE;
@@ -683,12 +818,12 @@
        dom_object *intern;
        char *value;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) 
== FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &value, &value_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        node = xmlNewCDataBlock(docp, (xmlChar *) value, value_len);
        if (!node) {
                RETURN_FALSE;
@@ -708,16 +843,16 @@
        zval *id, *rv = NULL;
        xmlNode *node;
        xmlDocPtr docp;
-       int ret, value_len, name_len;
+       int ret, value_len, name_len = 0;
        dom_object *intern;
        char *name, *value = NULL;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &name, &name_len, 
&value, &value_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s", 
&id, dom_document_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        node = xmlNewPI((xmlChar *) name, (xmlChar *) value);
        if (!node) {
                RETURN_FALSE;
@@ -743,12 +878,12 @@
        dom_object *intern;
        char *name;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == 
FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &name, &name_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        if (name_len == 0) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute name is 
required");
                RETURN_FALSE;
@@ -778,12 +913,12 @@
        int ret, name_len;
        char *name;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == 
FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &name, &name_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        node = xmlNewReference(docp, name);
        if (!node) {
                RETURN_FALSE;
@@ -807,12 +942,12 @@
        char *name;
        xmlChar *local;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == 
FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &name, &name_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC);
        namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC);
        local = xmlCharStrndup(name, name_len);
@@ -835,12 +970,12 @@
        int ret; 
        long recursive = 0;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o|l", &node, &recursive) 
== FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO|l", 
&id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        DOM_GET_OBJ(nodep, node, xmlNodePtr, nodeobj);
 
        if (nodep->type == XML_HTML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_NODE 
@@ -879,12 +1014,19 @@
        int errorcode;
        dom_object *intern;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!s", &uri, &uri_len, 
&name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s", 
&id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) {
                return;
        }
 
+       if (name_len == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Element Name is 
required");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
+       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+
        errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len);
 
        if (errorcode == 0) {
@@ -939,12 +1081,17 @@
        dom_object *intern;
        int errorcode;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!s", &uri, &uri_len, 
&name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s", 
&id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) {
                return;
        }
 
+       if (name_len == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Qualified Name is 
required");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        root = xmlDocGetRootElement(docp);
        if (root != NULL) {
                errorcode = dom_check_qname(name, &localname, &prefix, uri_len, 
name_len);
@@ -998,12 +1145,12 @@
        char *uri, *name;
        xmlChar *local, *nsuri;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &uri, &uri_len, 
&name, &name_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss", 
&id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC);
        namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC);
        local = xmlCharStrndup(name, name_len);
@@ -1026,11 +1173,12 @@
        dom_object *intern;
        char *idname;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &idname, 
&idname_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &idname, &idname_len) == FAILURE) {
                return;
        }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        attrp = xmlGetID(docp, (xmlChar *) idname);
 
        if (attrp && attrp->parent) {
@@ -1064,9 +1212,11 @@
        xmlDocPtr docp;
        dom_object *intern;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
&id, dom_document_class_entry) == FAILURE) {
+               return;
+       }
 
-       DOM_NO_ARGS();
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        dom_normalize((xmlNodePtr) docp TSRMLS_CC);
 }
@@ -1092,7 +1242,7 @@
        dom_object *intern;
        char *encoding, *version = NULL;
        int encoding_len = 0, version_len = 0, refcount;
-       
+
        if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss", 
&id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == 
FAILURE) {
                return;
        }
@@ -1328,7 +1478,7 @@
 URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load
 Since: DOM Level 3
 */
-PHP_FUNCTION(dom_document_load)
+PHP_METHOD(domdocument, load)
 {
        dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE);
 }
@@ -1338,7 +1488,7 @@
 URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML
 Since: DOM Level 3
 */
-PHP_FUNCTION(dom_document_loadxml)
+PHP_METHOD(domdocument, loadXML)
 {
        dom_parse_document(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING);
 }
@@ -1351,17 +1501,22 @@
 {
        zval *id;
        xmlDoc *docp;
-       int file_len, bytes, format;
+       int file_len = 0, bytes, format;
        dom_object *intern;
        dom_doc_props *doc_props;
        char *file;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-       
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == 
FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &file, &file_len) == FAILURE) {
                return;
        }
 
+       if (file_len == 0) {
+               php_error(E_WARNING, "Invalid Filename");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        /* encoding handled by property on doc */
 
        doc_props = dom_get_doc_props(intern->document);
@@ -1390,12 +1545,12 @@
        dom_doc_props *doc_props;
        int size, format;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|o", &nodep) == FAILURE) 
{
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O", 
&id, dom_document_class_entry, &nodep, dom_node_class_entry) == FAILURE) {
                return;
        }
 
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        doc_props = dom_get_doc_props(intern->document);
        format = doc_props->formatoutput;
 
@@ -1475,7 +1630,11 @@
        int err; 
        dom_object *intern;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
&id, dom_document_class_entry) == FAILURE) {
+               return;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        err = xmlXIncludeProcess (docp);
 
@@ -1509,8 +1668,12 @@
        xmlDoc *docp;
        dom_object *intern;
        xmlValidCtxt *cvp;
-       
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
&id, dom_document_class_entry) == FAILURE) {
+               return;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
        
        if (docp->intSubset == NULL) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No DTD given in 
XML-Document");
@@ -1548,11 +1711,16 @@
        int                     is_valid;
        char resolved_path[MAXPATHLEN + 1];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, 
&source_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &source, &source_len) == FAILURE) {
                return;
        }
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (source_len == 0) {
+               php_error(E_WARNING, "Invalid Schema source");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        switch (type) {
        case DOM_LOAD_FILE:
@@ -1633,11 +1801,16 @@
        int                     is_valid;
        char resolved_path[MAXPATHLEN + 1];
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, 
&source_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &source, &source_len) == FAILURE) {
                return;
        }
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (source_len == 0) {
+               php_error(E_WARNING, "Invalid Schema source");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        switch (type) {
        case DOM_LOAD_FILE:
@@ -1782,7 +1955,7 @@
 /* {{{ proto boolean domnode dom_document_load_html_file(string source);
 Since: DOM extended
 */
-PHP_FUNCTION(dom_document_load_html_file)
+PHP_METHOD(domdocument, loadHTMLFile)
 {
        dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE);
 }
@@ -1791,7 +1964,7 @@
 /* {{{ proto boolean domnode dom_document_load_html(string source);
 Since: DOM extended
 */
-PHP_FUNCTION(dom_document_load_html)
+PHP_METHOD(domdocument, loadHTML)
 {
        dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING);
 }
@@ -1809,12 +1982,17 @@
        dom_doc_props *doc_props;
        char *file;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
-       
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == 
FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", 
&id, dom_document_class_entry, &file, &file_len) == FAILURE) {
                return;
        }
 
+       if (file_len == 0) {
+               php_error(E_WARNING, "Invalid Filename");
+               RETURN_FALSE;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
+
        /* encoding handled by property on doc */
 
        doc_props = dom_get_doc_props(intern->document);
@@ -1839,7 +2017,11 @@
        xmlChar *mem;
        int size;
 
-       DOM_GET_THIS_OBJ(docp, id, xmlDocPtr, intern);
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", 
&id, dom_document_class_entry) == FAILURE) {
+               return;
+       }
+
+       DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
 
        htmlDocDumpMemory(docp, &mem, &size);
        if (!size) {

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

Reply via email to