cocos2d-x  3.0alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ScriptingCore Class Reference

#include <ScriptingCore.h>

Inheritance diagram for ScriptingCore:
ScriptEngineProtocol

Public Member Functions

 ~ScriptingCore ()
virtual ccScriptType getScriptType ()
 Get script type. More...
 
virtual void removeScriptObjectByObject (Object *pObj)
 Remove Object from lua state. More...
 
local removeScriptObjectByObject ( local pObj)
 Remove Object from lua state. More...
 
virtual int executeString (const char *codes)
 Execute script code contained in the given string. More...
 
void pauseSchedulesAndActions (js_proxy_t *p)
void resumeSchedulesAndActions (js_proxy_t *p)
void cleanupSchedulesAndActions (js_proxy_t *p)
virtual int executeScriptFile (const char *filename)
 Execute a script file. More...
 
local executeScriptFile ( local filename)
 Execute a script file. More...
 
virtual int executeGlobalFunction (const char *functionName)
 Execute a scripted global function. More...
 
virtual int sendEvent (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 NULL in lua More...
 
virtual bool handleAssert (const char *msg)
 called by CCAssert to allow scripting engine to handle failed assertions More...
 
local handleAssert ( local msg)
 called by CCAssert to allow scripting engine to handle failed assertions More...
 
bool executeFunctionWithObjectData (Node *self, const char *name, JSObject *obj)
JSBool executeFunctionWithOwner (jsval owner, const char *name, uint32_t argc=0, jsval *vp=NULL, jsval *retVal=NULL)
local executeFunctionWithOwner ( local owner, local name, local 0, local NULL, local NULL)
void executeJSFunctionWithThisObj (jsval thisObj, jsval callback, uint32_t argc=0, jsval *vp=NULL, jsval *retVal=NULL)
JSBool evalString (const char *string, jsval *outVal, const char *filename=NULL, JSContext *cx=NULL, JSObject *global=NULL)
 will eval the specified string More...
 
JSBool runScript (const char *path, JSObject *global=NULL, JSContext *cx=NULL)
 will run the specified string More...
 
void start ()
 initialize everything More...
 
void cleanup ()
 cleanup everything More...
 
void reset ()
 cleanup everything then initialize everything More...
 
void addRegisterCallback (sc_register_sth callback)
 will add the register_sth callback to the list of functions that need to be called after the creation of the context More...
 
void createGlobalContext ()
 Will create a new context. More...
 
int executeCustomTouchEvent (EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj, jsval &retval)
var executeCustomTouchEvent ( var eventType, var pTouch, var obj, var retval)
local executeCustomTouchEvent ( local eventType, local pTouch, local obj, local retval)
int executeCustomTouchEvent (EventTouch::EventCode eventType, Touch *pTouch, JSObject *obj)
int executeCustomTouchesEvent (EventTouch::EventCode eventType, const std::vector< Touch * > &touches, JSObject *obj)
JSContext * getGlobalContext ()
JSBool setReservedSpot (uint32_t i, JSObject *obj, jsval value)
void debugProcessInput (const std::string &str)
 enable the debug environment More...
 
void enableDebugger ()
JSObject * getDebugGlobal ()
local getDebugGlobal ()
JSObject * getGlobalObject ()
local getGlobalObject ()
- Public Member Functions inherited from ScriptEngineProtocol
virtual ~ScriptEngineProtocol ()
virtual void removeScriptHandler (int nHandler)
 Remove script function handler, only LuaEngine class need to implement this function. More...
 
virtual int reallocateScriptHandler (int nHandler)
 Reallocate script function handler, only LuaEngine class need to implement this function. More...
 

Static Public Member Functions

static ScriptingCoregetInstance ()
static void removeAllRoots (JSContext *cx)
local removeAllRoots ( local cx)
static void reportError (JSContext *cx, const char *message, JSErrorReport *report)
local reportError ( local cx, local message, local report)
static JSBool log (JSContext *cx, uint32_t argc, jsval *vp)
 Log something using CCLog. More...
 
local log ( local cx, local argc, local vp)
 Log something using CCLog. More...
 
static JSBool executeScript (JSContext *cx, uint32_t argc, jsval *vp)
 run a script from script :) More...
 
local executeScript ( local cx, local argc, local vp)
 run a script from script :) More...
 
static JSBool forceGC (JSContext *cx, uint32_t argc, jsval *vp)
 Force a cycle of GC. More...
 
local forceGC ( local cx, local argc, local vp)
 Force a cycle of GC. More...
 
static JSBool dumpRoot (JSContext *cx, uint32_t argc, jsval *vp)
static JSBool addRootJS (JSContext *cx, uint32_t argc, jsval *vp)
local addRootJS ( local cx, local argc, local vp)
static JSBool removeRootJS (JSContext *cx, uint32_t argc, jsval *vp)
local removeRootJS ( local cx, local argc, local vp)

Constructor & Destructor Documentation

var ~ScriptingCore ( )
local ~ScriptingCore ( )

Member Function Documentation

void addRegisterCallback ( sc_register_sth  callback)

