Bill Moseley <[EMAIL PROTECTED]> writes:
>I have some code that works like:
>
> my $result_object = $search_object->query($query);
>
>I'd like to prevent $search_object from being destroyed until
>$results_object is gone. Normally I could do
>
> $results_object->{parent} = $search_object;
>
>But in this case $results_object is a pointer to a C struct
>not a hash (or an array).
>
>Are there any options other than returning a blessed array or hash ref as
>my object?
All you really want to do is increment the SvREFCNT of the parent object
for the duration. You can do that my hand and then (if you cannot already
locate it) save pointer to search object's SV in the C struct.
Does that help ?
>
>Thanks,
>
>
>Here's the real code:
>
> $results = $swish->SwishQuery($query);
>
>so the current xs code is:
>
>SW_RESULTS
>SwishQuery( swish_handle, query = NULL )
> SW_HANDLE swish_handle
> char *query
>
> PREINIT:
> char * CLASS = "SWISH::API::Results";
>
>
>Where SW_RESULTS is a O_OBJECT typemap.
>
>O_OBJECT
> sv_setref_pv( $arg, CLASS, (void*)$var );
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/