Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Jsb

Classes

class  ScriptingCore
 ScriptingCore is the main class which manages interaction with JavaScript environment. More...
 

Functions

static ScriptingCoregetInstance ()
 ScriptingCore is a singleton class, you can retrieve its instance with this function. More...
 
virtual cocos2d::ccScriptType getScriptType () override
 Gets the script type, for ScriptingCore, it will return cocos2d::kScriptTypeJavascript More...
 
local getScriptType ()
 Gets the script type, for ScriptingCore, it will return cocos2d::kScriptTypeJavascript More...
 
virtual void retainScriptObject (cocos2d::Ref *owner, cocos2d::Ref *target) override
 Reflect the retain relationship to script scope.
 
var retainScriptObject ( var owner, var target)
 Reflect the retain relationship to script scope.
 
local retainScriptObject ( local owner, local target)
 Reflect the retain relationship to script scope.
 
virtual void rootScriptObject (cocos2d::Ref *target) override
 Add the script object to root object.
 
virtual void releaseScriptObject (cocos2d::Ref *owner, cocos2d::Ref *target) override
 Reflect the release relationship to script scope.
 
var releaseScriptObject ( var owner, var target)
 Reflect the release relationship to script scope.
 
local releaseScriptObject ( local owner, local target)
 Reflect the release relationship to script scope.
 
virtual void unrootScriptObject (cocos2d::Ref *target) override
 Remove the script object from root object.
 
virtual void releaseAllChildrenRecursive (cocos2d::Node *node) override
 Release all children in script scope.
 
virtual void releaseAllNativeRefs (cocos2d::Ref *owner) override
 Release all native refs for the given owner in script scope.
 
local releaseAllNativeRefs ( local owner)
 Release all native refs for the given owner in script scope.
 
virtual void removeScriptObjectByObject (cocos2d::Ref *obj) override
 Removes the C++ object's linked JavaScript proxy object from JavaScript context. More...
 
virtual int executeString (const char *codes) override
 Useless in ScriptingCore, please use evalString. More...
 
void pauseSchedulesAndActions (js_proxy_t *p)
 Pause scheduled tasks and actions for an object proxy. More...
 
void resumeSchedulesAndActions (js_proxy_t *p)
 Resume scheduled tasks and actions for an object proxy. More...
 
void cleanupSchedulesAndActions (js_proxy_t *p)
 Cleanup scheduled tasks and actions for an object proxy. More...
 
virtual int executeScriptFile (const char *filename) override
 Useless in ScriptingCore, please use runScript. More...
 
virtual int executeGlobalFunction (const char *functionName) override
 Useless in ScriptingCore, please use executeFunctionWithOwner. More...
 
virtual int sendEvent (cocos2d::ScriptEvent *message) override
 When trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be nullptr in Lua.
 
virtual bool parseConfig (ConfigType type, const std::string &str) override
 Parse configuration file. More...
 
local parseConfig ( local type, local str)
 Parse configuration file. More...
 
virtual bool handleAssert (const char *msg) override
 Useless in ScriptingCore. More...
 
virtual void setCalledFromScript (bool callFromScript) override
 Useless for Lua.
 
virtual bool isCalledFromScript () override
 Useless for Lua.
 
bool executeFunctionWithObjectData (void *nativeObj, const char *name, JSObject *obj)
 Execute a js function with a JavaScript object as parameter. More...
 
bool executeFunctionWithOwner (jsval owner, const char *name, uint32_t argc, jsval *vp)
 Execute a js function with a JavaScript caller, function name, arguments count and arguments. More...
 
var executeFunctionWithOwner ( var owner, var name, var argc, var vp)
 Execute a js function with a JavaScript caller, function name, arguments count and arguments. More...
 
local executeFunctionWithOwner ( local owner, local name, local argc, local vp)
 Execute a js function with a JavaScript caller, function name, arguments count and arguments. More...
 
bool executeFunctionWithOwner (jsval owner, const char *name, uint32_t argc, jsval *vp, JS::MutableHandleValue retVal)
 Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value. More...
 
var executeFunctionWithOwner ( var owner, var name, var argc, var vp, var retVal)
 Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value. More...
 
local executeFunctionWithOwner ( local owner, local name, local argc, local vp, local retVal)
 Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value. More...
 
bool executeFunctionWithOwner (jsval owner, const char *name, const JS::HandleValueArray &args)
 Execute a js function with a JavaScript caller, function name, arguments array. More...
 
bool executeFunctionWithOwner (jsval owner, const char *name, const JS::HandleValueArray &args, JS::MutableHandleValue retVal)
 Execute a js function with a JavaScript caller, function name, arguments array and a return value. More...
 
void executeJSFunctionWithThisObj (JS::HandleValue thisObj, JS::HandleValue callback)
 Execute a js function with a js this object and the js function object. More...
 
void executeJSFunctionWithThisObj (JS::HandleValue thisObj, JS::HandleValue callback, const JS::HandleValueArray &vp, JS::MutableHandleValue retVal)
 Execute a js function with a js this object, the js function object, arguments and a return value. More...
 
bool evalString (const char *string, JS::MutableHandleValue outVal, const char *filename, JSContext *cx, JS::HandleObject global)
 Evaluate the specified js code string. More...
 
bool evalString (const char *string, JS::MutableHandleValue outVal)
 Evaluate the specified js code string. More...
 
bool evalString (const char *string)
 Evaluate the specified js code string. More...
 
JS::PersistentRootedScript * getScript (const std::string &path)
 Get script object for the given path. More...
 
local getScript ( local path)
 Get script object for the given path. More...
 
JS::PersistentRootedScript * compileScript (const std::string &path, JS::HandleObject global, JSContext *cx=nullptr)
 Compile the specified js file. More...
 
local compileScript ( local path, local global, local nullptr)
 Compile the specified js file. More...
 
bool runScript (const std::string &path)
 Run the specified js file. More...
 
