mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
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
This commit is contained in:
parent
104f2b5ff4
commit
a2e1844de9
3 changed files with 31 additions and 17 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue