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);
+    }
+
 
 /*
 

Reply via email to