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

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sat Feb 20 20:07:19 UTC 2010


Author: whiteknight
Date: Sat Feb 20 20:07:17 2010
New Revision: 44247
URL: https://trac.parrot.org/parrot/changeset/44247

Log:
cleanup some EXTREMELY old syntax from ParrotInterpreter and ParrotThread to create METHODs. Use the preferred syntax for creating methods instead. all tests pass with this.

Modified:
   trunk/src/pmc/parrotinterpreter.pmc
   trunk/src/pmc/parrotthread.pmc

Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc	Sat Feb 20 19:54:16 2010	(r44246)
+++ trunk/src/pmc/parrotinterpreter.pmc	Sat Feb 20 20:07:17 2010	(r44247)
@@ -176,16 +176,6 @@
     new_interp->current_cont = NEED_CONTINUATION;
 }
 
-static int
-recursion_limit(PARROT_INTERP, PMC *self, int l)
-{
-    const int ret           = interp->recursion_limit;
-    UNUSED(self)
-
-    interp->recursion_limit = l;
-    return ret;
-}
-
 pmclass ParrotInterpreter no_ro {
     ATTR struct parrot_interp_t *interp; /* this PMC's interpreter */
     ATTR INTVAL                  tid;    /* thread id */
@@ -200,24 +190,28 @@
 
 =over 4
 
-=item C<void class_init()>
+=item C<yield>
+
+Yield the current thread
 
-Class initialization.
+=item C<recursion_limit(INTVAL l :optional)
+
+Gets the recursion limit of the interpreter, optionally setting it to something
+new.
 
 =cut
 
 */
 
-    void class_init() {
-        const int typ = enum_class_ParrotInterpreter;
-
-        /* TODO unify and fix signatures */
-        register_nci_method(INTERP, typ,
-                F2DPTR(pt_thread_yield), "yield", "v");
+    METHOD yield() {
+        pt_thread_yield();
+    }
 
-        /* misc functions */
-        register_nci_method(INTERP, typ,
-                F2DPTR(recursion_limit), "recursion_limit", "iJOi");
+    METHOD recursion_limit(INTVAL l :optional, INTVAL has_l :opt_flag) {
+        const INTVAL ret = INTERP->recursion_limit;
+        if (has_l)
+            INTERP->recursion_limit = l;
+        RETURN(INTVAL ret);
     }
 
 /*

Modified: trunk/src/pmc/parrotthread.pmc
==============================================================================
--- trunk/src/pmc/parrotthread.pmc	Sat Feb 20 19:54:16 2010	(r44246)
+++ trunk/src/pmc/parrotthread.pmc	Sat Feb 20 20:07:17 2010	(r44247)
@@ -79,12 +79,6 @@
     return tid;
 }
 
-static INTVAL do_thread_run_clone_default(PARROT_INTERP,
-                                          PMC *thread, PMC *sub, PMC *args) {
-    return do_thread_run(interp, thread, PARROT_CLONE_DEFAULT, sub, args);
-}
-
-
 pmclass ParrotThread extends ParrotInterpreter no_ro {
 
 /*
@@ -103,17 +97,17 @@
 
 */
 
-    void class_init() {
-        const int typ = enum_class_ParrotThread;
-
-        register_nci_method(INTERP, typ,
-                F2DPTR(do_thread_run), "run", "IJOIP@");
+    METHOD run(INTVAL clone_flags, PMC *sub, PMC *args :slurpy) {
+        const INTVAL retval = do_thread_run(INTERP, SELF, clone_flags, sub, args);
+        RETURN(INTVAL retval);
+    }
 
-        /* XXX appropriate name given that this won't clone globals? */
-        register_nci_method(INTERP, typ,
-                F2DPTR(do_thread_run_clone_default), "run_clone", "IJOP@");
+    METHOD run_clone(PMC *sub, PMC *args :slurpy) {
+        const INTVAL retval = do_thread_run(INTERP, SELF, PARROT_CLONE_DEFAULT, sub, args);
+        RETURN(INTVAL retval)
     }
 
+
 /*
 
 =item C<void init()>


More information about the parrot-commits mailing list