Re: XS C++ return class pointers

[email protected] (James Shirley)
Newsgroups perl.xs
Message-ID <[email protected]>
Steffen,

Thankyou. I've resolved my problems quite simply by specifying the CLASS
variable, after reading the generated c code..

So instead of:


MyClass *
MyClass::child()
  CODE:
    RETVAL = (MyClass *)safemalloc( sizeof(MyClass) );
    *RETVAL = THIS->child();

  OUTPUT:
    RETVAL

  CLEANUP:
    safefree(RETVAL);

I used:

MyClass *
MyClass::child()
  CODE:
    const char *CLASS = "MyPackage";
    RETVAL = new MyClass(THIS->child());

  OUTPUT:
    RETVAL


Cheers

James


On 10 April 2011 15:51, Steffen Mueller <[email protected]> wrote:

> Hi James,
>
>
> On 04/10/2011 04:08 AM, James Shirley wrote:
>
>> It seems I will need to spend some time to understand XS and perl guts.
>> I was just hoping to add a perl interface without spending to much time..
>>
>
> I think you should read the rest of my previous message more carefully.
> Quite likely, it explains what your problem is and how to work around it.
>
> --Steffen
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.