Extending Tamarin notes

6 months ago malczak c++ tamarin comments

Just a quick note, without any clarification. The question is, how to call method that was overridden in Action Script code. Suppose Our object exposes to Action Script public method 'execute'. When You override this method Your additional code will not be executed.

Code below can be used to extract 'execute' method code from virtual methods table. Call is this way - additional code (from overridden function) is also included.

I don't know if this is the best solution :)

//AMV+ core object
AvmCore *core = thread->core();
Atom ret;

// method that we want to call is 'execute' and it 
//can be overridden by AS programmer    
Stringp name = core->internString(core->newConstantStringLatin1("execute") );
Binding bind = myInstance->traits()->getTraitsBindings()->findBinding( name );

if ( bind ){
    //get method from vtable
    MethodEnv *method = myInstance->vtable->methods[AvmCore::bindingToMethodId(bind)];
    Atom atomv_out[1] = { myInstance->atom() };

    //execute mothod's code
    ret = method->coerceEnter( 0, atomv_out );          
};
Share |

Comments

No comments as yet. Be first to comment.

New comment

  1. (never shown, just for us for possible contact)

  2. (with http or https prefix)

  3. (use [code][/code] tags to post a code snippet)

  4. (javascript is required)

Website content premeditately commited by segfaultlabs (malczak & sobstel).
Layout by mlando. Icons by DryIcons.com. All rights reserved, of course.