bool runScript (const std::string &path, JS::HandleObject global, JSContext *cx=NULL)
 Run the specified js file. More...
 
local runScript ( local path, local global, local NULL)
 Run the specified js file. More...
 
bool requireScript (const char *path, JS::MutableHandleValue jsvalRet)
 Require the specified js file The difference between run and require is that require returns the export object of the script. More...
 
local requireScript ( local path, local jsvalRet)
 Require the specified js file The difference between run and require is that require returns the export object of the script. More...
 
bool requireScript (const char *path, JS::HandleObject global, JSContext *cx, JS::MutableHandleValue jsvalRet)
 Require the specified js file The difference between run and require is that require returns the export object of the script. More...
 
local requireScript ( local path, local global, local cx, local jsvalRet)
 Require the specified js file The difference between run and require is that require returns the export object of the script. More...
 
void cleanScript (const char *path)
 Clean script object for the specified js file. More...
 
std::unordered_map
< std::string,
JS::PersistentRootedScript * > & 
getFileScript ()
 Gets the cached script objects for all executed js file. More...
 
void cleanAllScript ()
 Clean all script objects.
 
std::chrono::steady_clock::time_point getEngineStartTime () const
 Gets the time that the ScriptingCore was initalized.
 
local getEngineStartTime ()
 Gets the time that the ScriptingCore was initalized.
 
void start ()
 Initialize everything, including the js context, js global object etc.
 
void cleanup ()
 Cleanup everything, including script cache, js context, global object etc.
 
void reset ()
 Cleanup everything then initialize everything.
 
void addRegisterCallback (sc_register_sth callback)
 Add the register_sth callback to the list of functions that need to be called after the creation of the context. More...
 
void createGlobalContext ()
 Create a new context. More...
 
static void removeAllRoots (JSContext *cx)
 Removes all rooted object in the given js context, rooted object won't be garbage collected. More...
 
int executeCustomTouchEvent (cocos2d::EventTouch::EventCode eventType, cocos2d::Touch *pTouch, JSObject *obj, JS::MutableHandleValue retval)
 Simulate a touch event and dispatch it to a js object. More...
 
int executeCustomTouchEvent (cocos2d::EventTouch::EventCode eventType, cocos2d::Touch *pTouch, JSObject *obj)
 Simulate a touch event and dispatch it to a js object. More...
 
int executeCustomTouchesEvent (cocos2d::EventTouch::EventCode eventType, const std::vector< cocos2d::Touch * > &touches, JSObject *obj)
 Simulate a multi touch event and dispatch it to a js object. More...
 
JSContext * getGlobalContext ()
 Gets the current global context. More...
 
static void reportError (JSContext *cx, const char *message, JSErrorReport *report)
 Report an error in the js context. More...
 
var reportError ( var cx, var message, var report)
 Report an error in the js context. More...
 
local reportError ( local cx, local message, local report)
 Report an error in the js context. More...
 
static bool log (JSContext *cx, uint32_t argc, jsval *vp)
 Log something to the js context using CCLog. More...
 
bool setReservedSpot (uint32_t i, JSObject *obj, jsval value)
 Sets a js value to the targeted js object's reserved slot, which is not exposed to script environment. More...
 
static bool executeScript (JSContext *cx, uint32_t argc, jsval *vp)
 Runs a script from script environment, it should be invoked from script environment Bound to __jsc__.executeScript and window.executeScript More...
 
local executeScript ( local cx, local argc, local vp)
 Runs a script from script environment, it should be invoked from script environment Bound to __jsc__.executeScript and window.executeScript More...
 
static bool forceGC (JSContext *cx, uint32_t argc, jsval *vp)
 Forces a cycle of garbage collection, it should be invoked from script environment Bound to __jsc__.garbageCollect and window.garbageCollect More...
 
local forceGC ( local cx, local argc, local vp)
 Forces a cycle of garbage collection, it should be invoked from script environment Bound to __jsc__.garbageCollect and window.garbageCollect More...
 
static bool dumpRoot (JSContext *cx, uint32_t argc, jsval *vp)
 Dump all named rooted objects, it should be invoked from script environment Bound to __jsc__.dumpRoot More...
 
local dumpRoot ( local cx, local argc, local vp)
 Dump all named rooted objects, it should be invoked from script environment Bound to __jsc__.dumpRoot More...
 
static bool isObjectValid (JSContext *cx, uint32_t argc, jsval *vp)
 Check whether a js object's C++ proxy is still valid, it should be invoked from script environment Bound to window.__isObjectValid More...
 
local isObjectValid ( local cx, local argc, local vp)
 Check whether a js object's C++ proxy is still valid, it should be invoked from script environment Bound to window.__isObjectValid More...
 
void debugProcessInput (const std::string &str)
 Log a string to the debug environment. More...
 
void enableDebugger (unsigned int port=5086)
 Enable the debug environment, mozilla Firefox's remote debugger or Code IDE can connect to it. More...
 
JSObject * getDebugGlobal ()
 Gets the debug environment's global object. More...
 
JSObject * getGlobalObject ()
 Gets the global object. More...
 
bool isFunctionOverridedInJS (JS::HandleObject obj, const std::string &name, JSNative native)
 Checks whether a C++ function is overridden in js prototype chain. More...
 
virtual void rootObject (cocos2d::Ref *ref) override
 Roots the associated JSObj. More...
 
virtual void unrootObject (cocos2d::Ref *ref) override
 Unroots the associated JSObj. More...
 
local unrootObject ( local ref)
 Unroots the associated JSObj. More...
 
virtual void removeObjectProxy (cocos2d::Ref *obj) override
 Remove proxy for a native object.
 
local removeObjectProxy ( local obj)
 Remove proxy for a native object.
 
virtual void garbageCollect () override
 Calls the Garbage Collector.
 
void setFinalizing (JSObject *finalizing)
 Sets the js object that is being finalizing in the script engine, internal use only, please do not call this function.
 
