# retrieveing the zval pointer of an "object"

- Thread: https://externals.io/message/12414
- Original archive: https://news-web.php.net/php.internals/12414
- Started by Michael Wallner on 2004-08-27T09:16:32+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12414 — Michael Wallner — 2004-08-27T09:16:32+00:00

URL: https://externals.io/message/12414#12414

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

---

## #12415 — Andrey Hristov — 2004-08-27T09:35:05+00:00

URL: https://externals.io/message/12414#12415 · In reply to: #12414

isn't the situation that several zvals can reference one object?

Andrey

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?
> 
> Thanks,

---

## #12418 — Michael Wallner — 2004-08-27T10:30:16+00:00

URL: https://externals.io/message/12414#12418 · In reply to: #12415

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

---

## #12419 — Andrey Hristov — 2004-08-27T10:41:21+00:00

URL: https://externals.io/message/12414#12419 · In reply to: #12418

The engine gurus have the final word :)

Andrey

Michael Wallner wrote:
> Hi Andrey Hristov, you wrote:
> 
> > […]
> 
> 
> Should this be read as "No way, sorry"? :)
> 
> Regards,

---

## #12427 — Andrei Zmievski — 2004-08-27T16:02:48+00:00

URL: https://externals.io/message/12414#12427 · In reply to: #12414

> 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

---

## #12429 — Michael Wallner — 2004-08-27T16:21:42+00:00

URL: https://externals.io/message/12414#12429 · In reply to: #12427

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

---

## #12430 — Andi Gutmans — 2004-08-27T16:23:08+00:00

URL: https://externals.io/message/12414#12430 · In reply to: #12414

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:
>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

---

## #12432 — Michael Wallner — 2004-08-27T17:25:18+00:00

URL: https://externals.io/message/12414#12432 · In reply to: #12430

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
