On Mon, Nov 19, 2012 at 5:09 AM, Stas Malyshev <smalys...@sugarcrm.com>wrote:

> Hi!
>
> > Hi internals!
> >
> > It happens quite often that you need to extract an integer from a zval
> and
> > you also want it to work for integers in strings, etc. In order to do so
> > you currently have to cast the zval to integer. This is always rather
> > complicated because you often don't want to actually change the passed
>
> Where it happens quite often outside of function arguments (where it is
> covered by parameter parsing APIs)?
>

It's just something that crops up every now and again. E.g. when you take
it from an array or something like that.


> Should it handle all conversions the engine performs or only from string?
>

Should be the normal casting behavior.


> We could probably expose zendi_convert_to_long() and similar ones, but
> I'm not sure what the use case for these would be. Could you give more
> background on this?
>

zendi_convert_to_long() isn't really what I'm looking for. All the current
convert functions convert a zval, which is not what you normally need, at
least that's the feeling that I got. So what you end up doing is something
like this:

     long result;
     Z_ADDREF_P(zval);
     convert_to_long_ex(&zval);
     result = Z_LVAL_P(zval);
     zval_ptr_dtor(&zval);

Which seems overly complicated to me. What I'm looking for is something
like this:

    long result = zval_get_long_with_cast(zval);

Or maybe I'm missing something about how to easily get an integer from a
value?

Nikita

Reply via email to