in reply to Re: Terrible Trouble With Typemaps (XS Question)
in thread Terrible Trouble With Typemaps (XS Question)

Thanks for the help, to be honest I didn't consider the preprocessor since I tend to avoid it as much as possible in the interests of readability.. but in this case it may have a use.

Just so you know, it will be more a case of:

int MyClass::countItemsIn (...) CODE: if (SV_IS_MYLIST(ST(0))) { THIS->countItemsIn ( CAST_SV_TO_MYLIST(ST(0)) ); } elsif (SV_IS_MYHASH(ST(0)) { THIS->countItemsIn ( CAST_SV_TO_MYHASH(ST(0)) ); }; OUTPUT: RETVAL

..where the SV_IS_MYLIST/CAST_SV_TO_MYLIST parts are all macros.

Replies are listed 'Best First'.
Re^3: Terrible Trouble With Typemaps (XS Question)
by dragonchild (Archbishop) on Sep 07, 2004 at 16:41 UTC
    What about the following:
    CODE: if ( MY_SV_IS( ST(0), 'MyList' )) { THIS->count_Items_in( MY_CAST_SV( ST(0), 'MyList' ) } elsif (MY_SV_IS( ST(0), 'MyHash' )) { THIS->count_Items_in( MY_CAST_SV( ST(0), 'MyHash' ) }

    This way, you don't have a plethora of macros. Remember, a preprocessor macro is just a direct text substitution. So, you can put text in there, kinda like what I was doing in my first reply.

    ------
    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

      It's got to be a plethora of macros, unfortunately, since the way I convert to MyList could well be very different from the conversion to MyHash.. especially when it comes to handling classes inherited from them.

      Ah well, with a consistant naming strategy there's not too much stuff making the macro namespace unusable.