Hi,

On Tue, Jun 04, 2002 at 10:21:09PM -0400, fabwash wrote : 
> i'm trying to use ZEND_FETCH_RESOURCE so I can use macros
> instead of other stuff, but i can't figure out how to use it.
> 
> I have the following php code:
> 
> $blah = new Blah();
> $blah->doSomething();
> 
> When Blah() is called, I want to create a structure and store it as a resource:
> 
> typedef struct {
>    int zoo;
>    long blurb;
> } blah_struct;
> 
> blah_struct *blah;
> 
> I register my resource:
> 
> ZEND_REGISTER_RESOURCE(result_returned, &blah, le_blahresource);
> 
> In "doSomething" I want to get my resource back, so I try to do:
> 
> ZEND_FETCH_RESOURCE(blah, blah_struct *, ????????, "blah", le_blahresource);

    ???????? is supposed to be a zval** of IS_RESOURCE which
    contains the rsrc_id to fetch from the resource list.
    
> This 3rd parameter is a mystery. I checked other modules, and
> they pass a zval taken from user input, but in my case, I don't
> have user input, I just want to get my structure back. What am
> I supposed to pass as the 3rd parameter?? I tried passing a
> reference to the Blah() object, but that didn't work.
> 
> I found a workaround, using zend_list_insert and
> zend_list_find, but I guess I should be able to use
> ZEND_REGISTER and ZEND_FETCH, no?

    zend_list_find is ok, but you have to store the rsrc_id
    somewhere. Take a look at ext/domxml which which stores
    resources within objects ( php_dom_set_object() ).

    - Markus

-- 
GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc
Did I help you?    http://guru.josefine.at/wish_en
Konnte ich helfen? http://guru.josefine.at/wish_de

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to