[PATCH] extend zend_parse_parameters() functionality (2nd attempt)

php.internals

Unnamed Person

23 years ago
Hello, I propose that a new type, 'Z', be added in order to allow the extension coders access to the zval** which was available with the now deprecated zend_get_parameters(). I came to this conclusion after tracing some segfaults to a section of code similar to this: zval *zend_value; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zend_value) == FAILURE) return; convert_to_array_ex(&zend_value); I realized after sifting through the Zend code that the proper handling of zval* types is just as important as that of the zval's. This modification will give extension programmers access to legitimate zval*'s and their corresponding zval. Zend/zend_API.c RELEASE ver 4.3.1 425c425,434 < ---
> case 'Z': > { > zval ***p=va_arg(*va, zval ***); > if(Z_TYPE_PP(arg) == IS_NULL && return_null){ > *p = NULL; > } else { > *p = arg; > } > } > break;
474c483 < case 'z': ---
> case 'z': case 'Z':
Josh

Andrei Zmievski

23 years ago
On Fri, 27 Jun 2003, fuhs@purdue.edu wrote:
> I propose that a new type, 'Z', be added in order to allow the extension coders > access to the zval** which was available with the now deprecated > zend_get_parameters(). > > I came to this conclusion after tracing some segfaults to a section of code > similar to this: > > zval *zend_value; > if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zend_value) == > FAILURE) > return; > > convert_to_array_ex(&zend_value); > > I realized after sifting through the Zend code that the proper handling of zval* > types is just as important as that of the zval's. This modification will > give extension programmers access to legitimate zval*'s and their corresponding > zval.
If you want zval**'s, use zend_get_parameters(). -Andrei "The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" but "That's funny..." -- Isaac Asimov.

Unnamed Person

23 years ago
Quoting Andrei Zmievski <andrei@gravitonic.com>:
> > If you want zval**'s, use zend_get_parameters(). > > -Andrei >
How does one get zval**'s in a non-deprecated way? Josh

(Marcus Börger)

23 years ago
Hello fuhs, Friday, June 27, 2003, 8:46:41 PM, you wrote: fpe> Quoting Andrei Zmievski <andrei@gravitonic.com>:
>> >> If you want zval**'s, use zend_get_parameters(). >> >> -Andrei >>
fpe> How does one get zval**'s in a non-deprecated way? fpe> Josh "z/" instead og "z" :-)
-- Best regards, Marcus mailto:helly@php.net

Unnamed Person

23 years ago
Quoting Marcus Börger <marcus.boerger@t-online.de>:
> Hello fuhs, > > Friday, June 27, 2003, 8:46:41 PM, you wrote: > > fpe> Quoting Andrei Zmievski <andrei@gravitonic.com>: > > >> > >> If you want zval**'s, use zend_get_parameters(). > >> > >> -Andrei > >> > > fpe> How does one get zval**'s in a non-deprecated way? > > fpe> Josh > > > "z/" instead og "z" :-) > > -- > Best regards, > Marcus mailto:helly@php.net > >
"z/" unecessarily separates the zval if I don't have to convert. I need the zval to be an array, however, the zend_parse_parameters() functionality will not convert from an object to an array if an object happens to be given. This is behavior that I would prefer to have. Since it makes sense that zend_parse_parameters() not automatically convert to an array with "a", I proposed the "Z" type so that I could handle the conversion as I see fit. But, since conversion is not always necessary, I didn't want to use "z/". convert_to_array_ex() is the behavior I need, but I can't get a good zval** with zend_parse_parameters() in its current state. Josh