On 6/15/06, muppet <[EMAIL PROTECTED]> wrote:

On Jun 14, 2006, at 9:05 PM, ruz wrote:

>   Hi.
> I'm trying to embed perl into C programm.
>
> In C function I have tMyStruct* xxx and want bless this pointer into
> class 'MyStruct' and pass this object as argument into perl function.
> I really don't understand how to write something like "bless
> $ref_to_xxx, 'MyStruct'". Could give me small example or pointer to a
> code where it's implemented.

The magic you want involves using sv_setref_pv() in a typemap.

See the sections "Perl Objects and C Structures" and "The Typemap" in
the perlxs manpage, and the sv_setref_pv() entry in the perlapi manpage.

Yesterday I've tried next thing:
XPUSHs(sv_2mortal(sv_setref_pv(newSViv((IV)xxx), "MyClass", (void*)xxx)));

Looks like it works, no much progress yet, but anyway thanks for your help.



--
However, like all drugs, PANEXA can produce some notable side
effects, all of which are probably really, really terrific and
nothing that anyone should be concerned about, let alone notify any
medical regulatory commission about.
   -- http://www.panexa.com





--
Best regards, Ruslan.

Reply via email to