will add the register_sth callback to the list of functions that need to be called after the creation of the context

var addRegisterCallback ( var  callback)

will add the register_sth callback to the list of functions that need to be called after the creation of the context

local addRegisterCallback ( local  callback)

will add the register_sth callback to the list of functions that need to be called after the creation of the context

static JSBool addRootJS ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static
var addRootJS ( var  cx,
var  argc,
var  vp 
)
static
local addRootJS ( local  cx,
local  argc,
local  vp 
)
static
void cleanup ( )

cleanup everything

var cleanup ( )

cleanup everything

local cleanup ( )

cleanup everything

void cleanupSchedulesAndActions ( js_proxy_t p)
var cleanupSchedulesAndActions ( var  p)
local cleanupSchedulesAndActions ( local  p)
void createGlobalContext ( )

Will create a new context.

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

var createGlobalContext ( )

Will create a new context.

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

local createGlobalContext ( )

Will create a new context.

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

void debugProcessInput ( const std::string &  str)

enable the debug environment

var debugProcessInput ( var  str)

enable the debug environment

local debugProcessInput ( local  str)

enable the debug environment

static JSBool dumpRoot ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static
var dumpRoot ( var  cx,
var  argc,
var  vp 
)
static
local dumpRoot ( local  cx,
local  argc,
local  vp 
)
static
void enableDebugger ( )
var enableDebugger ( )
local enableDebugger ( )
JSBool evalString ( const char *  string,
jsval *  outVal,
const char *  filename = NULL,
JSContext *  cx = NULL,
JSObject *  global = NULL 
)

will eval the specified string

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation. Can be NULL.
var evalString ( var  string,
var  outVal,
var  filename = NULL,
var  cx = NULL,
var  global = NULL 
)

will eval the specified string

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation. Can be NULL.
local evalString ( local  string,
local  outVal,
local  filename = NULL,
local  cx = NULL,
local  global = NULL 
)

will eval the specified string

Parameters
stringThe string with the javascript code to be evaluated
outValThe jsval that will hold the return value of the evaluation. Can be NULL.
int executeCustomTouchesEvent ( EventTouch::EventCode  eventType,
const std::vector< Touch * > &  touches,
JSObject *  obj 
)
var executeCustomTouchesEvent ( var  eventType,
var  touches,
var  obj 
)
local executeCustomTouchesEvent ( local  eventType,
local  touches,
local  obj 
)
int executeCustomTouchEvent ( EventTouch::EventCode  eventType,
Touch pTouch,
JSObject *  obj,
jsval &  retval 
)
var executeCustomTouchEvent ( var  eventType,
var  pTouch,
var  obj,
var  retval 
)
local executeCustomTouchEvent ( local  eventType,
local  pTouch,
local  obj,
local  retval 
)
int executeCustomTouchEvent ( EventTouch::EventCode  eventType,
Touch pTouch,
JSObject *  obj 
)
var executeCustomTouchEvent ( var  eventType,
var  pTouch,
var  obj 
)
local executeCustomTouchEvent ( local  eventType,
local  pTouch,
local  obj 
)
bool executeFunctionWithObjectData ( Node self,
const char *  name,
JSObject *  obj 
)
var executeFunctionWithObjectData ( var  self,
var  name,
var  obj 
)
local executeFunctionWithObjectData ( local  self,
local  name,
local  obj 
)
JSBool executeFunctionWithOwner ( jsval  owner,
const char *  name,
uint32_t  argc = 0,
jsval *  vp = NULL,
jsval *  retVal = NULL 
)
var executeFunctionWithOwner ( var  owner,
var  name,
var  argc = 0,
var  vp = NULL,
var  retVal = NULL 
)
local executeFunctionWithOwner ( local  owner,
local  name,
local  argc = 0,
local  vp = NULL,
local  retVal = NULL 
)
virtual int executeGlobalFunction ( const char *  functionName)
inlinevirtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

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)
inlinevirtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

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)
inlinevirtual

Execute a scripted global function.

The function should not take any parameters and should return an integer.

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.

void executeJSFunctionWithThisObj ( jsval  thisObj,
jsval  callback,
uint32_t  argc = 0,
jsval *  vp = NULL,
jsval *  retVal = NULL 
)
var executeJSFunctionWithThisObj ( var  thisObj,
var  callback,
var  argc = 0,
var  vp = NULL,
var  retVal = NULL 
)
local executeJSFunctionWithThisObj ( local  thisObj,
local  callback,
local  argc = 0,
local  vp = NULL,
local  retVal = NULL 
)
static JSBool executeScript ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

run a script from script :)

var executeScript ( var  cx,
var  argc,
var  vp 
)
static

run a script from script :)

local executeScript ( local  cx,
local  argc,
local  vp 
)
static

run a script from script :)

virtual int executeScriptFile ( const char *  filename)
inlinevirtual

Execute a script file.

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

Implements ScriptEngineProtocol.

var executeScriptFile ( var  filename)
inlinevirtual

Execute a script file.

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

