Skip to content

Commit

Permalink
initial implementation of Exception clone, TT #1446
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@48597 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
NotFound committed Aug 22, 2010
1 parent 4ecdfc3 commit 14d6252
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
40 changes: 40 additions & 0 deletions src/pmc/exception.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,46 @@ Initializes the exception with supplied values.

/*

=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.
Expand Down
4 changes: 2 additions & 2 deletions t/pmc/exception.t
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ _handler:
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:
Expand Down

0 comments on commit 14d6252

Please sign in to comment.