crenz has asked for the wisdom of the Perl Monks concerning the following question:
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
will all work correctly.n = GetName(aBarRef); n = GetName(aFooRef); n = GetName(aBazRef);
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XSUBs with variable input types
by thospel (Hermit) on Oct 24, 2004 at 22:15 UTC | |
by crenz (Priest) on Oct 25, 2004 at 09:01 UTC | |
by thospel (Hermit) on Oct 25, 2004 at 09:40 UTC | |
by crenz (Priest) on Oct 26, 2004 at 02:00 UTC | |
|
Re: XSUBs with variable input types
by Joost (Canon) on Oct 24, 2004 at 21:03 UTC |