llancet has asked for the wisdom of the Perl Monks concerning the following question:
I guess someone will tell me Inline::CPP, but for some reason I'm not going to use it. I've also read the code of Inline::CPP, but failed to understand it.
I know perl has XS to work with C functions. However, how to use XS with the OO features in C++? Can I wrap a method indirectly like this?
The C++ class:And a C wrapper:class Foo { void some_method(int arg) { do_something; } };
and then simply write XS for that C wrapper?void some_method(SV* self, int arg) { // can I store the pointer as IV? SV* inner = SvRV(self); Foo* obj = (Foo*) SvIV(inner); obj->some_method(arg); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to use C++ in perl WITH OUT INLINE
by biohisham (Priest) on Jun 25, 2011 at 04:55 UTC | |
Re: How to use C++ in perl WITH OUT INLINE
by Anonymous Monk on Jun 25, 2011 at 06:27 UTC | |
Re: How to use C++ in perl WITH OUT INLINE
by zentara (Cardinal) on Jun 25, 2011 at 14:18 UTC | |
by tod222 (Pilgrim) on Jun 26, 2011 at 05:37 UTC | |
Re: How to use C++ in perl WITH OUT INLINE
by thirdm (Sexton) on Jun 25, 2011 at 11:42 UTC |