Re: problems compiling new PECL module

From: Date: Sun, 09 Jan 2011 07:04:56 +0000
Subject: Re: problems compiling new PECL module
References: 1 2 3 4 5  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7930@lists.php.net to get a copy of this message
2011/1/9 Tim Gustafson <tjg@tgustafson.com>: > However, the GetSourceModule function is not working because I don't > understand how to embed a C++ object into a zval. I'm not sure if I understood correctly what you're trying to do, but if you want to return an instance of noise::module::Module to userland as a PHP object, you would need to declare its class (Noise_Module) and assign a proper constructor/destructor handler just like you did with your other classes. You'd declare your object: struct noise_module_object { zend_object std; noise::module::Module *nm; }; Declare the class: zend_class_entry *noise_module_ce; INIT_CLASS_ENTRY(.... Implement a constructor where you'd allocate memory for noise_module: zend_object_value noise_module_create_handler(zend_class_entry *type TSRMLS_DC) { // stuff } And then inside GetSourceModule() you would need to initialize it and assign noise_abs->GetSourceModule(i) to the nm internal variable. I am not sure how to properly instantiate the object inside your function, but I think you can take a look at what is done in DateTime::createFromString(): http://lxr.php.net/opengrok/xref/PHP_5_3/ext/date/php_date.c#3592 The actual object creation is being done in php_date_instantiate(): http://lxr.php.net/opengrok/xref/PHP_5_3/ext/date/php_date.c#php_date_instantiate I'm not sure if this is the right way to go, but I hope it helps... -- Pedro Padron http://ppadron.blog.br/

« previous php.pecl.dev (#7930) next »