When dealing with this kind of thing in C, we'd use a macro #define to make our lives easier. So, I could see something like:
#define CALL_COUNT_ITEMS_IF( type ) \ if (sv_derived_from(ST(0), type)) { \ RETVAL=THIS->countItemsIn( \ *(type *) SvIV((SV*)SvRV(ST(0))) \ ); \ } int MyClass::countItemsIn (...) CODE: CALL_COUNT_ITEMS_IF( 'MyList' ); CALL_COUNT_ITEMS_IF( 'MyHash' ); OUTPUT: RETVAL
Again, I have no idea if XS provides for a pre-processor or not. Hope this helps!
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
In reply to Re: Terrible Trouble With Typemaps (XS Question)
by dragonchild
in thread Terrible Trouble With Typemaps (XS Question)
by Molt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |