On Sat, Jul 10, 2004 at 09:18:02AM -0600, Tim Pushor wrote:
> Hi all,
> 
> I would like to make my XSUBS callable in an OO style for various 
> reasons (mostly because of namespace). Do I just make my C XSUBS take a 
> hash reference as the first argument? Then can I just do the same as I 
> would in perl - i.e. store 'class' stuff in the hash?

Yes. It really can be that simple. :-)

The Inline::C cookbook has some examples of how to write OO methods in C.
Although they're showing Inline's way of wrapping the arguments, it's not
that hard to translate them to XS, given that Inline is actually a simple
wrapper around XS for the structure of the actual C function bodies.

You'll probably want to verify that your reference is in the correct class
with sv_derived_from() [see perlapi.pod] so that derived classes work.

Nicholas Clark

Reply via email to