JSObject * getFinalizing ()
 Gets the js object that is being finalizing in the script engine.
 
js_proxy_t * jsb_new_proxy (void *nativeObj, JS::HandleObject jsObj)
 creates two new proxies: one associated with the nativeObj, and another one associated with the JsObj
 
js_proxy_t * jsb_get_native_proxy (void *nativeObj)
 returns the proxy associated with the Native*
 
js_proxy_t * jsb_get_js_proxy (JS::HandleObject jsObj)
 returns the proxy associated with the JSObject*
 
void jsb_remove_proxy (js_proxy_t *nativeProxy, js_proxy_t *jsProxy)
 deprecated: use jsb_remove_proxy(js_proxy_t* proxy) instead
 
void jsb_remove_proxy (js_proxy_t *proxy)
 removes both the native and js proxies
 
void removeJSObject (JSContext *cx, cocos2d::Ref *nativeObj)
 removes the native js object proxy and unroot the js object (if necessary), it's often used when JS object is created by native object
 
void jsb_ref_init (JSContext *cx, JS::Heap< JSObject * > *obj, cocos2d::Ref *ref, const char *debug)
 Generic initialization function for subclasses of Ref.
 
void jsb_ref_autoreleased_init (JSContext *cx, JS::Heap< JSObject * > *obj, cocos2d::Ref *ref, const char *debug)
 Generic initialization function for subclasses of Ref. More...
 
void jsb_ref_rebind (JSContext *cx, JS::HandleObject jsobj, js_proxy_t *js2native_proxy, cocos2d::Ref *oldRef, cocos2d::Ref *newRef, const char *debug)
 Disassociates oldRef from jsobj, and associates a new Ref. More...
 
void jsb_non_ref_init (JSContext *cx, JS::Heap< JSObject * > *obj, void *native, const char *debug)
 Generic initialization function for non Ref classes.
 
JSObject * jsb_ref_create_jsobject (JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char *debug)
 Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref.
 
JSObject * jsb_ref_autoreleased_create_jsobject (JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char *debug)
 Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref Similar to jsb_ref_create_jsobject(), but call it if you know that Ref has been autoreleased This function should never be called. More...
 
JSObject * jsb_create_weak_jsobject (JSContext *cx, void *native, js_type_class_t *typeClass, const char *debug)
 It will try to get the associated JSObjct for the native object. More...
 
JSObject * jsb_ref_get_or_create_jsobject (JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char *debug)
 It will try to get the associated JSObjct for ref. More...
 
JSObject * jsb_ref_autoreleased_get_or_create_jsobject (JSContext *cx, cocos2d::Ref *ref, js_type_class_t *typeClass, const char *debug=nullptr)
 It will try to get the associated JSObjct for ref. More...
 
CC_JS_DLL JSObject * jsb_get_or_create_weak_jsobject (JSContext *cx, void *native, js_type_class_t *typeClass, const char *debug=nullptr)
 It will try to get the associated JSObjct for the native object. More...
 
void jsb_register_finalize_hook (JSObject *hook, JSObject *owner)
 Register finalize hook and its owner as an entry in _js_hook_owner_map, so that we can find the owner of a FinalizeHook in its finalize function.
 
JSObject * jsb_get_and_remove_hook_owner (JSObject *hook)
 Remove the entry of finalize hook and its owner in _js_hook_owner_map.
 

Detailed Description

Function Documentation

static ScriptingCore* getInstance ( )
static

ScriptingCore is a singleton class, you can retrieve its instance with this function.

Returns
The ScriptingCore instance.
var getInstance ( )
static

ScriptingCore is a singleton class, you can retrieve its instance with this function.

Returns
The ScriptingCore instance.
local getInstance ( )
static

ScriptingCore is a singleton class, you can retrieve its instance with this function.

Returns
The ScriptingCore instance.
virtual cocos2d::ccScriptType
getScriptType
( )
inlineoverridevirtual

Gets the script type, for ScriptingCore, it will return cocos2d::kScriptTypeJavascript

Returns
cocos2d::kScriptTypeJavascript

Reimplemented from ScriptEngineProtocol.

var getScriptType ( )
inlineoverridevirtual

Gets the script type, for ScriptingCore, it will return cocos2d::kScriptTypeJavascript

Returns
cocos2d::kScriptTypeJavascript

Reimplemented from ScriptEngineProtocol.

local getScriptType ( )
inlineoverridevirtual

Gets the script type, for ScriptingCore, it will return cocos2d::kScriptTypeJavascript

Returns
cocos2d::kScriptTypeJavascript

Reimplemented from ScriptEngineProtocol.

virtual void
removeScriptObjectByObject
( cocos2d::Ref obj)
overridevirtual

Removes the C++ object's linked JavaScript proxy object from JavaScript context.

Parameters
objObject to be removed

Reimplemented from ScriptEngineProtocol.

var removeScriptObjectByObject ( var  obj)
overridevirtual

Removes the C++ object's linked JavaScript proxy object from JavaScript context.

Parameters
objObject to be removed

Reimplemented from ScriptEngineProtocol.

local removeScriptObjectByObject ( local  obj)
overridevirtual

Removes the C++ object's linked JavaScript proxy object from JavaScript context.

Parameters
objObject to be removed

Reimplemented from ScriptEngineProtocol.

virtual int executeString ( const char *  codes)
inlineoverridevirtual

Useless in ScriptingCore, please use evalString.

See also
evalString

Implements ScriptEngineProtocol.

var executeString ( var  codes)
inlineoverridevirtual

Useless in ScriptingCore, please use evalString.

See also
evalString

Implements ScriptEngineProtocol.

local executeString ( local  codes)
inlineoverridevirtual

Useless in ScriptingCore, please use evalString.

See also
evalString

Implements ScriptEngineProtocol.

void pauseSchedulesAndActions ( js_proxy_t *  p)

Pause scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
var pauseSchedulesAndActions ( var  p)

