]> granicus.if.org Git - php/commitdiff
start of dom update
authorRob Richards <rrichards@php.net>
Sun, 15 Feb 2004 10:54:37 +0000 (10:54 +0000)
committerRob Richards <rrichards@php.net>
Sun, 15 Feb 2004 10:54:37 +0000 (10:54 +0000)
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

ext/dom/processinginstruction.c
ext/dom/text.c
ext/dom/xpath.c

index 3a57457122a55440a2ce7ed901475efafe084851..044bdf00985668577ae9fb996c21a4e0709d9257 100644 (file)
@@ -124,11 +124,26 @@ int dom_processinginstruction_data_read(dom_object *obj, zval **retval TSRMLS_DC
 
 int dom_processinginstruction_data_write(dom_object *obj, zval *newval TSRMLS_DC)
 {
+       zval value_copy;
        xmlNode *nodep;
 
        nodep = 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);
+       }
+
        xmlNodeSetContentLen(nodep, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1);
 
+       if (newval == &value_copy) {
+               zval_dtor(newval);
+       }
+
        return SUCCESS;
 }
 
index d315adaff86c70c35f0ec1565725114e3e3a8fdb..05fca65ded7afa094e088a59535a94380d142de7 100644 (file)
@@ -103,6 +103,7 @@ Since:
 */
 PHP_FUNCTION(dom_text_split_text)
 {
+       zval       *id;
        xmlChar    *cur;
        xmlChar    *first;
        xmlChar    *second;
@@ -113,11 +114,10 @@ PHP_FUNCTION(dom_text_split_text)
        int         length;
        dom_object      *intern;
 
-       DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern);
-
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &offset) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &id, dom_text_class_entry, &offset) == FAILURE) {
                return;
        }
+       DOM_GET_OBJ(node, id, xmlNodePtr, intern);
 
        if (node->type != XML_TEXT_NODE) {
                RETURN_FALSE;
@@ -162,12 +162,14 @@ Since: DOM Level 3
 */
 PHP_FUNCTION(dom_text_is_whitespace_in_element_content)
 {
+       zval       *id;
        xmlNodePtr  node;
        dom_object      *intern;
 
-       DOM_GET_THIS_OBJ(node, getThis(), xmlNodePtr, intern);
-
-       DOM_NO_ARGS();
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_text_class_entry) == FAILURE) {
+               return;
+       }
+       DOM_GET_OBJ(node, id, xmlNodePtr, intern);
 
        if (xmlIsBlankNode(node)) {
                RETURN_TRUE;
index 4b693bb4653535eaca7ca8730ed4b94cbdb4e42b..abaf35b9fabefceb6b515766e64ebfb0460341a3 100644 (file)
@@ -49,7 +49,7 @@ PHP_FUNCTION(dom_xpath_xpath)
        dom_object *docobj, *intern;
        xmlXPathContextPtr ctx, oldctx;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &id, dom_xpath_class_entry, &doc) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
                return;
        }
 
@@ -106,7 +106,9 @@ PHP_FUNCTION(dom_xpath_register_ns)
        dom_object *intern;
        unsigned char *prefix, *ns_uri;
 
-       DOM_GET_THIS(id);
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss", &id, dom_xpath_class_entry, &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) {
+               return;
+       }
 
        intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
 
@@ -116,10 +118,6 @@ PHP_FUNCTION(dom_xpath_register_ns)
                RETURN_FALSE;
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) {
-               RETURN_FALSE;
-       }
-
        if (xmlXPathRegisterNs(ctxp, prefix, ns_uri) != 0) {
                RETURN_FALSE
        }
@@ -149,7 +147,10 @@ PHP_FUNCTION(dom_xpath_query)
        xmlDoc *docp = NULL;
        xmlNsPtr *ns;
 
-       DOM_GET_THIS(id);
+
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|O", &id, dom_xpath_class_entry, &expr, &expr_len, &context, dom_node_class_entry) == FAILURE) {
+               return;
+       }
 
        intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
 
@@ -165,10 +166,6 @@ PHP_FUNCTION(dom_xpath_query)
                RETURN_FALSE;
        }
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|o", &expr, &expr_len, &context) == FAILURE) {
-               RETURN_FALSE;
-       }
-
        if (context != NULL) {
                DOM_GET_OBJ(nodep, context, xmlNodePtr, nodeobj);
        }