Refactor how prehashed hash keys work.
[gitmo/Class-MOP.git] / xs / Attribute.xs
1 #include "mop.h"
2
3 MODULE = Class::MOP::Attribute   PACKAGE = Class::MOP::Attribute
4
5 PROTOTYPES: DISABLE
6
7 void
8 name(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
17         if ( (he = hv_fetch_ent((HV *)SvRV(self), KEY_FOR(name), 0, HASH_FOR(name))) )
18             XPUSHs(HeVAL(he));
19         else
20             ST(0) = &PL_sv_undef;