Pause scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
local pauseSchedulesAndActions ( local  p)

Pause scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
void resumeSchedulesAndActions ( js_proxy_t *  p)

Resume scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
var resumeSchedulesAndActions ( var  p)

Resume scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
local resumeSchedulesAndActions ( local  p)

Resume scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
void cleanupSchedulesAndActions ( js_proxy_t *  p)

Cleanup scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
var cleanupSchedulesAndActions ( var  p)

Cleanup scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
local cleanupSchedulesAndActions ( local  p)

Cleanup scheduled tasks and actions for an object proxy.

Parameters
pThe object proxy
virtual int executeScriptFile ( const char *  filename)
inlineoverridevirtual

Useless in ScriptingCore, please use runScript.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

var executeScriptFile ( var  filename)
inlineoverridevirtual

Useless in ScriptingCore, please use runScript.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

local executeScriptFile ( local  filename)
inlineoverridevirtual

Useless in ScriptingCore, please use runScript.

Parameters
filenameString object holding the filename of the script file that is to be executed

Implements ScriptEngineProtocol.

virtual int executeGlobalFunction ( const char *  functionName)
overridevirtual

Useless in ScriptingCore, please use executeFunctionWithOwner.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

var executeGlobalFunction ( var  functionName)
overridevirtual

Useless in ScriptingCore, please use executeFunctionWithOwner.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

local executeGlobalFunction ( local  functionName)
overridevirtual

Useless in ScriptingCore, please use executeFunctionWithOwner.

Parameters
functionNameString object holding the name of the function, in the global script environment, that is to be executed.
Returns
The integer value returned from the script function.

Implements ScriptEngineProtocol.

virtual bool parseConfig ( ConfigType  type,
const std::string &  str 
)
overridevirtual

Parse configuration file.

Parameters
typethe specific type value.
strthe information data.

Implements ScriptEngineProtocol.

var parseConfig ( var  type,
var  str 
)
overridevirtual

Parse configuration file.

Parameters
typethe specific type value.
strthe information data.

Implements ScriptEngineProtocol.

local parseConfig ( local  type,
local  str 
)
overridevirtual

Parse configuration file.

Parameters
typethe specific type value.
strthe information data.

Implements ScriptEngineProtocol.

virtual bool handleAssert ( const char *  msg)
inlineoverridevirtual

Useless in ScriptingCore.

Returns
false

Implements ScriptEngineProtocol.

var handleAssert ( var  msg)
inlineoverridevirtual

Useless in ScriptingCore.

Returns
false

Implements ScriptEngineProtocol.

local handleAssert ( local  msg)
inlineoverridevirtual

Useless in ScriptingCore.

Returns
false

Implements ScriptEngineProtocol.

bool executeFunctionWithObjectData ( void *  nativeObj,
const char *  name,
JSObject *  obj 
)

Execute a js function with a JavaScript object as parameter.

By passing a native object, ScriptingCore will found its JavaScript object with the proxy. Then the function will be invoked with the native object's js proxy as caller.

Parameters
nativeObjThe caller object's C++ proxy.
nameThe function name.
objThe JavaScript object as parameter.
Returns
Return the js function's boolean result if successfully invoked, otherwise return false.
var executeFunctionWithObjectData ( var  nativeObj,
var  name,
var  obj 
)

Execute a js function with a JavaScript object as parameter.

By passing a native object, ScriptingCore will found its JavaScript object with the proxy. Then the function will be invoked with the native object's js proxy as caller.

Parameters
nativeObjThe caller object's C++ proxy.
nameThe function name.
objThe JavaScript object as parameter.
Returns
Return the js function's boolean result if successfully invoked, otherwise return false.
local executeFunctionWithObjectData ( local  nativeObj,
local  name,
local  obj 
)

Execute a js function with a JavaScript object as parameter.

By passing a native object, ScriptingCore will found its JavaScript object with the proxy. Then the function will be invoked with the native object's js proxy as caller.

Parameters
nativeObjThe caller object's C++ proxy.
nameThe function name.
objThe JavaScript object as parameter.
Returns
Return the js function's boolean result if successfully invoked, otherwise return false.
bool executeFunctionWithOwner ( jsval  owner,
const char *  name,
uint32_t  argc,
jsval *  vp 
)

Execute a js function with a JavaScript caller, function name, arguments count and arguments.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
Returns
Return true if successfully invoked, otherwise return false.
var executeFunctionWithOwner ( var  owner,
var  name,
var  argc,
var  vp 
)

Execute a js function with a JavaScript caller, function name, arguments count and arguments.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
Returns
Return true if successfully invoked, otherwise return false.
local executeFunctionWithOwner ( local  owner,
local  name,
local  argc,
local  vp 
)

