Extending Tamarin notes

over 2 years 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 :)

 1 //AMV+ core object
 2 AvmCore *core = thread->core();
 3 Atom ret;
 4 
 5 // method that we want to call is 'execute' and it 
 6 //can be overridden by AS programmer    
 7 Stringp name = core->internString(core->newConstantStringLatin1("execute") );
 8 Binding bind = myInstance->traits()->getTraitsBindings()->findBinding( name );
 9 
10 if ( bind ){
11     //get method from vtable
12     MethodEnv *method = myInstance->vtable->methods[AvmCore::bindingToMethodId(bind)];
13     Atom atomv_out[1] = { myInstance->atom() };
14 
15     //execute mothod's code
16     ret = method->coerceEnter( 0, atomv_out );          
17 };

Comments

No comments as yet. Be first to comment.

New comment

  1. (with http or https prefix)

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

  3. (javascript is required)

Website content premeditately commited by malczak & sobstel.
Layout by mlando. Icons by dryicons.com. All rights reserved.