develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33673 - trunk/src/pmc

From:
jonathan
Date:
December 8, 2008 15:58
Subject:
[svn:parrot] r33673 - trunk/src/pmc
Message ID:
20081208235829.155ADCB9AF@x12.develooper.com
Author: jonathan
Date: Mon Dec  8 15:58:28 2008
New Revision: 33673

Modified:
   trunk/src/pmc/role.pmc

Log:
[core] Implement remove_method on roles.

Modified: trunk/src/pmc/role.pmc
==============================================================================
--- trunk/src/pmc/role.pmc	(original)
+++ trunk/src/pmc/role.pmc	Mon Dec  8 15:58:28 2008
@@ -336,6 +336,24 @@
         }
     }
 
+/*
+
+=item C<void remove_method(STRING *name, PMC *sub)>
+
+Removes the method with the given name.
+
+=cut
+
+*/
+    VTABLE void remove_method(STRING *name) {
+        Parrot_Role_attributes * const role = PARROT_ROLE(SELF);
+        if (VTABLE_exists_keyed_str(interp, role->methods, name))
+            VTABLE_delete_keyed_str(interp, role->methods, name);
+        else
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "No method named '%S' to remove in role '%S'.",
+                name, VTABLE_get_string(interp, SELF));
+    }
 
 /*
 
@@ -665,6 +683,20 @@
         VTABLE_add_method(interp, SELF, name, sub);
     }
 
+/*
+
+=item C<void remove_method(STRING *name)>
+
+Removes the method with the given name.
+
+=cut
+
+*/
+    METHOD remove_method(STRING *name)
+    {
+        VTABLE_remove_method(interp, SELF, name);
+    }
+
 
 /*
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About