On Sat Jan 27 11:39:15 2007, [EMAIL PROTECTED] wrote: > This patch allows object vtable method overrides for find_method, get_attr, > get_attr, get_attr_str, set_attr, set_attr_str, and get_class. Now these > can be overridden in PIR using the :vtable flag or prefixing their > respective names with "__". It affects src/pmc/parrotobject.pmc and > src/ops/object.ops.
Thanks. The patch looks good. Could you also supply a regression test that demonstrates what was failing before the patch, and passes with the patch applied? Something along the lines of the attached patch, though I only spent a few minutes on it and expect you'll want to expand it. Allison
Index: t/pmc/object-meths.t =================================================================== --- t/pmc/object-meths.t (revision 17026) +++ t/pmc/object-meths.t (working copy) @@ -6,7 +6,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 38; +use Parrot::Test tests => 41; =head1 NAME @@ -1260,6 +1260,80 @@ init_pmc was called OUTPUT +pir_output_is( <<'CODE', <<'OUTPUT', "overloading find_method vtable" ); +.sub main :main + .local pmc cl, o + cl = newclass 'MyClass' + o = new 'MyClass' + o.'blue'() +.end + +.namespace ['MyClass'] + +.sub find_method :method :vtable + .param pmc methodname + print "find_method was called\n" +.end + +CODE +find_method was called +OUTPUT + +pir_output_is( <<'CODE', <<'OUTPUT', "overloading attribute accessor vtable" ); +.sub main :main + .local pmc cl, o + cl = newclass 'MyClass' + addattribute cl, 'blue' + o = new 'MyClass' + $P2 = new String + $P2 = "blue" + setattribute o, "blue", $P2 + $P1 = getattribute o, "blue" +.end + +.namespace ['MyClass'] + +.sub get_attr :method :vtable + .param pmc attrname + print "get_attr was called\n" +.end +.sub get_attr_str :method :vtable + .param pmc attrname + print "get_attr_str was called\n" +.end +.sub set_attr :method :vtable + .param pmc attrname + print "set_attr was called\n" +.end +.sub set_attr_str :method :vtable + .param pmc attrname + print "set_attr_str was called\n" +.end +CODE +get_attr was called +get_attr_str was called +set_attr was called +set_attr_str was called +OUTPUT + +pir_output_is( <<'CODE', <<'OUTPUT', "overloading get_class vtable" ); +.sub main :main + .local pmc cl, o + cl = newclass 'MyClass' + o = new 'MyClass' + o.'get_class'() +.end + +.namespace ['MyClass'] + +.sub get_class :method :vtable + print "get_class was called\n" +.end + +CODE +get_class was called +OUTPUT + # Local Variables: # mode: cperl # cperl-indent-level: 4