From: gfx Date: Sun, 1 Nov 2009 02:56:38 +0000 (+0900) Subject: Use shortnames for mouse_instance_* X-Git-Tag: 0.40_04~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fe2272b04003d989c299dae495c4c6f9730dabc;p=gitmo%2FMouse.git Use shortnames for mouse_instance_* --- diff --git a/mouse.h b/mouse.h index 2b75762..9974f81 100644 --- a/mouse.h +++ b/mouse.h @@ -104,10 +104,12 @@ void mouse_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot); #define has_slot(self, key) mouse_instance_has_slot(aTHX_ self, key) #define get_slot(self, key) mouse_instance_get_slot(aTHX_ self, key) #define set_slot(self, key, value) mouse_instance_set_slot(aTHX_ self, key, value) +#define delete_slot(self, key) mouse_instance_delete_slot(aTHX_ self, key) +#define weaken_slot(self, key) mouse_instance_weaken_slot(aTHX_ self, key) -#define has_slots(self, key) mouse_instance_has_slot(aTHX_ self, sv_2mortal(newSVpvs_share(key))) -#define get_slots(self, key) mouse_instance_get_slot(aTHX_ self, sv_2mortal(newSVpvs_share(key))) -#define set_slots(self, key, value) mouse_instance_set_slot(aTHX_ self, sv_2mortal(newSVpvs_share(key)), value) +#define has_slots(self, key) has_slot(self, sv_2mortal(newSVpvs_share(key))) +#define get_slots(self, key) get_slot(self, sv_2mortal(newSVpvs_share(key))) +#define set_slots(self, key, value) set_slot(self, sv_2mortal(newSVpvs_share(key)), value) /* mouse_simle_accessor.xs */ #define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name) diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 993c1c7..451e9f4 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -31,7 +31,7 @@ HV* namespace(SV* self) CODE: { - SV* const package = mouse_instance_get_slot(aTHX_ self, mouse_package); + SV* const package = get_slot(aTHX_ self, mouse_package); if(!(package && SvOK(package))){ croak("No package name defined"); } @@ -45,8 +45,8 @@ void add_method(SV* self, SV* name, SV* code, ...) CODE: { - SV* const package = mouse_instance_get_slot(aTHX_ self, mouse_package); /* $self->{package} */ - SV* const methods = mouse_instance_get_slot(aTHX_ self, mouse_methods); /* $self->{methods} */ + SV* const package = get_slot(aTHX_ self, mouse_package); /* $self->{package} */ + SV* const methods = get_slot(aTHX_ self, mouse_methods); /* $self->{methods} */ GV* gv; SV* code_ref; @@ -83,7 +83,7 @@ CODE: } sv_setsv_mg((SV*)gv, code_ref); /* *gv = $code_ref */ - mouse_instance_set_slot(aTHX_ methods, name, code); /* $self->{methods}{$name} = $code */ + set_slot(methods, name, code); /* $self->{methods}{$name} = $code */ /* TODO: name the CODE ref if it's anonymous */ //code_entity = (CV*)SvRV(code_ref); diff --git a/xs-src/MouseAccessor.xs b/xs-src/MouseAccessor.xs index 6af6b03..dd89a00 100644 --- a/xs-src/MouseAccessor.xs +++ b/xs-src/MouseAccessor.xs @@ -246,7 +246,7 @@ mouse_attr_get(pTHX_ SV* const self, MAGIC* const mg){ SV* const slot = MOUSE_mg_slot(mg); SV* value; - value = mouse_instance_get_slot(aTHX_ self, slot); + value = get_slot(self, slot); /* check_lazy */ if( !value && flags & MOUSEf_ATTR_IS_LAZY ){ @@ -276,7 +276,7 @@ mouse_attr_get(pTHX_ SV* const self, MAGIC* const mg){ } /* store value to slot */ - value = mouse_instance_set_slot(aTHX_ self, slot, value); + value = set_slot(self, slot, value); } PUSH_VALUE(value, flags); @@ -291,10 +291,10 @@ mouse_attr_set(pTHX_ SV* const self, MAGIC* const mg, SV* value){ value = mouse_apply_type_constraint(aTHX_ MOUSE_mg_xa(mg), value, flags); } - mouse_instance_set_slot(aTHX_ self, slot, value); + set_slot(self, slot, value); if(flags & MOUSEf_ATTR_IS_WEAK_REF){ - mouse_instance_weaken_slot(aTHX_ self, slot); + weaken_slot(self, slot); } if(flags & MOUSEf_ATTR_HAS_TRIGGER){ @@ -412,7 +412,7 @@ XS(mouse_xs_simple_reader) croak("Expected exactly one argument for a reader for '%"SVf"'", slot); } - value = mouse_instance_get_slot(aTHX_ self, slot); + value = get_slot(self, slot); ST(0) = value ? value : &PL_sv_undef; XSRETURN(1); } @@ -428,7 +428,7 @@ XS(mouse_xs_simple_writer) croak("Expected exactly two argument for a writer for '%"SVf"'", slot); } - ST(0) = mouse_instance_set_slot(aTHX_ self, slot, ST(1)); + ST(0) = set_slot(self, slot, ST(1)); XSRETURN(1); } @@ -443,7 +443,7 @@ XS(mouse_xs_simple_clearer) croak("Expected exactly one argument for a clearer for '%"SVf"'", slot); } - value = mouse_instance_delete_slot(aTHX_ self, slot); + value = delete_slot(self, slot); ST(0) = value ? value : &PL_sv_undef; XSRETURN(1); } @@ -458,7 +458,7 @@ XS(mouse_xs_simple_predicate) croak("Expected exactly one argument for a predicate for '%"SVf"'", slot); } - ST(0) = boolSV( mouse_instance_has_slot(aTHX_ self, slot) ); + ST(0) = boolSV( has_slot(self, slot) ); XSRETURN(1); }