# New Ticket Created by Patrick R. Michaud
# Please include the string: [perl #37430]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37430 >
In r9445 Leo added code to special-case the get_*_keyed_int
and set_*_keyed_int methods for parrot objects.
This patch adds support for delete_keyed_int (needed for PGE),
as well as updating the corresponding test in t/pmc/object_meths.t .
Pm
Index: classes/parrotobject.pmc
===================================================================
--- classes/parrotobject.pmc (revision 9474)
+++ classes/parrotobject.pmc (working copy)
@@ -189,8 +189,10 @@
=item C<void set_pmc_keyed_int (INTVAL key, PMC* value)>
-These methods have default implmentations in F<classes/default.pmc>
-which redirct to PMC keys. Test if a specialized method exists, else
+=item C<void delete_keyed_int(INTVAL key)>
+
+These methods have default implementations in F<classes/default.pmc>
+which redirect to PMC keys. Test if a specialized method exists, else
use fallback.
=cut
@@ -285,6 +287,17 @@
SUPER(key, value);
}
+ void delete_keyed_int (INTVAL key) {
+ STRING *meth = CONST_STRING(interpreter, "__delete_keyed_int");
+ PMC *sub = find_meth(interpreter, pmc, meth);
+ if (sub) {
+ (void) Parrot_run_meth_fromc_args(interpreter, sub,
+ pmc, meth, "vI", key);
+ }
+ else
+ SUPER(key);
+ }
+
/*
=item C<void visit(visit_info *info)>
Index: t/pmc/object-meths.t
===================================================================
--- t/pmc/object-meths.t (revision 9474)
+++ t/pmc/object-meths.t (working copy)
@@ -1019,6 +1019,8 @@
$S0 = "foo"
o[$I0] = 42
o[$S0] = 42
+ delete o[$I0]
+ delete o[$S0]
.end
.namespace ["MyClass"]
@@ -1035,9 +1037,21 @@
print "skey\n"
.end
+.sub __delete_keyed_int :method
+ .param int key
+ print "del_ikey\n"
+.end
+
+.sub __delete_keyed :method
+ .param string key
+ print "del_skey\n"
+.end
+
CODE
ikey
skey
+del_ikey
+del_skey
OUTPUT
pir_output_is(<<'CODE', <<'OUTPUT', "delegate keyed_int PMC derived");