in reply to returning an object in XS
There needs to be a typemap that will explain to Perl how to bind a rect * to a Perl structure of some sort. There are several CPAN modules that help to simplify the process. The one I'm most familiar with is Inline::CPP. But I'm highly biased.
The gist of it is that you can create a C++ class that maps to a Perl class. The constructor becomes new(). The destructor becomes DESTROY(), and so on. The docs for Inline::C, Inline::C-Cookbook, and Inline::CPP are required reading in getting started with it. But it's fun (if you're slightly masochistic) once you get the hang of it.
Inline::Struct is compatible with C (ie, doesn't require C++), and will bind C structures to Perl objects too.
There was a time when Inline::CPP wasn't installing on the vast majority of systems out there. Over the last few months we've gotten it to the point that there's only one class of smoke testers that are still having trouble with it (NetBSD -- Any NetBSD pros get in touch with me so we can try to figure it out). Most other common platforms are able to install it and use it. There's also an email list where people can answer questions about the Inline modules: inline@perl.org. See http://lists.perl.org for details.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: returning an object in XS
by bipham (Novice) on Feb 29, 2012 at 04:23 UTC | |
by davido (Cardinal) on Feb 29, 2012 at 04:43 UTC | |
by bipham (Novice) on Feb 29, 2012 at 21:07 UTC | |
by davido (Cardinal) on Feb 29, 2012 at 23:23 UTC |