Execute a js function with a JavaScript caller, function name, arguments count and arguments.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
Returns
Return true if successfully invoked, otherwise return false.
bool executeFunctionWithOwner ( jsval  owner,
const char *  name,
uint32_t  argc,
jsval *  vp,
JS::MutableHandleValue  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
var executeFunctionWithOwner ( var  owner,
var  name,
var  argc,
var  vp,
var  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
local executeFunctionWithOwner ( local  owner,
local  name,
local  argc,
local  vp,
local  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments count, arguments and a return value.

Parameters
ownerThe caller object.
nameThe function name.
argcThe arguments count.
vpThe arguments.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
bool executeFunctionWithOwner ( jsval  owner,
const char *  name,
const JS::HandleValueArray &  args 
)

Execute a js function with a JavaScript caller, function name, arguments array.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
Returns
Return true if successfully invoked, otherwise return false.
var executeFunctionWithOwner ( var  owner,
var  name,
var  args 
)

Execute a js function with a JavaScript caller, function name, arguments array.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
Returns
Return true if successfully invoked, otherwise return false.
local executeFunctionWithOwner ( local  owner,
local  name,
local  args 
)

Execute a js function with a JavaScript caller, function name, arguments array.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
Returns
Return true if successfully invoked, otherwise return false.
bool executeFunctionWithOwner ( jsval  owner,
const char *  name,
const JS::HandleValueArray &  args,
JS::MutableHandleValue  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments array and a return value.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
var executeFunctionWithOwner ( var  owner,
var  name,
var  args,
var  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments array and a return value.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
local executeFunctionWithOwner ( local  owner,
local  name,
local  args,
local  retVal 
)

Execute a js function with a JavaScript caller, function name, arguments array and a return value.

This is more reliable in js memory management

Parameters
ownerThe caller object.
nameThe function name.
argsThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
void executeJSFunctionWithThisObj ( JS::HandleValue  thisObj,
JS::HandleValue  callback 
)

Execute a js function with a js this object and the js function object.

Parameters
thisObjThe js this object.
callbackThe js function object.
Returns
Return true if successfully invoked, otherwise return false.
var executeJSFunctionWithThisObj ( var  thisObj,
var  callback 
)

Execute a js function with a js this object and the js function object.

Parameters
thisObjThe js this object.
callbackThe js function object.
Returns
Return true if successfully invoked, otherwise return false.
local executeJSFunctionWithThisObj ( local  thisObj,
local  callback 
)

Execute a js function with a js this object and the js function object.

Parameters
thisObjThe js this object.
callbackThe js function object.
Returns
Return true if successfully invoked, otherwise return false.
void executeJSFunctionWithThisObj ( JS::HandleValue  thisObj,
JS::HandleValue  callback,
const JS::HandleValueArray &  vp,
JS::MutableHandleValue  retVal 
)

Execute a js function with a js this object, the js function object, arguments and a return value.

Parameters
thisObjThe js this object.
callbackThe js function object.
vpThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
var executeJSFunctionWithThisObj ( var  thisObj,
var  callback,
var  vp,
var  retVal 
)

Execute a js function with a js this object, the js function object, arguments and a return value.

Parameters
thisObjThe js this object.
callbackThe js function object.
vpThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
local executeJSFunctionWithThisObj ( local  thisObj,
local  callback,
local  vp,
local  retVal 
)

Execute a js function with a js this object, the js function object, arguments and a return value.

Parameters
thisObjThe js this object.
callbackThe js function object.
vpThe arguments array.
retValThe js object to save the return value.
Returns
Return true if successfully invoked, otherwise return false.
bool evalString ( const char *  string,
JS::MutableHandleValue  outVal,
const char *  filename,
JSContext *  cx,
JS::HandleObject  global 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
filenameThe filename
cxThe js context
globalThe js global object
Returns
Return true if successfully invoked, otherwise return false.
var evalString ( var  string,
var  outVal,
var  filename,
var  cx,
var  global 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
filenameThe filename
cxThe js context
globalThe js global object
Returns
Return true if successfully invoked, otherwise return false.
local evalString ( local  string,
local  outVal,
local  filename,
local  cx,
local  global 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
filenameThe filename
cxThe js context
globalThe js global object
Returns
Return true if successfully invoked, otherwise return false.
bool evalString ( const char *  string,
JS::MutableHandleValue  outVal 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
Returns
Return true if successfully invoked, otherwise return false.
var evalString ( var  string,
var  outVal 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
Returns
Return true if successfully invoked, otherwise return false.
local evalString ( local  string,
local  outVal 
)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation.
Returns
Return true if successfully invoked, otherwise return false.
bool evalString ( const char *  string)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
Returns
Return true if successfully invoked, otherwise return false.
var evalString ( var  string)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
Returns
Return true if successfully invoked, otherwise return false.
local evalString ( local  string)

Evaluate the specified js code string.

Parameters
stringThe string with the javascript code to be evaluated
Returns
Return true if successfully invoked, otherwise return false.
JS::PersistentRootedScript*
getScript
( const std::string &  path)

Get script object for the given path.

Parameters
pathThe script file path
Returns
Script object
var getScript ( var  path)

Get script object for the given path.

Parameters
pathThe script file path
Returns
Script object
local getScript ( local  path)

Get script object for the given path.

Parameters
pathThe script file path
Returns
Script object
JS::PersistentRootedScript*
compileScript
( const std::string &  path,
JS::HandleObject  global,
JSContext *  cx = nullptr 
)

Compile the specified js file.

Parameters
pathThe path of the script to be compiled
globalThe js global object
cxThe js context
var compileScript ( var  path,
var  global,
var  cx = nullptr 
)

Compile the specified js file.

Parameters
pathThe path of the script to be compiled
globalThe js global object
cxThe js context
local compileScript ( local  path,
local  global,
local  cx = nullptr 
)

Compile the specified js file.

Parameters
pathThe path of the script to be compiled
globalThe js global object
cxThe js context
bool runScript ( const std::string &  path)

Run the specified js file.

Parameters
pathThe path of the script to be executed
Returns
Return true if succeed, otherwise return false.
var runScript ( var  path)

Run the specified js file.

Parameters
pathThe path of the script to be executed
Returns
Return true if succeed, otherwise return false.
local runScript ( local  path)

Run the specified js file.

Parameters
pathThe path of the script to be executed
Returns
Return true if succeed, otherwise return false.
bool runScript ( const std::string &  path,
JS::HandleObject  global,
JSContext *  cx = NULL 
)

Run the specified js file.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
Returns
Return true if succeed, otherwise return false.
var runScript ( var  path,
var  global,
var  cx = NULL 
)

Run the specified js file.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
Returns
Return true if succeed, otherwise return false.
local runScript ( local  path,
local  global,
local  cx = NULL 
)

Run the specified js file.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
Returns
Return true if succeed, otherwise return false.
bool requireScript ( const char *  path,
JS::MutableHandleValue  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
var requireScript ( var  path,
var  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
local requireScript ( local  path,
local  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
bool requireScript ( const char *  path,
JS::HandleObject  global,
JSContext *  cx,
JS::MutableHandleValue  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
var requireScript ( var  path,
var  global,
var  cx,
var  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
local requireScript ( local  path,
local  global,
local  cx,
local  jsvalRet 
)

Require the specified js file The difference between run and require is that require returns the export object of the script.

Parameters
pathThe path of the script to be executed
globalThe global object to execute the script
globalThe context to execute the script
jsvalRetOn success, return the value from the last executed expression statement processed in the script
Returns
Return true if succeed, otherwise return false.
See also
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_ExecuteScript
void cleanScript ( const char *  path)

Clean script object for the specified js file.

Parameters
pathThe path of the js file to be cleaned
var cleanScript ( var  path)

Clean script object for the specified js file.

Parameters
pathThe path of the js file to be cleaned
local cleanScript ( local  path)

Clean script object for the specified js file.

Parameters
pathThe path of the js file to be cleaned
std::unordered_map<std::string,
JS::PersistentRootedScript*>
& getFileScript
( )

Gets the cached script objects for all executed js file.

Returns
The cached script object map
var getFileScript ( )

Gets the cached script objects for all executed js file.

Returns
The cached script object map
local getFileScript ( )

Gets the cached script objects for all executed js file.

Returns
The cached script object map
void addRegisterCallback ( sc_register_sth  callback)

Add the register_sth callback to the list of functions that need to be called after the creation of the context.

It's normally used to register script bindings in the js context for bound classes

Parameters
callbackThe callback to register something to the js context
var addRegisterCallback ( var  callback)

Add the register_sth callback to the list of functions that need to be called after the creation of the context.

It's normally used to register script bindings in the js context for bound classes

Parameters
callbackThe callback to register something to the js context
local addRegisterCallback ( local  callback)

Add the register_sth callback to the list of functions that need to be called after the creation of the context.

It's normally used to register script bindings in the js context for bound classes

Parameters
callbackThe callback to register something to the js context
void createGlobalContext ( )

Create a new context.

If one is already there, it will destroy the old context and create a new one.

var createGlobalContext ( )

Create a new context.

If one is already there, it will destroy the old context and create a new one.

local createGlobalContext ( )

Create a new context.

If one is already there, it will destroy the old context and create a new one.

static void removeAllRoots ( JSContext *  cx)
static

Removes all rooted object in the given js context, rooted object won't be garbage collected.

Parameters
cxThe js context
var removeAllRoots ( var  cx)
static

Removes all rooted object in the given js context, rooted object won't be garbage collected.

Parameters
cxThe js context
local removeAllRoots ( local  cx)
static

Removes all rooted object in the given js context, rooted object won't be garbage collected.

Parameters
cxThe js context
int executeCustomTouchEvent ( cocos2d::EventTouch::EventCode  eventType,
cocos2d::Touch pTouch,
JSObject *  obj,
JS::MutableHandleValue  retval 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
retvalThe return value of the touch event callback
Returns
Return 1 if succeed, otherwise return 0.
var executeCustomTouchEvent ( var  eventType,
var  pTouch,
var  obj,
var  retval 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
retvalThe return value of the touch event callback
Returns
Return 1 if succeed, otherwise return 0.
local executeCustomTouchEvent ( local  eventType,
local  pTouch,
local  obj,
local  retval 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
retvalThe return value of the touch event callback
Returns
Return 1 if succeed, otherwise return 0.
int executeCustomTouchEvent ( cocos2d::EventTouch::EventCode  eventType,
cocos2d::Touch pTouch,
JSObject *  obj 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
var executeCustomTouchEvent ( var  eventType,
var  pTouch,
var  obj 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
local executeCustomTouchEvent ( local  eventType,
local  pTouch,
local  obj 
)

Simulate a touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
pTouchThe touch object
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
int executeCustomTouchesEvent ( cocos2d::EventTouch::EventCode  eventType,
const std::vector< cocos2d::Touch * > &  touches,
JSObject *  obj 
)

Simulate a multi touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
touchesTouches list for multitouch
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
var executeCustomTouchesEvent ( var  eventType,
var  touches,
var  obj 
)

Simulate a multi touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
touchesTouches list for multitouch
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
local executeCustomTouchesEvent ( local  eventType,
local  touches,
local  obj 
)

Simulate a multi touch event and dispatch it to a js object.

Parameters
eventTypeThe touch event type
touchesTouches list for multitouch
objThe js object
Returns
Return 1 if succeed, otherwise return 0.
JSContext* getGlobalContext ( )
inline

Gets the current global context.

Returns
the global context
var getGlobalContext ( )
inline

Gets the current global context.

Returns
the global context
local getGlobalContext ( )
inline

Gets the current global context.

Returns
the global context
static void reportError ( JSContext *  cx,
const char *  message,
JSErrorReport *  report 
)
static

Report an error in the js context.

Parameters
cxThe js context
messageThe error message
reportThe js error report object
var reportError ( var  cx,
var  message,
var  report 
)
static

Report an error in the js context.

Parameters
cxThe js context
messageThe error message
reportThe js error report object
local reportError ( local  cx,
local  message,
local  report 
)
static

Report an error in the js context.

Parameters
cxThe js context
messageThe error message
reportThe js error report object
static bool log ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Log something to the js context using CCLog.

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
var log ( var  cx,
var  argc,
var  vp 
)
static

Log something to the js context using CCLog.

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
local log ( local  cx,
local  argc,
local  vp 
)
static

Log something to the js context using CCLog.

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
bool setReservedSpot ( uint32_t  i,
JSObject *  obj,
jsval  value 
)

Sets a js value to the targeted js object's reserved slot, which is not exposed to script environment.

Parameters
iThe slot index
objThe targeted object
valueThe js value to set to the slot
Returns
Return true if succeed, otherwise return false.
var setReservedSpot ( var  i,
var  obj,
var  value 
)

Sets a js value to the targeted js object's reserved slot, which is not exposed to script environment.

Parameters
iThe slot index
objThe targeted object
valueThe js value to set to the slot
Returns
Return true if succeed, otherwise return false.
local setReservedSpot ( local  i,
local  obj,
local  value 
)

Sets a js value to the targeted js object's reserved slot, which is not exposed to script environment.

Parameters
iThe slot index
objThe targeted object
valueThe js value to set to the slot
Returns
Return true if succeed, otherwise return false.
static bool executeScript ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Runs a script from script environment, it should be invoked from script environment Bound to __jsc__.executeScript and window.executeScript

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
var executeScript ( var  cx,
var  argc,
var  vp 
)
static

Runs a script from script environment, it should be invoked from script environment Bound to __jsc__.executeScript and window.executeScript

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
local executeScript ( local  cx,
local  argc,
local  vp 
)
static

Runs a script from script environment, it should be invoked from script environment Bound to __jsc__.executeScript and window.executeScript

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
Returns
Return true if succeed, otherwise return false.
static bool forceGC ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Forces a cycle of garbage collection, it should be invoked from script environment Bound to __jsc__.garbageCollect and window.garbageCollect

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
var forceGC ( var  cx,
var  argc,
var  vp 
)
static

Forces a cycle of garbage collection, it should be invoked from script environment Bound to __jsc__.garbageCollect and window.garbageCollect

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
local forceGC ( local  cx,
local  argc,
local  vp 
)
static

Forces a cycle of garbage collection, it should be invoked from script environment Bound to __jsc__.garbageCollect and window.garbageCollect

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
static bool dumpRoot ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Dump all named rooted objects, it should be invoked from script environment Bound to __jsc__.dumpRoot

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
var dumpRoot ( var  cx,
var  argc,
var  vp 
)
static

Dump all named rooted objects, it should be invoked from script environment Bound to __jsc__.dumpRoot

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
local dumpRoot ( local  cx,
local  argc,
local  vp 
)
static

Dump all named rooted objects, it should be invoked from script environment Bound to __jsc__.dumpRoot

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
static bool isObjectValid ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Check whether a js object's C++ proxy is still valid, it should be invoked from script environment Bound to window.__isObjectValid

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
var isObjectValid ( var  cx,
var  argc,
var  vp 
)
static

Check whether a js object's C++ proxy is still valid, it should be invoked from script environment Bound to window.__isObjectValid

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
local isObjectValid ( local  cx,
local  argc,
local  vp 
)
static

Check whether a js object's C++ proxy is still valid, it should be invoked from script environment Bound to window.__isObjectValid

Parameters
cxThe js context
argcThe arguments count
vpThe arguments
void debugProcessInput ( const std::string &  str)

Log a string to the debug environment.

Enable the debug environment so that it can be invoked.

Parameters
strThe message to log
var debugProcessInput ( var  str)

Log a string to the debug environment.

Enable the debug environment so that it can be invoked.

Parameters
strThe message to log
local debugProcessInput ( local  str)

Log a string to the debug environment.

Enable the debug environment so that it can be invoked.

Parameters
strThe message to log
void enableDebugger ( unsigned int  port = 5086)

Enable the debug environment, mozilla Firefox's remote debugger or Code IDE can connect to it.

Parameters
portThe port to connect with the debug environment, default value is 5086
var enableDebugger ( var  port = 5086)

Enable the debug environment, mozilla Firefox's remote debugger or Code IDE can connect to it.

Parameters
portThe port to connect with the debug environment, default value is 5086
local enableDebugger ( local  port = 5086)

Enable the debug environment, mozilla Firefox's remote debugger or Code IDE can connect to it.

Parameters
portThe port to connect with the debug environment, default value is 5086
JSObject* getDebugGlobal ( )
inline

Gets the debug environment's global object.

Returns
The debug environment's global object
var getDebugGlobal ( )
inline

Gets the debug environment's global object.

Returns
The debug environment's global object
local getDebugGlobal ( )
inline

Gets the debug environment's global object.

Returns
The debug environment's global object
JSObject* getGlobalObject ( )
inline

Gets the global object.

Returns
The global object
var getGlobalObject ( )
inline

Gets the global object.

Returns
The global object
local getGlobalObject ( )
inline

Gets the global object.

Returns
The global object
bool isFunctionOverridedInJS ( JS::HandleObject  obj,
const std::string &  name,
JSNative  native 
)

Checks whether a C++ function is overridden in js prototype chain.

Parameters
objThe js object
nameThe function name
nativeThe native function
Returns
The global object
var isFunctionOverridedInJS ( var  obj,
var  name,
var  native 
)

Checks whether a C++ function is overridden in js prototype chain.

Parameters
objThe js object
nameThe function name
nativeThe native function
Returns
The global object
local isFunctionOverridedInJS ( local  obj,
local  name,
local  native 
)

Checks whether a C++ function is overridden in js prototype chain.

Parameters
objThe js object
nameThe function name
nativeThe native function
Returns
The global object
virtual void rootObject ( cocos2d::Ref ref)
overridevirtual

Roots the associated JSObj.

The GC won't collected rooted objects. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

var rootObject ( var  ref)
overridevirtual

Roots the associated JSObj.

The GC won't collected rooted objects. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

local rootObject ( local  ref)
overridevirtual

Roots the associated JSObj.

The GC won't collected rooted objects. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

virtual void unrootObject ( cocos2d::Ref ref)
overridevirtual

Unroots the associated JSObj.

The GC will collect this object the next time the GC is called. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

var unrootObject ( var  ref)
overridevirtual

Unroots the associated JSObj.

The GC will collect this object the next time the GC is called. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

local unrootObject ( local  ref)
overridevirtual

Unroots the associated JSObj.

The GC will collect this object the next time the GC is called. This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1

Reimplemented from ScriptEngineProtocol.

void jsb_ref_autoreleased_init ( JSContext *  cx,
JS::Heap< JSObject * > *  obj,
cocos2d::Ref ref,
const char *  debug 
)

Generic initialization function for subclasses of Ref.

Similar to jsb_ref_init(), but call it if you know that Ref has been autoreleased This function should never be called. It is only added as way to fix an issue with the static auto-bindings with the "create" function

var jsb_ref_autoreleased_init ( var  cx,
var  obj,
var  ref,
var  debug 
)

Generic initialization function for subclasses of Ref.

Similar to jsb_ref_init(), but call it if you know that Ref has been autoreleased This function should never be called. It is only added as way to fix an issue with the static auto-bindings with the "create" function

local jsb_ref_autoreleased_init ( local  cx,
local  obj,
local  ref,
local  debug 
)

Generic initialization function for subclasses of Ref.

Similar to jsb_ref_init(), but call it if you know that Ref has been autoreleased This function should never be called. It is only added as way to fix an issue with the static auto-bindings with the "create" function

void jsb_ref_rebind ( JSContext *  cx,
JS::HandleObject  jsobj,
js_proxy_t *  js2native_proxy,
cocos2d::Ref oldRef,
cocos2d::Ref newRef,
const char *  debug 
)

Disassociates oldRef from jsobj, and associates a new Ref.

Useful for the EaseActions and others

var jsb_ref_rebind ( var  cx,
var  jsobj,
var  js2native_proxy,
var  oldRef,
var  newRef,
var  debug 
)

Disassociates oldRef from jsobj, and associates a new Ref.

Useful for the EaseActions and others

local jsb_ref_rebind ( local  cx,
local  jsobj,
local  js2native_proxy,
local  oldRef,
local  newRef,
local  debug 
)

Disassociates oldRef from jsobj, and associates a new Ref.

Useful for the EaseActions and others

JSObject*
jsb_ref_autoreleased_create_jsobject
( JSContext *  cx,
cocos2d::Ref ref,
js_type_class_t *  typeClass,
const char *  debug 
)

Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref Similar to jsb_ref_create_jsobject(), but call it if you know that Ref has been autoreleased This function should never be called.

It is only added as way to fix an issue with the static auto-bindings with the "create" function

var
jsb_ref_autoreleased_create_jsobject
( var  cx,
var  ref,
var  typeClass,
var  debug 
)

Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref Similar to jsb_ref_create_jsobject(), but call it if you know that Ref has been autoreleased This function should never be called.

It is only added as way to fix an issue with the static auto-bindings with the "create" function

local
jsb_ref_autoreleased_create_jsobject
( local  cx,
local  ref,
local  typeClass,
local  debug 
)

Creates a new JSObject of a certain type (typeClass) and creates a proxy associated with and the Ref Similar to jsb_ref_create_jsobject(), but call it if you know that Ref has been autoreleased This function should never be called.

It is only added as way to fix an issue with the static auto-bindings with the "create" function

JSObject* jsb_create_weak_jsobject ( JSContext *  cx,
void *  native,
js_type_class_t *  typeClass,
const char *  debug 
)

It will try to get the associated JSObjct for the native object.

The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.

var jsb_create_weak_jsobject ( var  cx,
var  native,
var  typeClass,
var  debug 
)

It will try to get the associated JSObjct for the native object.

The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.

local jsb_create_weak_jsobject ( local  cx,
local  native,
local  typeClass,
local  debug 
)

It will try to get the associated JSObjct for the native object.

The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.

JSObject*
jsb_ref_get_or_create_jsobject
( JSContext *  cx,
cocos2d::Ref ref,
js_type_class_t *  typeClass,
const char *  debug 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref. Call this function for objects that were already created and initialized, when returning getChild()

var jsb_ref_get_or_create_jsobject ( var  cx,
var  ref,
var  typeClass,
var  debug 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref. Call this function for objects that were already created and initialized, when returning getChild()

local
jsb_ref_get_or_create_jsobject
( local  cx,
local  ref,
local  typeClass,
local  debug 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref. Call this function for objects that were already created and initialized, when returning getChild()

JSObject*
jsb_ref_autoreleased_get_or_create_jsobject
( JSContext *  cx,
cocos2d::Ref ref,
js_type_class_t *  typeClass,
const char *  debug = nullptr 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref Call this function for objects that might return an already existing copy when you create them. For example, Animation3D::create();

var
jsb_ref_autoreleased_get_or_create_jsobject
( var  cx,
var  ref,
var  typeClass,
var  debug = nullptr 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref Call this function for objects that might return an already existing copy when you create them. For example, Animation3D::create();

local
jsb_ref_autoreleased_get_or_create_jsobject
( local  cx,
local  ref,
local  typeClass,
local  debug = nullptr 
)

It will try to get the associated JSObjct for ref.

If it can't find it, it will create a new one associating it to Ref Call this function for objects that might return an already existing copy when you create them. For example, Animation3D::create();

CC_JS_DLL JSObject*
jsb_get_or_create_weak_jsobject
( JSContext *  cx,
void *  native,
js_type_class_t *  typeClass,
const char *  debug = nullptr 
)

It will try to get the associated JSObjct for the native object.

If it can't find it, it will create a new one associating it to the native object. The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_get_or_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.

var jsb_get_or_create_weak_jsobject ( var  cx,
var  native,
var  typeClass,
var  debug = nullptr 
)

It will try to get the associated JSObjct for the native object.

If it can't find it, it will create a new one associating it to the native object. The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_get_or_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.

local
jsb_get_or_create_weak_jsobject
( local  cx,
local  native,
local  typeClass,
local  debug = nullptr 
)

It will try to get the associated JSObjct for the native object.

If it can't find it, it will create a new one associating it to the native object. The reference created from JSObject to native object is weak because it won't retain it. The behavior is exactly the same with 'jsb_ref_get_or_create_jsobject' when CC_ENABLE_GC_FOR_NATIVE_OBJECTS deactivated.