François Lemaire wrote:
Hello all,
here's what I'm trying to do: I'm writing a PHP extension in C and I'd like
to create a DOMDocument object in my C code that I could send back to my PHP
code. I have been trying many things, like:
#include "ext/dom/php_dom.h"
....
zval *doc;
MAKE_STD_ZVAL(doc);
object_init_ex(doc, dom_document_class_entry);
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
ZVAL_STRING(&constructor, ZEND_CONSTRUCTOR_FUNC_NAME, 1);
call_user_function(NULL, &doc, &constructor, &c_ret, 0, NULL TSRMLS_CC);
It compiles, but when I call my function, it fails on object_init_ex (and
when I say it fails, it stops apache...). I've also tried things like:
zend_call_method(NULL, dom_document_class_entry,
dom_document_class_entry->constructor, ZEND_CONSTRUCTOR_FUNC_NAME,
strlen(ZEND_CONSTRUCTOR_FUNC_NAME), &doc, 2, "1.0", "UTF-8" TSRMLS_CC);
but it stills kill apache each time.
Does anyone know how to do this? Is this even feasible?
Include dom/xml_common.h and use the DOM_RET_OBJ macro.
That will make sure everything is created properly. You should be able
to find an example of this in the xsl extension.
Rob
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php