summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-02-15 10:54:37 +0000
committerRob Richards <rrichards@php.net>2004-02-15 10:54:37 +0000
commita2e1844de9d2584769fbd4a06e7b67e418919198 (patch)
treee45fd090071c7df7cd445694b8db039929fdee21
parent104f2b5ff4940727b06346979750f0cb387d4c7e (diff)
downloadphp-git-a2e1844de9d2584769fbd4a06e7b67e418919198.tar.gz
start of dom update
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
-rw-r--r--ext/dom/processinginstruction.c15
-rw-r--r--ext/dom/text.c14
-rw-r--r--ext/dom/xpath.c19
3 files changed, 31 insertions, 17 deletions
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index 3a57457122..044bdf0098 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -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;
}
diff --git a/ext/dom/text.c b/ext/dom/text.c
index d315adaff8..05fca65ded 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -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;
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 4b693bb465..abaf35b9fa 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -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);
}