Mutual calls between js and c ++ in jsb

Source: Internet
Author: User


Declare the function in c ++, named functionCpp, through the jsapi in spidermonkey
JS_DefineFunction of is bound to a js function named functionJS. This function name

2. c ++ calls js Functions
Declare the function in js, named functionJS, through the jsapi in spidermonkey
JS_CallFunctoionName (JS_CallFunction is also available, but the parameters are different ),

Haha = testjs ("js run hahhahaha" "return from c ++: true" "false" testfunction = testhaha = "return from js"

 

JSBool testjs (JSContext * cx, uint32_t argc, jsval * (argc> * =, & (CCLog (wrapper.

 

 

CCScriptEngineProtocol * pEngine =-> runScript (* cx = SC-> * obj = SC->, testjs, JSPROP_READONLY | = c_string_to_jsval (cx, & var1, & * pS = JS_ValueToString (ScriptingCore: getInstance ()-> (). c_str ());

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.