XS bits: Which class is this object blessed into?
So it turns out I'm not really good at this blogging thing. It's not that I feel I have nothing worth writing about, but that my time is usually better spent on other things. Instead of pretending to myself that I will eventually write long rants (and then effectively writing nothing), I'll try to post occasional bits of code that I found useful and not particularly obvious. I've been writing a lot of XS lately and the somewhat incomplete or at least inaccessible XS / perl API documentation could do with a little more cookbook style. Furthermore, when writing C/XS code that uses the perl API, I find myself trying to do the same things that are trivial in Perl and taking much, much longer to actually succeed. Thus, I'll start out with a bit of perl API.
Which class is this object blessed into?
If you wonder why this isn't a moderately frequent issue, then consider that 90% of the time, you really want to know whether the given object is blessed into a class that is derived from some class. This related issue is simple, using
. There is no builtin function/macro to give you the class name itself. You can get it with:
bool sv_derived_from(SV* sv, const char* name)
I guess it's simple enough to figure out when you read the code, but it wasn't obvious to me when I wrote it, err, asked better programmers for help with it.
Is there a web site that has the perlapi document in HTML form and HTML anchors for each function/macro to link to?
Update: Thanks to Christians comment, I added the appropriate links to documentation