Re: help request: passing return value

From: Date: Tue, 07 Oct 2003 12:41:59 +0000
Subject: Re: help request: passing return value
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-4721@lists.php.net to get a copy of this message
Wez Furlong wrote:
PHP_FUNCTION (or ZEND_FUNCTION - they are the same) includes the function paramters; one of those is: zval *return_value; which already contains an allocated zval (set to NULL). If you want to change this in one of your own functions, you could do something like this: int f1(zval *return_value, ...) { ... change the return_value here ... return SUCCESS; } PHP_FUNCTION(my_func) { if (f1(return_value) == SUCCESS) {
       /* it worked */
       return;
} else {
       /* it didn't work */
       php_error(....)
} } Thanks a lot, it seems to work.
Also take a look in Zend/zend.h at the definitions for INTERNAL_FUNCTION_PARAMETERS and INTERNAL_FUNCTION_PARAM_PASSTHRU I will. Thanks again.
which can be used in you own function declarations to handle the php function paramters. Hope that helps, --Wez. PS: You're welcome to join the PHP Extension Community Library, or PECL, on pecl-dev@lists.php.net ----- Original Message ----- From: "netcat" <netcat@abox.co.il> To: "PHP Development" <internals@lists.php.net> Sent: Tuesday, October 07, 2003 9:43 AM Subject: [PHP-DEV] help request: passing return value
Hi internals. [background] I'm newbie here and with php extensions. Working on php extension. It should give access to librep. I have very little experience with C. [problem] zval f1(some_args) { zval r; ... return r; } /* f1 can return many different types */ ZEND_FUNCTION(f2) { /* working on some_args here */ ... ... /* here i need to return what f1(some_args) returns */ } What's the best way to pass the result ? Any macro that would ? [tried] To look at another modules. Make f1 be (zval *) and "*return_value=*rep_data_converter(result);" in f2. Since zval is not very simple structure - it doesn't work.
-- NetCat ------------------------------------------------------ SPAM-Free 10mb Free email + Antivirus + POP3 + more... Get it at http://www.doal.co.il:81/free/?c=all-spam

« previous php.internals (#4721) next »