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 11a9a17..27fe3be 100644 (file)
@@ -183,7 +183,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 6481f03..33f5efb 100644 (file)
@@ -87,7 +87,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 20daad6..626fa83 100644 (file)
@@ -69,8 +69,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);