Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: How to de-reference a coderef? (B tricks)

by Anonymous Monk
on Aug 24, 2011 at 01:14 UTC ( #922026=note: print w/replies, xml ) Need Help??


in reply to Re: How to de-reference a coderef? (B tricks)
in thread How to de-reference a coderef?

How do you do this in XS? Given a CV how do you get the name for the corresponding named sub?
  • Comment on Re^2: How to de-reference a coderef? (B tricks)

Replies are listed 'Best First'.
Re^3: How to de-reference a coderef? (B tricks)
by ikegami (Pope) on Aug 25, 2011 at 04:29 UTC
    use strict; use warnings; use feature qw( say ); use Inline C => <<'__EOI__'; SV* coderef2name(CV* cv) { const GV * const gv = CvGV(cv); const HV * const stash = GvSTASH(gv); const char * const pkg_name = HvNAME(stash); const char * const func_name = GvNAME(gv); SV * const fqn = newSVpvn("", 0); sv_catpv(fqn, pkg_name); sv_catpv(fqn, "::"); sv_catpv(fqn, func_name); return fqn; // Mortalised by Inline } __EOI__ sub f {} say coderef2name(\&f);
Re^3: How to de-reference a coderef? (B tricks)
by Anonymous Monk on Aug 25, 2011 at 01:14 UTC
    You call coderef2name from XS, that is how you do it

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://922026]
help
Chatterbox?
[karlgoethebier]: ...because of sausage and luncheon meats...
[karlgoethebier]: ... the ultimate coding experience for everyday people...
[karlgoethebier]: ...like me
[marto]: what a mess
[karlgoethebier]: perhaps i need a zerial?
[Corion]: marto: Heh - I think that's a nice contractual trap, "you will not use other gods/engines besides ours" ;)
[Corion]: But if the base intention was to have CIG as "co-developers" who (have to) contribute changes back to the mainline, it makes sense to have them use no other engine
[marto]: yes, I hear that development house has been on its last legs for a couple of years now
[Corion]: Is anybody aware of what makes Android Oreo better than Android Nougat? I'm not sure if the architectural changes (etc) are there already that make upgrading an Oreo-kernel phone to a newer Android userland (Lineage OS) version feasible
[Corion]: Yeah, CryTek got blindsided (or whatever) by Unity and Unreal Engine being zero cost, and the CryTek documentation being bad/nonexistent I think

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-12-14 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?