#if defined(LIBXML_XPATH_ENABLED)
memcpy(&dom_xpath_object_handlers, &dom_object_handlers, sizeof(zend_object_handlers));
- dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, std);
+ dom_xpath_object_handlers.offset = XtOffsetOf(dom_xpath_object, dom) + XtOffsetOf(dom_object, std);
dom_xpath_object_handlers.free_obj = dom_xpath_objects_free_storage;
INIT_CLASS_ENTRY(ce, "DOMXPath", php_dom_xpath_class_functions);
{
dom_xpath_object *intern = php_xpath_obj_from_obj(object);
- zend_object_std_dtor(&intern->std TSRMLS_CC);
+ zend_object_std_dtor(&intern->dom.std TSRMLS_CC);
- if (intern->ptr != NULL) {
- xmlXPathFreeContext((xmlXPathContextPtr) intern->ptr);
- php_libxml_decrement_doc_ref((php_libxml_node_object *) intern TSRMLS_CC);
- intern->ptr = NULL;
+ if (intern->dom.ptr != NULL) {
+ xmlXPathFreeContext((xmlXPathContextPtr) intern->dom.ptr);
+ php_libxml_decrement_doc_ref((php_libxml_node_object *) &intern->dom TSRMLS_CC);
}
if (intern->registered_phpfunctions) {
ALLOC_HASHTABLE(intern->registered_phpfunctions);
zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
- intern->prop_handler = &dom_xpath_prop_handlers;
- intern->std.handlers = &dom_xpath_object_handlers;
+ intern->dom.prop_handler = &dom_xpath_prop_handlers;
+ intern->dom.std.handlers = &dom_xpath_object_handlers;
- zend_object_std_init(&intern->std, class_type TSRMLS_CC);
- object_properties_init(&intern->std, class_type);
+ zend_object_std_init(&intern->dom.std, class_type TSRMLS_CC);
+ object_properties_init(&intern->dom.std, class_type);
- return &intern->std;
+ return &intern->dom.std;
}
/* }}} */
#endif
#define DOM_NODESET XML_XINCLUDE_START
typedef struct _dom_xpath_object {
- void *ptr;
- php_libxml_ref_obj *document;
- HashTable *prop_handler;
int registerPhpFunctions;
HashTable *registered_phpfunctions;
HashTable *node_list;
- zend_object std;
+ dom_object dom;
} dom_xpath_object;
static inline dom_xpath_object *php_xpath_obj_from_obj(zend_object *obj) {
- return (dom_xpath_object*)((char*)(obj) - XtOffsetOf(dom_xpath_object, std));
+ return (dom_xpath_object*)((char*)(obj)
+ - XtOffsetOf(dom_xpath_object, dom) - XtOffsetOf(dom_object, std));
}
#define Z_XPATHOBJ_P(zv) php_xpath_obj_from_obj(Z_OBJ_P((zv)))
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);
}
}
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);
}
(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 */
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;
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;
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);
}
}