in reply to Terrible Trouble With Typemaps (XS Question)
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Terrible Trouble With Typemaps (XS Question)
by Molt (Chaplain) on Sep 07, 2004 at 14:38 UTC | |
by dragonchild (Archbishop) on Sep 07, 2004 at 16:41 UTC | |
by Molt (Chaplain) on Sep 09, 2004 at 11:03 UTC |