TDJ>> Could you go into a little more depth on the problem, just so I
TDJ>> understand?
The problem is that passing argument passes only zval *, i.e. pointer to
variable itself. To make reference assignment, you need zval **, i.e. the
place in the symbol table.
--
Stanislav Malyshev, Zend Pro
TDJ>> Sorry, I wasn't clear. I mean ref_assign to be a C function, in my
TDJ>> extension.
Ah. Then you need to accept the first parameter by reference (this is
defined in ZEND_FE definition, put first_arg_force_ref as second
parameter). Then you get parameters the usual way (zend_get_parameters
TDJ>> Thanks for your response! While it does not cause a crash, your
TDJ>> function doesn't do what I expected. Do you know where I went
TDJ>> wrong?
OK, looking again on the matter in depth, it seems to me that you cannot
do it from C function either, due to the way in which parameters are
p
TDJ>> Thanks for your response! While it does not cause a crash, your
TDJ>> function doesn't do what I expected. Do you know where I went
TDJ>> wrong?
You are right, this doesn't work. I'll look a bit more into it...
--
Stanislav Malyshev, Zend Products Engineer
[EMAIL PROTECTED] http://ww
- Original Message -
From: "Stanislav Malyshev" <[EMAIL PROTECTED]>
To: "Tim Daly, Jr." <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, October 17, 2002 5:34 PM
Subject: Re: [PHP-DEV] trying to understand zvals
> TDJ>> I
PHP_FUNCTION(ref_assign)
{
zval *bar, *foo;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &bar, &foo) ==
FAILURE) {
return;
}
ZVAL_ADDREF(foo);
*bar = *foo;
bar->is_ref = TRUE;
bar->refcount = 1;
}
this works, b
Stanislav Malyshev <[EMAIL PROTECTED]> writes:
*snip*
> TDJ>> that did such a reference assignment:
> TDJ>>
> TDJ>> $foo = "zonk";
> TDJ>> $bar = "baz";
> TDJ>>
> TDJ>> ref_assign($bar, $foo); // $bar =& $foo;
> TDJ>>
> TDJ>> what has to happen in ref_assign?
>
> That'
TDJ>> I'm trying to do some extension programming, and I'm pretty confused
TDJ>> by the whole zval thing. In particular, references are a little
TDJ>> mysterious. If I have
TDJ>>
TDJ>> $foo = "zonk";
TDJ>> $bar =& $foo;
TDJ>>
TDJ>> in PHP, what actually happens? Specifically, i
Stanislav Malyshev <[EMAIL PROTECTED]> writes:
> OK, looking again on the matter in depth, it seems to me that you cannot
> do it from C function either, due to the way in which parameters are
> passed in the engine.
Could you go into a little more depth on the problem, just so I
understand?
Stanislav Malyshev <[EMAIL PROTECTED]> writes:
> Ah. Then you need to accept the first parameter by reference (this is
> defined in ZEND_FE definition, put first_arg_force_ref as second
> parameter). Then you get parameters the usual way (zend_get_parameters_ex,
> etc.) and have to zval ** va
Brad LaFountain <[EMAIL PROTECTED]> writes:
> PHP_FUNCTION(ref_assign)
> {
> zval *bar, *foo;
>
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &bar, &foo) ==
> FAILURE) {
> return;
> }
>
> ZVAL_ADDREF(foo);
> *bar = *foo;
> bar->i
11 matches
Mail list logo