Re: Re: Non-pointer params, zend_parse_parameters, and the "!" modifier

From: Date: Sat, 02 Feb 2013 14:11:19 +0000
Subject: Re: Re: Non-pointer params, zend_parse_parameters, and the "!" modifier
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-65562@lists.php.net to get a copy of this message
2013/2/2 Gustavo Lopes <glopes@nebm.ist.utl.pt>:
> On Sat, 02 Feb 2013 14:36:00 +0100, Sara Golemon <pollita@php.net> wrote:
>
>> Gustavo's diff for scalars adds '!' support (this was ignored
>> previously) by letting the NULL get cast to the type (e.g.
>> false/0/0.0) and using a second zend_bool parameter to indicate if
>> NULL was passed or not:
>>
>>   long num = 42;
>>   zend_bool num_was_null;
>>
>>   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l!", &num,
>> &num_was_null) == FAILURE) return;
>>
>> Now if the func is called with NULL as the argument, num will still be
>> overwritten to 0, but we'll get the flag indicating that NULL got
>> passed in, and we're forced to reset it to the default value (assuming
>> that was our intent).
>>
>> [...]
>> Thoughts?
>
>
> You raise a good point. From my part, feel free to modify it so the passed
> long is not changed.
>

Yeah, makes sense. +1

-- 
Regards,
Felipe Pena


Thread (3 messages)

« previous php.internals (#65562) next »