emscripten::val - Unable to call function inside property of object

23 views
Skip to first unread message

gerald-dotcom

unread,
May 18, 2020, 7:23:05 AM5/18/20
to emscripten-discuss

I have Global JavaScript object structured like below,


foo Object
> gee property
>> nee() function
>> zee() function


I used two possible ways to call the nee function, see below,


1 Method

emscripten::val::global("foo").call<void>("gee.nee");

2 Method

emscripten::val::global("foo['gee']").call<void>("nee");


However, none of these working at all instead output errors, see below,

1 Method Output

TypeError: handle[name] is not a function

2 Method Output

TypeError: Cannot read property 'nee' of undefined,TypeError: Cannot read property 'nee' of undefined


I was able to do Object Key based verification through emscripten::val of the Object and can confirm both Object and Property are in Global Scope.

Even though, I was not able to run Object Keys through emscripten::val to grab the functions inside gee Property.

But using Client Side JS, I was able to run Object Keys to grab functions inside gee Property.


I can call same Function through EM_JS but it's not suitable for my project for some obvious reasons.


So, I would like to hear the right way to call this function through emscripten::val?

キャロウ マーク

unread,
May 18, 2020, 1:44:03 PM5/18/20
to emscripten-discuss


On May 18, 2020, at 4:23, gerald-dotcom <wregr...@gmail.com> wrote:

I have Global JavaScript object structured like below,


foo Object
> gee property
>> nee() function
>> zee() function


I used two possible ways to call the nee function, see below,


1 Method

emscripten::val::global("foo").call<void>("gee.nee");

2 Method

emscripten::val::global("foo['gee']").call<void>("nee");




May be val::global(“foo")[“gee”].call<void>[“nee”]; Something like that works for me  to fetch something from the module using val::module_property, absent the “call<void>”.

I could be completely wrong. As my questions to this group, so far sadly unanswered, show there’s a lot I still don’t understand about embind and webidl_binder.

Regards

    -Mark


signature.asc

gerald-dotcom

unread,
May 19, 2020, 11:45:28 AM5/19/20
to emscripten-discuss
It works. 
Reply all
Reply to author
Forward
0 new messages