The first step to frame XS attributes
[gitmo/Class-MOP.git] / xs / MethodAccessor.xs
1 #include "mop.h"
2
3 static CV*
4 mop_instantiate_xs_accessor(pTHX_ SV* const meta_attr, XSPROTO(accessor_impl)){
5     SV* const key = mop_call0(aTHX_ meta_attr, sv_2mortal(newSVpvs("attribute_name")));
6     STRLEN len;
7     const char* const pv = SvPV_const(key, len);
8     return mop_install_simple_accessor(aTHX_ NULL /* anonymous */, pv, len, accessor_impl);
9 }
10
11 MODULE = Class::MOP::Method::Accessor   PACKAGE = Class::MOP::Method::Accessor
12
13 PROTOTYPES: DISABLE
14
15 BOOT:
16     INSTALL_SIMPLE_READER_WITH_KEY(Method::Accessor, associated_attribute, attribute);
17     INSTALL_SIMPLE_READER(Method::Accessor, accessor_type);
18
19
20 CV*
21 _generate_accessor_method_xs(SV* self)
22 CODE:
23     RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_accessor);
24 OUTPUT:
25     RETVAL
26
27 CV*
28 _generate_reader_method_xs(SV* self)
29 CODE:
30     RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_reader);
31 OUTPUT:
32     RETVAL
33
34 CV*
35 _generate_writer_method_xs(SV* self)
36 CODE:
37     RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_writer);
38 OUTPUT:
39     RETVAL
40
41 CV*
42 _generate_predicate_method_xs(SV* self)
43 CODE:
44     RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_predicate);
45 OUTPUT:
46     RETVAL
47
48 CV*
49 _generate_clearer_method_xs(SV* self)
50 CODE:
51     RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_clearer);
52 OUTPUT:
53     RETVAL
54