Add xs accessors
gfx [Tue, 21 Jul 2009 00:03:15 +0000 (09:03 +0900)]
lib/Class/MOP/Attribute.pm
lib/Class/MOP/Method.pm
lib/Class/MOP/Method/Accessor.pm
mop.h
xs/Attribute.xs
xs/Method.xs

index da4de78..65f9dd9 100644 (file)
@@ -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)
index 4f65c62..088c803 100644 (file)
@@ -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
index f43770a..8d313c9 100644 (file)
@@ -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 (file)
--- 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)
 
index 2083786..14f9940 100644 (file)
@@ -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);
index 13dcf31..02a5f5c 100644 (file)
@@ -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);