Cocos2d-x  v3.11
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
ScriptEngineProtocol Class Referenceabstract

Don't make ScriptEngineProtocol inherits from Ref 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...

Inherited by LuaEngine, and ScriptingCore.

Public Types

enum  ConfigType
 ConfigType enum.
 

Public Member Functions

 ScriptEngineProtocol ()
 Constructor of ScriptEngineProtocol.
 
virtual ~ScriptEngineProtocol ()
 Destructor of ScriptEngineProtocol.
 
virtual ccScriptType getScriptType ()
 Get the specific script type. More...
 
virtual void retainScriptObject (Ref *owner, Ref *target)
 Reflect the retain relationship to script scope.
 
virtual void rootScriptObject (Ref *target)
 Add the script object to root object.
 
virtual void releaseScriptObject (Ref *owner, Ref *target)
 Reflect the release relationship to script scope.
 
virtual void unrootScriptObject (Ref *target)
 Remove the script object from root object.
 
virtual void releaseAllChildrenRecursive (Node *node)
 Release all children native refs for the given node in script scope.
 
virtual void releaseAllNativeRefs (cocos2d::Ref *owner)
 Release all native refs for the given owner in script scope.
 
virtual void removeScriptObjectByObject (Ref *obj)
 Remove script object,the specific meaning should refer to the ScriptType. More...
 
virtual void removeScriptHandler (int handler)
 Remove script function handler, only LuaEngine class need to implement this function.
 
virtual int reallocateScriptHandler (int handler)
 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. More...
 
virtual int executeScriptFile (const char *filename)=0
 Execute a script file. More...
 
virtual int executeGlobalFunction (const char *functionName)=0
 Execute a scripted global function. More...
 
virtual int sendEvent (ScriptEvent *evt)=0
 When some events triggered in the c++ also needs to pass into script ,call this func.The ScriptEvent contains the data need to passed into the script.
 
virtual bool handleAssert (const char *msg)=0
 Handle the assert message. More...
 
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 bool parseConfig (ConfigType type, const std::string &str)=0
 Parse configuration file. More...
 
virtual void rootObject (Ref *obj)
 Root a Reference. More...
 
virtual void unrootObject (Ref *obj)
 Unroot a Reference. More...
 
virtual void garbageCollect ()
 Triggers the garbage collector.
 

Detailed Description

Don't make ScriptEngineProtocol inherits from Ref 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.

Member Function Documentation

virtual ccScriptType getScriptType ( )
inlinevirtual

Get the specific script type.

the specific script type.

Reimplemented in ScriptingCore, and LuaEngine.

virtual void
removeScriptObjectByObject
( Ref obj)
inlinevirtual

Remove script object,the specific meaning should refer to the ScriptType.

For Lua,

See also
removeScriptObjectByObject of LuaEngine

Reimplemented in LuaEngine, and ScriptingCore.

virtual int executeString ( const char *  codes)
pure virtual

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.

Implemented in LuaEngine, and ScriptingCore.

virtual int executeScriptFile ( const char *  filename)
pure virtual

Execute a script file.

String object holding the filename of the script file that is to be executed. 0 if it happen the error or it hasn't return value, otherwise it return the value by calling the lua function.

Implemented in LuaEngine, and ScriptingCore.

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 for Lua.

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.

Implemented in LuaEngine, and ScriptingCore.

virtual bool handleAssert ( const char *  msg)
pure virtual

Handle the assert message.

return true if current _callFromLua of LuaStack is not equal to 0 otherwise return false for Lua.

Implemented in LuaEngine, and ScriptingCore.

virtual void setCalledFromScript ( bool  callFromScript)
inlinevirtual

Set whether the call comes from the script or not, only use for the js.

whether the call comes from the script or not.

Reimplemented in ScriptingCore.

virtual bool isCalledFromScript ( )
inlinevirtual

Get the flag that represents whether the call comes from the script or not,only use for the js.

false.

Reimplemented in ScriptingCore.

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

Parse configuration file.

the specific type value. the information data.

Implemented in LuaEngine, and ScriptingCore.

virtual void rootObject ( Ref obj)
inlinevirtual

Root a Reference.

It tells the Garbage Collector that the associated Scripting object should not be collected

Reimplemented in ScriptingCore.

virtual void unrootObject ( Ref obj)
inlinevirtual

Unroot a Reference.

It tells the Garbage Collector that the associated Scripting object can be collected

Reimplemented in ScriptingCore.


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