#1262: Simple patch for the overriding of invoke for objects
----------------------+-----------------------------------------------------
 Reporter:  NotFound  |       Owner:       
     Type:  patch     |      Status:  new  
 Priority:  normal    |   Milestone:       
Component:  none      |     Version:  1.7.0
 Severity:  medium    |    Keywords:       
     Lang:            |       Patch:       
 Platform:            |  
----------------------+-----------------------------------------------------
 This simple change makes object() works as expected for the short test
 case I tried:

 {{{
 Index: src/pmc/object.pmc
 ===================================================================
 --- src/pmc/object.pmc  (revision 42404)
 +++ src/pmc/object.pmc  (working copy)
 @@ -616,8 +616,11 @@
              PMC * const meth =
                  Parrot_oo_find_vtable_override_for_class(interp,
 cur_class,
                                                           meth_name);
 -            if (!PMC_IS_NULL(meth))
 +            if (!PMC_IS_NULL(meth)) {
 +                PMC *call_sig = Parrot_pcc_get_signature(interp,
 CURRENT_CONTEXT(interp));
 +                VTABLE_unshift_pmc(interp, call_sig, SELF);
                  return VTABLE_invoke(interp, meth, next);
 +           }

              if (cur_class->vtable->base_type == enum_class_PMCProxy) {
                  /* Get the PMC instance and call the vtable method on
 that. */
 }}}

 This is the test:

 {{{
 .sub main :main
   $P0 = newclass ['myobj']
   addattribute $P0, 'name'
   $P1 = new $P0
   $P3 = new 'String'
   $P3 = 'world'
   setattribute $P1, 'name', $P3
   $P1()
 .end

 .namespace ['myobj']

 .sub hello :method
   print 'hello, '
   $P1 = getattribute self, 'name'
   say $P1
 .end

 .sub 'invoke' :vtable
   self.'hello'()
 .end
 }}}

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/1262>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to