Questions related to Native method implementations

Steven Johnson stejohns at
Mon Jun 9 17:17:01 PDT 2008

Definitely. The patch there hasn't been pushed yet but hopefully will be
within a day or two. In TT there is substantive benefit to doing as much
work as practical in AS itself, rather than native code -- so much so that
we are hoping to avoid to providing a hosting API for constructing objects
directly from C/C++.

On 6/9/08 5:13 PM, "Mark Hammond" <mhammond at> wrote:

> The best I can do is point you at the 'axscript' directory in the
> tamarin-central branch.  Similarly to what Par said, the approach axscript
> takes is to implement the native objects, but have them instantiated from
> script code, not from C++ code.  In axscript's case, it assumes that some
> bootstrap script code has created an object called 'engine', and the C++
> code gets that object from the global object, and using other C++ APIs,
> arranges to call (script implemented) methods on that object.  That script
> code in turn interacts with the natively implemented objects.  Using
> top-level script functions would probably work just as well as my "object
> oriented" approach, which was chosen to mirror the underlying API I was
> implementing using Tamarin.
> I believe some of this will need to change for TT though - see bug
> for details.
> Cheers,
> Mark
> --------------------------------------------------------------
> From: tamarin-devel-bounces at
> [mailto:tamarin-devel-bounces at] On Behalf Of Kelkar, Anand
> Sent: Tuesday, 10 June 2008 8:30 AM
> To: tamarin-devel at
> Subject: Questions related to Native method implementations
> Hello,
> I created my AS class and defined some native methods and implemented them
> in C++. If I use that class in AS and instantiate it and call methods my
> code in C++ is executed properly.
> Now I want to how to create an instance of that AS class from C++ side. So I
> think I know the steps but not sure how to do it.
> - I will first have to find classclosure for my AS class in my domain
> environment
> - Use that classclosure to create a new object of type subclass of
> ScriptObject
> - Find method I want to call inside ScriptObject
> - Execute that method
> I tried looking in tamarin-devel archives and found one thread related to
> this
> ³how to add my own objects?   Mark Hammond
> But it does not have the full answer to my questions about how to
> instantiate as AS class (which has native methods implemented in C++) from
> C++.
> Can somebody help me with this.
> Thanks
> Anand
> P.S. I also have some other questions related to this which I sent sometime
> back to a wrong address, I guess.
> From: Kelkar, Anand
> Sent: Friday, May 30, 2008 3:19 PM
> To: 'tamarin-devel at'
> Subject: Questions related to Native method implementations
> Hello,
> I am trying to implement few methods of a sample AS3.0 class as native
> methods. In that process I am able to use macros like BEGIN_NATIVE_MAP and
> define C++ impmentations for the native methods. Also able to build the
> AS3.0 class and generate header file defining all constatnts related to
> class, methods name etc and map AS3.0 class with my C++ class.  I am also
> hitting the code inside my native C++ methods when functions are called on
> object of that AS3.0 class. But I have comple of questions related to
> implementations of native methods.
> - How to interpret arguments passed to native member functions of classes
> that we have added?  Especially if those are not native like boolean,
> string, ints etc. How to interpret Œobject¹ type parameters?
> - How to return a valid data type from a native function which is not a
> simple data type like int, bool etc?
> - How to map/interpret AS3.0 class member properties defined inside AS class
> definition to member variables inside C++ class that is used to implement
> native methods?
> - Is it possible to access other AS3.0 class static members like constants
> from C++.
> Are there any good examples of such implementations. I tried looking mostly
> at StringBuilder, ByteArray implementations in avmshell but most of them
> have native parameters such as int, bool, string etc.
> Thanks in advance.
> Anand
> _______________________________________________
> Tamarin-devel mailing list
> Tamarin-devel at

More information about the Tamarin-devel mailing list