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