-
I'd like a native code function to return an object of a given class and I'm coming up a bit short on how to accomplish that. I'd really appreciate a little example or some pointers. I have the following class in
The scale function is not important, I just wanted to have a member function there. I have the following JS portion of a native module:
The first function Here's modTest.c:
The question now is:
Where I'm stuck:
Help appreciated! I'm attaching a complete project, run with That project has an extra native function that returns a created ArrayBuffer. Ideally I'd like to return a Float64Array based on that buffer instead, I hope doing that will be very similar to the Vec3 stuff above. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 18 replies
-
I'm not sure I understand what you mean, but I have some suggestions for you to get the values : ` scale(n) { const $vec3 = new Vec3( trace(JSON.stringify($vec3)) |
Beta Was this translation helpful? Give feedback.
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 usexsmcNew
onxsThis
and thexsID_Quaternion
property. That approach avoids needing an intermediate JavaScript function between the caller and the native code to insert the construc…