The LuaEngine integrated into the cocos2d-x to process the interactive operation between lua and c++. More...
Inherits ScriptEngineProtocol.
Public Member Functions | |
virtual | ~LuaEngine (void) |
Destructor of LuaEngine. | |
virtual ccScriptType | getScriptType () override |
Get ccScriptType of LuaEngine used, it is always kScriptTypeLua. More... | |
LuaStack * | getLuaStack (void) |
Get LuaStack of the LuaEngine. More... | |
virtual void | addSearchPath (const char *path) |
Add a path to find Lua files in. More... | |
virtual void | addLuaLoader (lua_CFunction func) |
Add Lua loader. More... | |
virtual int | reload (const char *moduleFileName) |
Reload script code corresponding to moduleFileName. More... | |
virtual void | removeScriptObjectByObject (Ref *object) override |
Remove the related reference about the Ref object stored in the Lua table by set the value of corresponding key nil: The related Lua tables are toluafix_refid_ptr_mapping,toluafix_refid_type_mapping,tolua_value_root and object_Metatable["tolua_ubox"] or tolua_ubox. More... | |
virtual void | removeScriptHandler (int nHandler) override |
Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil. More... | |
virtual int | reallocateScriptHandler (int nHandler) override |
Reallocate Lua function reference index to the Lua function pointer to add reference. More... | |
virtual int | executeString (const char *codes) override |
Execute script code contained in the given string. More... | |
virtual int | executeScriptFile (const char *filename) override |
Execute a script file. More... | |
virtual int | executeGlobalFunction (const char *functionName) override |
Execute a scripted global function. More... | |
virtual bool | handleAssert (const char *msg) override |
Handle the assert message. More... | |
virtual bool | parseConfig (ConfigType type, const std::string &str) override |
Parse the config information data. More... | |
virtual int | sendEvent (ScriptEvent *message) override |
When some events triggered in the c++ also needs to pass on to lua to handle, we could call this function to send events. More... | |
virtual int | handleEvent (ScriptHandlerMgr::HandlerType type, void *data) |
Pass on the events related with ScrollView,TableCell,AssertManager, Armature, Accelerometer, Keyboard, Touch, Touches ,Mouse and Custom event to lua to handle. More... | |
virtual int | handleEvent (ScriptHandlerMgr::HandlerType type, void *data, int numResults, const std::function< void(lua_State *, int)> &func) |
Pass on the events related with TableCell and TableView to lua to handle. More... | |
Public Member Functions inherited from ScriptEngineProtocol | |
ScriptEngineProtocol () | |
Constructor of ScriptEngineProtocol. | |
virtual | ~ScriptEngineProtocol () |
Destructor of ScriptEngineProtocol. | |
virtual void | setCalledFromScript (bool callFromScript) |
Set whether the call comes from the script or not, only use for the js. More... | |
virtual bool | isCalledFromScript () |
Get the flag that represents whether the call comes from the script or not,only use for the js. More... | |
virtual void | rootObject (Ref *obj) |
Root a Reference. More... | |
virtual void | unrootObject (Ref *obj) |
Unroot a Reference. More... | |
Static Public Member Functions | |
static LuaEngine * | getInstance (void) |
Get instance of LuaEngine. More... | |
static LuaEngine * | defaultEngine (void) |
Get defaultEngine of LuaEngine, it was deprecated. More... | |
Additional Inherited Members | |
Public Types inherited from ScriptEngineProtocol | |
enum | ConfigType |
ConfigType enum. | |
The LuaEngine integrated into the cocos2d-x to process the interactive operation between lua and c++.
|
inlinestatic |
|
inlineoverridevirtual |
Get ccScriptType of LuaEngine used, it is always kScriptTypeLua.
kScriptTypeLua.
Reimplemented from ScriptEngineProtocol.
|
inline |
|
virtual |
Add a path to find Lua files in.
to be added to the Lua path.
|
virtual |
Add Lua loader.
a function pointer point to the loader function.
|
virtual |
Reload script code corresponding to moduleFileName.
If value of package["loaded"][moduleFileName] is existed, it would set the value nil.Then,it calls executeString function.
String object holding the filename of the script file that is to be executed. 0 if the string is executed correctly or other if the string is executed wrongly.
|
overridevirtual |
Remove the related reference about the Ref object stored in the Lua table by set the value of corresponding key nil: The related Lua tables are toluafix_refid_ptr_mapping,toluafix_refid_type_mapping,tolua_value_root and object_Metatable["tolua_ubox"] or tolua_ubox.
Meanwhile set the corresponding userdata nullptr and remove the all the lua function reference corresponding to this object.
In current mechanism, this function is called in the destructor of Ref object, developer don't call this functions.
the key object to remove script object.
Implements ScriptEngineProtocol.
|
overridevirtual |
Remove Lua function reference by nHandler by setting toluafix_refid_function_mapping[nHandle] nil.
the function refrence index to find the correspoinding Lua function pointer.
Reimplemented from ScriptEngineProtocol.
|
overridevirtual |
Reallocate Lua function reference index to the Lua function pointer to add reference.
the function refrence index to find the correspoinding Lua function pointer.
Reimplemented from ScriptEngineProtocol.
|
overridevirtual |
Execute script code contained in the given string.
holding the valid script code that should be executed. 0 if the string is executed correctly,other if the string is executed wrongly.
Implements ScriptEngineProtocol.
|
overridevirtual |
Execute a script file.
String object holding the filename of the script file that is to be executed. 0 if it happen error or it hasn't return value, otherwise return 1.
Implements ScriptEngineProtocol.
|
overridevirtual |
Execute a scripted global function.
The function should not take any parameters and should return an integer.
String object holding the name of the function, in the global script environment, that is to be executed. The integer value returned from the script function.
Implements ScriptEngineProtocol.
|
overridevirtual |
Handle the assert message.
return true if current _callFromLua of LuaStack is not equal to 0 otherwise return false.
Implements ScriptEngineProtocol.
|
overridevirtual |
Parse the config information data.
in current mechanism,it always ConfigType::COCOSTUDIO. the information data. if __onParseConfig function exist in the Lua, it return the value that _stack->executeFunction returns otherwise return false.
Implements ScriptEngineProtocol.
|
overridevirtual |
When some events triggered in the c++ also needs to pass on to lua to handle, we could call this function to send events.
the ScriptEvent object that has ScriptEventType and the pointer to information data. default return 0 otherwise return values the same as handleNodeEvent, handleMenuClickedEvent or handleCallFuncActionEvent,etc.
Implements ScriptEngineProtocol.
|
virtual |
Pass on the events related with ScrollView,TableCell,AssertManager, Armature, Accelerometer, Keyboard, Touch, Touches ,Mouse and Custom event to lua to handle.
Different ScriptHandlerMgr::HandlerType means different processing for the data. The pointer point to the information which should be pass on to lua, it would be parsed in the function to convert to the specific data according to the ScriptHandlerMgr::HandlerType,then pass to lua as function parameters. default return 0 otherwise return values according different ScriptHandlerMgr::HandlerType.
|
virtual |
Pass on the events related with TableCell and TableView to lua to handle.
Different ScriptHandlerMgr::HandlerType means different processing for the data. The pointer point to the information which should be pass on to lua, it would be parsed in the function to convert to the specific data according to the ScriptHandlerMgr::HandlerType,then pass to lua as function parameters. The number of the return values. The callback would be called when numResults is > 0. default return 0 otherwise return values according different ScriptHandlerMgr::HandlerType.