#define set_slots(self, key, value) set_slot(self, sv_2mortal(newSVpvs_share(key)), value)
/* mouse_simle_accessor.xs */
-#define INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTSV(klass, name, dsv) \
- (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #name, sizeof(#name)-1, XS_Mouse_simple_accessor, (dsv), HEf_SVKEY)
-#define INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(klass, name, ds) \
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTSV(klass, name, newSVpvs(ds))
-
#define INSTALL_SIMPLE_READER(klass, name) \
INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name)
#define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) \
(void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_reader, NULL, 0)
+#define INSTALL_SIMPLE_READER_WITH_DEFAULTSV(klass, name, dsv) \
+ (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #name, sizeof(#name)-1, XS_Mouse_simple_reader, (dsv), HEf_SVKEY)
+#define INSTALL_SIMPLE_READER_WITH_DEFAULTS(klass, name, ds) \
+ INSTALL_SIMPLE_READER_WITH_DEFAULTSV(klass, name, newSVpvs(ds))
+
#define INSTALL_SIMPLE_WRITER(klass, name) \
NSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, name)
#define INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, key) \
INSTALL_SIMPLE_READER(Class, roles);
INSTALL_SIMPLE_PREDICATE_WITH_KEY(Class, is_anon_class, anon_serial_id);
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Class, method_metaclass, "Mouse::Meta::Method");
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Class, attribute_metaclass, "Mouse::Meta::Attribute");
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Class, constructor_class, "Mouse::Meta::Method::Constructor::XS");
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Class, destructor_class, "Mouse::Meta::Method::Destructor::XS");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Class, method_metaclass, "Mouse::Meta::Method");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Class, attribute_metaclass, "Mouse::Meta::Attribute");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Class, constructor_class, "Mouse::Meta::Method::Constructor::XS");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Class, destructor_class, "Mouse::Meta::Method::Destructor::XS");
newCONSTSUB(gv_stashpvs("Mouse::Meta::Method::Constructor::XS", TRUE), "_generate_constructor",
newRV_inc((SV*)get_cvs("Mouse::Object::new", TRUE)));
INSTALL_SIMPLE_READER_WITH_KEY(Role, get_roles, roles);
INSTALL_SIMPLE_PREDICATE_WITH_KEY(Role, is_anon_role, anon_serial_id);
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Role, method_metaclass, "Mouse::Meta::Role::Method");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Role, method_metaclass, "Mouse::Meta::Role::Method");
MODULE = Mouse PACKAGE = Mouse::Object
if(items == 1){ /* reader */
value = get_slot(self, MOUSE_mg_slot(mg));
- if(!value) {
- if(MOUSE_mg_ptr(mg)){
- /* the default value must be a SV */
- assert(MOUSE_mg_len(mg) == HEf_SVKEY);
- value = (SV*)MOUSE_mg_ptr(mg);
- }
- else{
- value = &PL_sv_undef;
- }
+ if(!value){
+ value = &PL_sv_undef;
}
}
else if(items == 2){ /* writer */
}
value = get_slot(self, MOUSE_mg_slot(mg));
- ST(0) = value ? value : &PL_sv_undef;
+ if(!value) {
+ if(MOUSE_mg_ptr(mg)){
+ /* the default value must be a SV */
+ assert(MOUSE_mg_len(mg) == HEf_SVKEY);
+ value = (SV*)MOUSE_mg_ptr(mg);
+ }
+ else{
+ value = &PL_sv_undef;
+ }
+ }
+
+ ST(0) = value;
XSRETURN(1);
}
INSTALL_SIMPLE_PREDICATE_WITH_KEY(Attribute, has_builder, builder);
INSTALL_SIMPLE_PREDICATE_WITH_KEY(Attribute, has_documentation, documentation);
- INSTALL_SIMPLE_ACCESSOR_WITH_DEFAULTS(Attribute, accessor_metaclass, "Mouse::Meta::Method::Accessor::XS");
+ INSTALL_SIMPLE_READER_WITH_DEFAULTS(Attribute, accessor_metaclass, "Mouse::Meta::Method::Accessor::XS");