Refactor how prehashed hash keys work.
[gitmo/Class-MOP.git] / xs / Method.xs
CommitLineData
d846ade3 1#include "mop.h"
2
d846ade3 3MODULE = Class::MOP::Method PACKAGE = Class::MOP::Method
4
5PROTOTYPES: DISABLE
6
7void
8name(self)
9 SV *self
10 PREINIT:
11 register HE *he;
12 PPCODE:
13 if ( ! SvROK(self) ) {
14 die("Cannot call name as a class method");
15 }
16
22932438 17 if ( (he = hv_fetch_ent((HV *)SvRV(self), KEY_FOR(name), 0, HASH_FOR(name))) )
d846ade3 18 XPUSHs(HeVAL(he));
19 else
20 ST(0) = &PL_sv_undef;
21
22void
23package_name(self)
24 SV *self
25 PREINIT:
26 register HE *he;
27 PPCODE:
28 if ( ! SvROK(self) ) {
29 die("Cannot call package_name as a class method");
30 }
31
22932438 32 if ( (he = hv_fetch_ent((HV *)SvRV(self), KEY_FOR(package_name), 0, HASH_FOR(package_name))) )
d846ade3 33 XPUSHs(HeVAL(he));
34 else
35 ST(0) = &PL_sv_undef;
36
37void
38body(self)
39 SV *self
40 PREINIT:
41 register HE *he;
42 PPCODE:
43 if ( ! SvROK(self) ) {
44 die("Cannot call body as a class method");
45 }
46
22932438 47 if ( (he = hv_fetch_ent((HV *)SvRV(self), KEY_FOR(body), 0, HASH_FOR(body))) )
d846ade3 48 XPUSHs(HeVAL(he));
49 else
50 ST(0) = &PL_sv_undef;