Skip to content

Instantiate an object of some class in native code #1148

Answered by phoddie
tve asked this question in Q&A
Discussion options

You must be logged in to vote

Instead of creating a global variable and then looking that up, is it possible to pass the constructor to native code and then call it there?

This is possible. It is a little strange though.

I understand that it isn't always desirable to store the constructor in a global. Another option is to store the constructor on the prototype of the object with the native function. That way the the native code can look it up. In your case, that would be something like AHS.prototype.Quaternion = Quaternion. Then you can use xsmcNew on xsThis and the xsID_Quaternion property. That approach avoids needing an intermediate JavaScript function between the caller and the native code to insert the construc…

Replies: 1 comment 18 replies

Comment options

You must be logged in to vote
18 replies
@tve
Comment options

@phoddie
Comment options

@tve
Comment options

@phoddie
Comment options

Answer selected by tve
@tve
Comment options

@phoddie
Comment options

@tve
Comment options

@phoddie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants