Don't make ScriptEngineProtocol inherits from Object since setScriptEngine is invoked only once in AppDelegate.cpp, It will affect the lifecycle of ScriptEngine instance, the autorelease pool will be destroyed before destructing ScriptEngine.
More...
#include <ScriptSupport.h>
|
| ScriptEngineProtocol () |
| Constructor of ScriptEngineProtocol.
|
|
virtual | ~ScriptEngineProtocol () |
| Destructor of ScriptEngineProtocol.
|
|
virtual ccScriptType | getScriptType () |
| Get the specific script type.
|
|
virtual void | retainScriptObject (Object *, Object *) |
| Reflect the retain relationship to script scope.
|
|
virtual void | rootScriptObject (Object *) |
| Add the script object to root object.
|
|
virtual void | releaseScriptObject (Object *, Object *) |
| Reflect the release relationship to script scope.
|
|
virtual void | unrootScriptObject (Object *) |
| Remove the script object from root object.
|
|
virtual void | releaseAllChildrenRecursive (Node *) |
| Release all children native refs for the given node in script scope.
|
|
virtual void | releaseAllNativeRefs (ax::Object *) |
| Release all native refs for the given owner in script scope.
|
|
virtual void | removeScriptObjectByObject (Object *) |
| Remove script object,The specific meaning should refer to the ScriptType.
|
|
virtual void | removeScriptHandler (int) |
| Remove script function handler, only LuaEngine class need to implement this function.
|
|
virtual int | reallocateScriptHandler (int) |
| Reallocate script function handler, only LuaEngine class need to implement this function.
|
|
virtual int | executeString (const char *codes)=0 |
| Execute script code contained in the given string.
|
|
virtual int | executeScriptFile (const char *filename)=0 |
| Execute a script file.
|
|
virtual int | executeGlobalFunction (const char *functionName)=0 |
| Execute a scripted global function.
|
|
virtual int | sendEvent (const ScriptEvent &evt)=0 |
| 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 | handleAssert (const char *msg)=0 |
| Handle the assert message.
|
|
virtual void | setCalledFromScript (bool) |
| Useless for Lua.
|
|
virtual bool | isCalledFromScript () |
| Useless for Lua.
|
|
virtual bool | parseConfig (ConfigType type, std::string_view str)=0 |
| Parse configuration file.
|
|
virtual void | rootObject (Object *) |
| Root a Reference.
|
|
virtual void | unrootObject (Object *) |
| Unroot a Reference.
|
|
virtual void | removeObjectProxy (Object *obj) |
| Remove proxy for a native object.
|
|
virtual void | garbageCollect () |
| Triggers the garbage collector.
|
|
Don't make ScriptEngineProtocol inherits from Object since setScriptEngine is invoked only once in AppDelegate.cpp, It will affect the lifecycle of ScriptEngine instance, the autorelease pool will be destroyed before destructing ScriptEngine.
So a crash will appear on Win32 if you click the close button. @js NA
◆ ScriptEngineProtocol()
◆ ~ScriptEngineProtocol()
◆ getScriptType()
virtual ccScriptType getScriptType |
( |
| ) |
|
|
inlinevirtual |
Get the specific script type.
- Returns
- the specific script type.
@lua NA @js NA
◆ removeScriptObjectByObject()
virtual void removeScriptObjectByObject |
( |
Object * | | ) |
|
|
inlinevirtual |
Remove script object,The specific meaning should refer to the ScriptType.
For Lua,
- See also
- removeScriptObjectByObject of LuaEngine.
@lua NA @js NA
◆ removeScriptHandler()
virtual void removeScriptHandler |
( |
int | | ) |
|
|
inlinevirtual |
Remove script function handler, only LuaEngine class need to implement this function.
- See also
- removeScriptHandler of LuaEngine. @lua NA @js NA
◆ reallocateScriptHandler()
virtual int reallocateScriptHandler |
( |
int | | ) |
|
|
inlinevirtual |
Reallocate script function handler, only LuaEngine class need to implement this function.
- See also
- reallocateScriptHandler of LuaEngine. @lua NA @js NA
◆ executeString()
virtual int executeString |
( |
const char * | codes | ) |
|
|
pure virtual |
Execute script code contained in the given string.
- Parameters
-
codes | holding the valid script code that should be executed. |
- Returns
- 0 if the string is executed correctly.
-
other if the string is executed wrongly. @lua NA @js NA
◆ executeScriptFile()
virtual int executeScriptFile |
( |
const char * | filename | ) |
|
|
pure virtual |
Execute a script file.
- Parameters
-
filename | String object holding the filename of the script file that is to be executed. |
- Returns
- 0 if it happen the error or it hasn't return value, otherwise it return the value by calling the lua function. @lua NA @js NA
◆ executeGlobalFunction()
virtual int executeGlobalFunction |
( |
const char * | functionName | ) |
|
|
pure virtual |
Execute a scripted global function.
The function should not take any parameters and should return an integer.
- Parameters
-
functionName | String 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. @lua NA @js NA
◆ sendEvent()
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.
@lua NA @js NA
◆ handleAssert()
virtual bool handleAssert |
( |
const char * | msg | ) |
|
|
pure virtual |
Handle the assert message.
- Returns
- true if the assert was handled by the script engine, false otherwise.
@lua NA @js NA
◆ setCalledFromScript()
virtual void setCalledFromScript |
( |
bool | | ) |
|
|
inlinevirtual |
Useless for Lua.
@lua NA @js NA
◆ isCalledFromScript()
virtual bool isCalledFromScript |
( |
| ) |
|
|
inlinevirtual |
Useless for Lua.
@lua NA @js NA
◆ parseConfig()
virtual bool parseConfig |
( |
ConfigType | type, |
|
|
std::string_view | str ) |
|
pure virtual |
Parse configuration file.
- Parameters
-
type | the specific type value. |
str | the information data. |
@lua NA @js NA
◆ rootObject()
virtual void rootObject |
( |
Object * | | ) |
|
|
inlinevirtual |
Root a Reference.
It tells the Garbage Collector that the associated Scripting object should not be collected
◆ unrootObject()
virtual void unrootObject |
( |
Object * | | ) |
|
|
inlinevirtual |
Unroot a Reference.
It tells the Garbage Collector that the associated Scripting object can be collected
The documentation for this class was generated from the following file: