Merge master into topic/xs-attr-template
[gitmo/Class-MOP.git] / xs / MethodAccessor.xs
CommitLineData
a69b9501 1#include "mop.h"
2
3static CV*
4mop_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
11MODULE = Class::MOP::Method::Accessor PACKAGE = Class::MOP::Method::Accessor
12
13PROTOTYPES: DISABLE
14
15BOOT:
16 INSTALL_SIMPLE_READER_WITH_KEY(Method::Accessor, associated_attribute, attribute);
17 INSTALL_SIMPLE_READER(Method::Accessor, accessor_type);
18
19
20CV*
21_generate_accessor_method_xs(SV* self)
22CODE:
23 RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_accessor);
24OUTPUT:
25 RETVAL
26
27CV*
28_generate_reader_method_xs(SV* self)
29CODE:
30 RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_reader);
31OUTPUT:
32 RETVAL
33
34CV*
35_generate_writer_method_xs(SV* self)
36CODE:
37 RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_writer);
38OUTPUT:
39 RETVAL
40
41CV*
42_generate_predicate_method_xs(SV* self)
43CODE:
44 RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_predicate);
45OUTPUT:
46 RETVAL
47
48CV*
49_generate_clearer_method_xs(SV* self)
50CODE:
51 RETVAL = mop_instantiate_xs_accessor(aTHX_ self, mop_xs_simple_clearer);
52OUTPUT:
53 RETVAL
54