Skip to content

Commit

Permalink
Implement Capture.freeze/thaw. Closes #2047
Browse files Browse the repository at this point in the history
  • Loading branch information
bacek committed Mar 11, 2011
1 parent 492de04 commit cdecdf8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/pmc/capture.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,34 @@ Mark the array.

/*

=item C<void freeze()>

=item C<void thaw()>

Freeze/thaw Capture

=cut

*/

VTABLE void freeze(PMC *info) {
PMC *array, *hash;
GET_ATTR_array(INTERP, SELF, array);
GET_ATTR_hash(INTERP, SELF, hash);

VTABLE_push_pmc(INTERP, info, array);
VTABLE_push_pmc(INTERP, info, hash);
}

VTABLE void thaw(PMC *info) {
PMC *tmp;
tmp = VTABLE_shift_pmc(INTERP, info);
SET_ATTR_array(INTERP, SELF, tmp);
tmp = VTABLE_shift_pmc(INTERP, info);
SET_ATTR_hash(INTERP, SELF, tmp);
}
/*

=back

=head2 Methods
Expand Down
4 changes: 2 additions & 2 deletions t/pmc/capture.t
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ a variety of keys and values.
$P0 = thaw $S1

$S0 = $P0["foo"]
"is"($S0, "foo", "Hash thawed", "todo" => "TT #2047")
"is"($S0, "foo", "Hash thawed")
$S0 = $P0[0]
"is"($S0, "bar", "Array thawed", "todo" => "TT #2047")
"is"($S0, "bar", "Array thawed")
.end

# Local Variables:
Expand Down

0 comments on commit cdecdf8

Please sign in to comment.