Implements ScriptEngineProtocol.

local executeScriptFile ( local  filename)
inlinevirtual

Execute a script file.

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

Implements ScriptEngineProtocol.

virtual int executeString ( const char *  codes)
inlinevirtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

var executeString ( var  codes)
inlinevirtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

local executeString ( local  codes)
inlinevirtual

Execute script code contained in the given string.

Parameters
codesholding the valid script code that should be executed.
Returns
0 if the string is excuted correctly.
other if the string is excuted wrongly.

Implements ScriptEngineProtocol.

static JSBool forceGC ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Force a cycle of GC.

Parameters
cx
argc
vp
var forceGC ( var  cx,
var  argc,
var  vp 
)
static

Force a cycle of GC.

Parameters
cx
argc
vp
local forceGC ( local  cx,
local  argc,
local  vp 
)
static

Force a cycle of GC.

Parameters
cx
argc
vp
JSObject* getDebugGlobal ( )
inline
var getDebugGlobal ( )
inline
local getDebugGlobal ( )
inline
JSContext* getGlobalContext ( )
inline
Returns
the global context
var getGlobalContext ( )
inline
Returns
the global context
local getGlobalContext ( )
inline
Returns
the global context
JSObject* getGlobalObject ( )
inline
var getGlobalObject ( )
inline
local getGlobalObject ( )
inline
static ScriptingCore* getInstance ( void  )
inlinestatic
var getInstance (   )
inlinestatic
local getInstance (   )
inlinestatic
virtual ccScriptType getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

var getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

local getScriptType ( )
inlinevirtual

Get script type.

Reimplemented from ScriptEngineProtocol.

virtual bool handleAssert ( const char *  msg)
inlinevirtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

var handleAssert ( var  msg)
inlinevirtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

local handleAssert ( local  msg)
inlinevirtual

called by CCAssert to allow scripting engine to handle failed assertions

Returns
true if the assert was handled by the script engine, false otherwise.

Implements ScriptEngineProtocol.

static JSBool log ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static

Log something using CCLog.

Parameters
cx
argc
vp
var log ( var  cx,
var  argc,
var  vp 
)
static

Log something using CCLog.

Parameters
cx
argc
vp
local log ( local  cx,
local  argc,
local  vp 
)
static

Log something using CCLog.

Parameters
cx
argc
vp
void pauseSchedulesAndActions ( js_proxy_t p)
var pauseSchedulesAndActions ( var  p)
local pauseSchedulesAndActions ( local  p)
static void removeAllRoots ( JSContext *  cx)
static
var removeAllRoots ( var  cx)
static
local removeAllRoots ( local  cx)
static
static JSBool removeRootJS ( JSContext *  cx,
uint32_t  argc,
jsval *  vp 
)
static
var removeRootJS ( var  cx,
var  argc,
var  vp 
)
static
local removeRootJS ( local  cx,
local  argc,
local  vp 
)
static
virtual void
removeScriptObjectByObject
( Object pObj)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

var removeScriptObjectByObject ( var  pObj)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

local removeScriptObjectByObject ( local  pObj)
virtual

Remove Object from lua state.

Parameters
objectto remove

Implements ScriptEngineProtocol.

static void reportError ( JSContext *  cx,
const char *  message,
JSErrorReport *  report 
)
static
Parameters
cx
message
report
var reportError ( var  cx,
var  message,
var  report 
)
static
Parameters
cx
message
report
local reportError ( local  cx,
local  message,
local  report 
)
static
Parameters
cx
message
report
void reset ( )

cleanup everything then initialize everything

var reset ( )

cleanup everything then initialize everything

local reset ( )

cleanup everything then initialize everything

void resumeSchedulesAndActions ( js_proxy_t p)
var resumeSchedulesAndActions ( var  p)
local resumeSchedulesAndActions ( local  p)
JSBool runScript ( const char *  path,
JSObject *  global = NULL,
JSContext *  cx = NULL 
)

will run the specified string

Parameters
stringThe path of the script to be run
var runScript ( var  path,
var  global = NULL,
var  cx = NULL 
)

will run the specified string

Parameters
stringThe path of the script to be run
local runScript ( local  path,
local  global = NULL,
local  cx = NULL 
)

will run the specified string

Parameters
stringThe path of the script to be run
virtual int sendEvent ( ScriptEvent evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be NULL in lua

Implements ScriptEngineProtocol.

var sendEvent ( var  evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be NULL in lua

Implements ScriptEngineProtocol.

local sendEvent ( local  evt)
overridevirtual

when trigger a script event ,call this func,add params needed into ScriptEvent object.nativeObject is object triggering the event, can be NULL in lua

Implements ScriptEngineProtocol.

JSBool setReservedSpot ( uint32_t  i,
JSObject *  obj,
jsval  value 
)
var setReservedSpot ( var  i,
var  obj,
var  value 
)
local setReservedSpot ( local  i,
local  obj,
local  value 
)
void start ( )

initialize everything

var start ( )

initialize everything

local start ( )

initialize everything


The documentation for this class was generated from the following file: