diff options
author | Xinchen Hui <laruence@gmail.com> | 2014-04-21 14:14:00 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@gmail.com> | 2014-04-21 14:14:00 +0800 |
commit | e48b9ad197b4ec6ac72e75538453cc350d0a41f4 (patch) | |
tree | f5ded37abc65e64e270b6f1ac264db9bc603f949 /ext/dom/xpath.c | |
parent | cf7e703813e065fec7a8a5caa7aff4b70d3455b8 (diff) | |
parent | 54d9ad53f4797733b41bf2c65bd2c2cb5a1938b6 (diff) | |
download | php-git-e48b9ad197b4ec6ac72e75538453cc350d0a41f4.tar.gz |
Merge branch 'refactoring2' of github.com:zendtech/php into refactoring2
Diffstat (limited to 'ext/dom/xpath.c')
-rw-r--r-- | ext/dom/xpath.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 21998704fe..08bb8603a5 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -159,7 +159,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, node->parent = nsparent; node->ns = curns; } - php_dom_create_object(node, &child, (dom_object *)intern TSRMLS_CC); + php_dom_create_object(node, &child, &intern->dom TSRMLS_CC); add_next_index_zval(&fci.params[i], &child); } } @@ -196,7 +196,6 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, if (!zend_make_callable(&fci.function_name, &callable TSRMLS_CC)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", callable->val); - } else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to call handler '%s()'.", callable->val); /* Push an empty string, so that we at least have an xslt result... */ @@ -213,7 +212,7 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, } GC_REFCOUNT(&retval)++; zend_hash_next_index_insert(intern->node_list, &retval); - obj = Z_DOMOBJ_P(&retval); + obj = Z_XPATHOBJ_P(&retval); nodep = dom_object_get_node(obj); valuePush(ctxt, xmlXPathNewNodeSet(nodep)); } else if (Z_TYPE(retval) == IS_BOOL) { @@ -223,12 +222,13 @@ static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, valuePush(ctxt, xmlXPathNewString((xmlChar *)"")); } else { convert_to_string_ex(&retval); - valuePush(ctxt, xmlXPathNewString( Z_STRVAL(retval))); + valuePush(ctxt, xmlXPathNewString(Z_STRVAL(retval))); } zval_ptr_dtor(&retval); } } - STR_FREE(callable); + STR_RELEASE(callable); + zval_dtor(&fci.function_name); if (fci.param_count > 0) { for (i = 0; i < nargs - 1; i++) { zval_ptr_dtor(&fci.params[i]); @@ -275,11 +275,11 @@ PHP_METHOD(domxpath, __construct) RETURN_FALSE; } - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); if (intern != NULL) { - oldctx = (xmlXPathContextPtr)intern->ptr; + oldctx = (xmlXPathContextPtr)intern->dom.ptr; if (oldctx != NULL) { - php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); + php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom TSRMLS_CC); xmlXPathFreeContext(oldctx); } @@ -290,10 +290,10 @@ PHP_METHOD(domxpath, __construct) (const xmlChar *) "http://php.net/xpath", dom_xpath_ext_function_object_php); - intern->ptr = ctx; + intern->dom.ptr = ctx; ctx->userData = (void *)intern; - intern->document = docobj->document; - php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC); + intern->dom.document = docobj->document; + php_libxml_increment_doc_ref((php_libxml_node_object *) &intern->dom, docp TSRMLS_CC); } } /* }}} end DOMXPath::__construct */ @@ -326,9 +326,9 @@ PHP_FUNCTION(dom_xpath_register_ns) return; } - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); - ctxp = (xmlXPathContextPtr) intern->ptr; + ctxp = (xmlXPathContextPtr) intern->dom.ptr; if (ctxp == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context"); RETURN_FALSE; @@ -343,13 +343,10 @@ PHP_FUNCTION(dom_xpath_register_ns) static void dom_xpath_iter(zval *baseobj, dom_object *intern) /* {{{ */ { - dom_nnodemap_object *mapptr; + dom_nnodemap_object *mapptr = (dom_nnodemap_object *) intern->ptr; - mapptr = (dom_nnodemap_object *)intern->ptr; - Z_ADDREF_P(baseobj); - mapptr->baseobj = Z_OBJ_P(baseobj); + ZVAL_COPY_VALUE(&mapptr->baseobj_zv, baseobj); mapptr->nodetype = DOM_NODESET; - } /* }}} */ @@ -371,9 +368,9 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ return; } - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); - ctxp = (xmlXPathContextPtr) intern->ptr; + ctxp = (xmlXPathContextPtr) intern->dom.ptr; if (ctxp == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid XPath Context"); RETURN_FALSE; @@ -466,7 +463,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ node->parent = nsparent; node->ns = curns; } - php_dom_create_object(node, &child, (dom_object *)intern TSRMLS_CC); + php_dom_create_object(node, &child, &intern->dom TSRMLS_CC); add_next_index_zval(&retval, &child); } } @@ -522,7 +519,7 @@ PHP_FUNCTION(dom_xpath_register_php_functions) DOM_GET_THIS(id); if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "a", &array_value) == SUCCESS) { - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value)); while ((entry = zend_hash_get_current_data(Z_ARRVAL_P(array_value)))) { zend_string *str = zval_get_string(entry TSRMLS_CC); @@ -535,13 +532,13 @@ PHP_FUNCTION(dom_xpath_register_php_functions) RETURN_TRUE; } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "S", &name) == SUCCESS) { - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); ZVAL_LONG(&new_string, 1); zend_hash_update(intern->registered_phpfunctions, name, &new_string); intern->registerPhpFunctions = 2; } else { - intern = Z_DOMOBJ_P(id); + intern = Z_XPATHOBJ_P(id); intern->registerPhpFunctions = 1; } |