I'm working on creating an OO-style interface to a procedural C API (Mac OS X' CoreMIDI, for the interested). I'm not really an XS expert, so I'd like some advice on one specific problem:
Let's assume we have a base class, foo. Classes baz and bar and other classes inherit from this class. The C API returns me opaque references to objects of these classes and offers several functions such as GetName that work with foo, bar and baz, but not with quux objects. So
n = GetName(aBarRef);
n = GetName(aFooRef);
n = GetName(aBazRef);
will all work correctly.
For the Perl interface, I want to create classes Foo, Bar and Baz. Now, if I create an XSUB GetName(fooRef myReference), Perl will complain if I call it with a barRef.
So the question is: How can I make an XSUB accept input parameters of a number of different types? Or should I just create different XSUBs (GetFooName, GetBarName, ...), since I'm not going to expose these functions to the user of my module anyway?