Questions related to Native method implementations

Par Winzell zell at threerings.net
Mon Jun 9 15:53:27 PDT 2008


I am not a Tamarin developer, but -- in my own dabblings, I have always 
tried to move as much complexity as possible into AS3. In your case, why 
not create the new instance from a non-native static method? Then your 
problem is reduced to finding the class, finding the static method in 
it, and calling it.

I have some code that does this, but most likely not the most elegant 
way. I can post it if nobody more qualified beats me to it. :)

Zell


Kelkar, Anand wrote:
> 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? 
> <https://mail.mozilla.org/pipermail/tamarin-devel/2007-August/000020.html>  
> /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 mozilla.org'
> *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 mozilla.org
> https://mail.mozilla.org/listinfo/tamarin-devel



More information about the Tamarin-devel mailing list