Skip to content

Commit 5b5b706

Browse files
committed
Add ops for setting/getting serialization context for an object.
1 parent decd296 commit 5b5b706

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/ops/nqp.ops

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,3 +706,38 @@ inline op nqp_set_sc_object(in STR, in INT, in PMC) :base_core {
706706
"Cannot fetch object from non-existance serialization context %Ss",
707707
$1);
708708
}
709+
710+
/*
711+
712+
=item nqp_set_sc_for_object()
713+
714+
Sets an object's serialization context.
715+
716+
=cut
717+
718+
*/
719+
inline op nqp_set_sc_for_object(in PMC, in PMC) :base_core {
720+
if ($1->vtable->base_type == ro_id)
721+
SC_PMC($1) = $2;
722+
else
723+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
724+
"Can only use nqp_set_sc_for_object with a RakudoObject");
725+
}
726+
727+
/*
728+
729+
=item nqp_get_sc_for_object()
730+
731+
Gets an object's serialization context. Returns NULL if there
732+
is none.
733+
734+
=cut
735+
736+
*/
737+
inline op nqp_get_sc_for_object(out PMC, in PMC) :base_core {
738+
if ($2->vtable->base_type == ro_id)
739+
$1 = SC_PMC($2);
740+
else
741+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
742+
"Can only use nqp_get_sc_for_object with a RakudoObject");
743+
}

0 commit comments

Comments
 (0)