[svn:parrot] r48597 - in trunk: src/pmc t/pmc

NotFound at svn.parrot.org NotFound at svn.parrot.org
Sun Aug 22 22:03:04 UTC 2010


Author: NotFound
Date: Sun Aug 22 22:03:03 2010
New Revision: 48597
URL: https://trac.parrot.org/parrot/changeset/48597

Log:
initial implementation of Exception clone, TT #1446

Modified:
   trunk/src/pmc/exception.pmc
   trunk/t/pmc/exception.t

Modified: trunk/src/pmc/exception.pmc
==============================================================================
--- trunk/src/pmc/exception.pmc	Sun Aug 22 14:58:51 2010	(r48596)
+++ trunk/src/pmc/exception.pmc	Sun Aug 22 22:03:03 2010	(r48597)
@@ -166,6 +166,46 @@
 
 /*
 
+=item C<PMC *clone()>
+
+Create a copy of the Exception.
+
+Copy only the user supplied values, not the throwing and handling
+information.
+
+=cut
+
+*/
+
+    VTABLE PMC *clone() {
+        PMC * const dest = Parrot_pmc_new(INTERP, SELF->vtable->base_type);
+        INTVAL   id;
+        STRING   *message;
+        PMC      *payload;
+        INTVAL   severity;
+        INTVAL   type;
+        INTVAL   exit_code;
+        GET_ATTR_id(INTERP, SELF, id);
+        SET_ATTR_id(INTERP, dest, id);
+        GET_ATTR_message(INTERP, SELF, message);
+        SET_ATTR_message(INTERP, dest, message);
+        GET_ATTR_severity(INTERP, SELF, severity);
+        SET_ATTR_severity(INTERP, dest, severity);
+        GET_ATTR_type(INTERP, SELF, type);
+        SET_ATTR_type(INTERP, dest, type);
+        GET_ATTR_exit_code(INTERP, SELF, exit_code);
+        SET_ATTR_exit_code(INTERP, dest, exit_code);
+
+        GET_ATTR_payload(INTERP, SELF, payload);
+        if (!PMC_IS_NULL(payload)) {
+            payload = VTABLE_clone(INTERP, payload);
+            SET_ATTR_payload(INTERP, dest, payload);
+        }
+        return dest;
+    }
+
+/*
+
 =item C<void mark()>
 
 Mark any active exception data as live.

Modified: trunk/t/pmc/exception.t
==============================================================================
--- trunk/t/pmc/exception.t	Sun Aug 22 14:58:51 2010	(r48596)
+++ trunk/t/pmc/exception.t	Sun Aug 22 22:03:03 2010	(r48597)
@@ -194,8 +194,8 @@
   catch:
     result = 1
   catchall:
-    # TT #1446
-    todo(result, 1, 'caught a cloned Exception')
+    # TT #1446 - need more tests
+    is(result, 1, 'caught a cloned Exception')
 .end
 
 # Local Variables:


More information about the parrot-commits mailing list