retrieveing the zval pointer of an "object"

php.internals

Michael Wallner

22 years ago
Hi, I have an hopefully simple question; imagine the following statement: obj = (struct obj_struct *) zend_object_store_get_object(zval TSRMLS_CC); Ok, now I'm in a situation where I'd need the other way round, i.e. a way to fetch the zval of the obj I've got (i.e. I have "obj" and need "zval"). Any hints? Thanks,
-- Michael - < mike(@)php.net >

Andrey Hristov

22 years ago
isn't the situation that several zvals can reference one object? Andrey Michael Wallner wrote:

Michael Wallner

22 years ago
Hi Andrey Hristov, you wrote:
> isn't the situation that several zvals can reference one object?
Should this be read as "No way, sorry"? :) Regards,
-- Michael - < mike(@)php.net >

Andrey Hristov

22 years ago
The engine gurus have the final word :) Andrey Michael Wallner wrote:

Andrei Zmievski

22 years ago
On Fri, 27 Aug 2004, Michael Wallner wrote:
> Hi, > > I have an hopefully simple question; > imagine the following statement: > > obj = (struct obj_struct *) zend_object_store_get_object(zval TSRMLS_CC); > > > Ok, now I'm in a situation where I'd need the other way > round, i.e. a way to fetch the zval of the obj I've got > (i.e. I have "obj" and need "zval"). > > Any hints?
The main question is: why do you need to do it? - Andrei

Michael Wallner

22 years ago
Hi Andrei Zmievski, you wrote:
> The main question is: why do you need to do it?
Exercise ;) I'll try to explain after having dinner... Thanks,
-- Michael - < mike(@)php.net >

Andi Gutmans

22 years ago
There doesn't exist such a thing as the object's zval. An object can have many zval's. The zval includes the object's id and handlers that manage the object's behavior. You can just create a new zval by using MAKE_STD_ZVAL() and setting the relevant fields. If you get stuck let me know. Andi At 11:16 AM 8/27/2004 +0200, Michael Wallner wrote:

Michael Wallner

22 years ago
Hi Andi Gutmans, you wrote:
> You can just create a new zval by using > MAKE_STD_ZVAL() and setting the relevant fields.
Fair enough; I was searching for kinda ZVAL_OBJ[ECT]() macro at second, without success...
> If you get stuck let me know.
A tiny piece of code would help a lot :) I can't imagine how to do that right now, because I don't have the zend_object_handle. If you scroll down to approx. the middle of the code here http://iworks.at/~mike/apr/apr.c there's the definition of an APR_Ring object being kind of a doule-linked list. Now if I want to introduce a walk method going along the objects to call_user_function_ex() on them I need a zval to pass as parameter. Thanks,
-- Michael - < mike(@)php.net >