Re: Translating optional zval ** with zend_parse_parameters() to PHP 7
| From: | Thomas Hruska | Date: | Fri, 25 Nov 2016 12:30:33 +0000 |
| Subject: | Re: Translating optional zval ** with zend_parse_parameters() to PHP 7 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97180@lists.php.net to get a copy of this message | ||
On 11/25/2016 12:27 AM, Kalle Sommer Nielsen wrote:
Hi Thomas 2016-11-25 4:13 GMT+01:00 Thomas Hruska <thruska@cubiclesoft.com>:Unless I missed something, zend_long is generally defined as a standard int64_t or int32_t type (Zend/zend_long.h). I need to be able to *modify* the original variable that was passed in. I already use "|l" and zend_long elsewhere in the extension. I'm thinking the correct ZPP string is "|z/" but the usage examples in core that I've looked at so far are inconsistent, hence the original question of what's the correct approach? -- Thomas Hruska CubicleSoft President I've got great, time saving software that you will find useful. http://cubiclesoft.com/I'm working on updating an extension for PHP 7 compatibility. I have one function that uses an optional zval ** with zend_parse_parameters().Since you are working with integers, you can do: zend_long prevcount = 0; if(zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &prevcount) == FAILURE) {zval **zprevcount = NULL; int count; int argc = ZEND_NUM_ARGS();if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Z",&zprevcount) == FAILURE) return;...if (argc > 0) { count = (int)PrevCount;zval_dtor(*zprevcount); ZVAL_LONG(*zprevcount, count); }What's the correct way to translate that into PHP 7?return;} if(prevcount) {/* ... use prevcount ... */} Notice that all integers returned from the ZPP is a zend_long, you can see more information about the ZPP in php-src/README.PARAMETER_PARSING_API