From: gfx Date: Tue, 21 Jul 2009 00:03:15 +0000 (+0900) Subject: Add xs accessors X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a53443d62e0757d4a332b5abdb53b809d289d4a2;p=gitmo%2FClass-MOP.git Add xs accessors --- diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index da4de78..65f9dd9 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -179,7 +179,7 @@ sub _set_initial_slot_value { #sub initializer { $_[0]->{'initializer'} } #sub definition_context { $_[0]->{'definition_context'} } #sub insertion_order { $_[0]->{'insertion_order'} } -sub _set_insertion_order { $_[0]->{'insertion_order'} = $_[1] } +#sub _set_insertion_order { $_[0]->{'insertion_order'} = $_[1] } # end bootstrapped away method section. # (all methods below here are kept intact) diff --git a/lib/Class/MOP/Method.pm b/lib/Class/MOP/Method.pm index 4f65c62..088c803 100644 --- a/lib/Class/MOP/Method.pm +++ b/lib/Class/MOP/Method.pm @@ -75,7 +75,7 @@ sub fully_qualified_name { #sub original_method { (shift)->{'original_method'} } -sub _set_original_method { $_[0]->{'original_method'} = $_[1] } +#sub _set_original_method { $_[0]->{'original_method'} = $_[1] } # It's possible that this could cause a loop if there is a circular # reference in here. That shouldn't ever happen in normal diff --git a/lib/Class/MOP/Method/Accessor.pm b/lib/Class/MOP/Method/Accessor.pm index f43770a..8d313c9 100644 --- a/lib/Class/MOP/Method/Accessor.pm +++ b/lib/Class/MOP/Method/Accessor.pm @@ -52,8 +52,8 @@ sub _new { ## accessors -sub associated_attribute { (shift)->{'attribute'} } -sub accessor_type { (shift)->{'accessor_type'} } +#sub associated_attribute { (shift)->{'attribute'} } +#sub accessor_type { (shift)->{'accessor_type'} } sub can_xs { diff --git a/mop.h b/mop.h index c7259c3..08b448e 100644 --- a/mop.h +++ b/mop.h @@ -26,6 +26,9 @@ CV* mop_install_simple_accessor(pTHX_ const char* const fq_name, const char* con #define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name) #define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) (void)mop_install_simple_accessor(aTHX_ "Class::MOP::" #klass "::" #name, #key, sizeof(#key)-1, mop_xs_simple_reader) +#define INSTALL_SIMPLE_WRITER(klass, name) INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, name) +#define INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, key) (void)mop_install_simple_accessor(aTHX_ "Class::MOP::" #klass "::" #name, #key, sizeof(#key)-1, mop_xs_simple_writer) + #define INSTALL_SIMPLE_PREDICATE(klass, name) INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, name) #define INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, key) (void)mop_install_simple_accessor(aTHX_ "Class::MOP::" #klass "::has_" #name, #key, sizeof(#key)-1, mop_xs_simple_predicate_for_metaclass) diff --git a/xs/Attribute.xs b/xs/Attribute.xs index 2083786..14f9940 100644 --- a/xs/Attribute.xs +++ b/xs/Attribute.xs @@ -19,6 +19,8 @@ BOOT: INSTALL_SIMPLE_READER(Attribute, insertion_order); INSTALL_SIMPLE_READER(Attribute, definition_context); + INSTALL_SIMPLE_WRITER_WITH_KEY(Attribute, _set_insertion_order, insertion_order); + INSTALL_SIMPLE_PREDICATE(Attribute, accessor); INSTALL_SIMPLE_PREDICATE(Attribute, reader); INSTALL_SIMPLE_PREDICATE(Attribute, writer); diff --git a/xs/Method.xs b/xs/Method.xs index 13dcf31..02a5f5c 100644 --- a/xs/Method.xs +++ b/xs/Method.xs @@ -10,3 +10,5 @@ BOOT: INSTALL_SIMPLE_READER(Method, body); INSTALL_SIMPLE_READER(Method, associated_metaclass); INSTALL_SIMPLE_READER(Method, original_method); + + INSTALL_SIMPLE_WRITER_WITH_KEY(Method, _set_original_method, original_method);