My Project
Public Member Functions | List of all members
NPL::INPLScriptingState Class Referenceabstract

NPLScriptingState interface. More...

#include <INPLScriptingState.h>

Inheritance diagram for NPL::INPLScriptingState:
NPL::IMonoScriptingState CMonoScriptingState CMonoScriptingState

Public Member Functions

virtual void Release ()=0
 this is something like delete this
 
virtual void * GetState ()=0
 get the Mono Domain state. More...
 
virtual bool IsValid ()=0
 return true if the runtime state is valid
 
virtual bool IsScriptFileLoaded (const std::string &filepath)=0
 whether a given script file is loaded. More...
 
virtual bool LoadFile (const std::string &filePath, bool bReload)=0
 load a new CS script file without running it. More...
 
virtual int DoString (const char *sCall, int nLength=0)=0
 do string in the current state. More...
 
virtual NPL::NPLReturnCode ActivateFile (const std::string &filepath, const char *code=NULL, int nLength=0)=0
 Activate a local file. More...
 
virtual bool CreateState (const char *name, INPLRuntimeState *pState=NULL)=0
 load or restore the runtime state More...
 
virtual void DestroyState ()=0
 destroy the runtime state careful with this function, it will make the state invalid.
 
virtual void SetNPLRuntimeState (INPLRuntimeState *pState)=0
 set the NPL runtime state that this mono scripting state belongs to. More...
 
virtual INPLRuntimeStateGetNPLRuntimeState ()=0
 Get the NPL runtime state that this mono scripting state belongs to.
 

Detailed Description

NPLScriptingState interface.

Implement this to support additional languages inside NPLRuntimeState. Please note that we use const std::string& for filename, which means that implementation of this interface should most probably use std::map<std::string filename, file_instance> for keeping loaded files as well. It can save us one std::string copy instruction when these API are called.

Member Function Documentation

§ ActivateFile()

virtual NPL::NPLReturnCode NPL::INPLScriptingState::ActivateFile ( const std::string &  filepath,
const char *  code = NULL,
int  nLength = 0 
)
pure virtual

Activate a local file.

The file should be loaded already.

Parameters
filepathpointer to the file path.
Returns
: NPLReturnCode

§ CreateState()

virtual bool NPL::INPLScriptingState::CreateState ( const char *  name,
INPLRuntimeState pState = NULL 
)
pure virtual

load or restore the runtime state

Parameters
nameany runtime state name.
pStatethe NPL runtime state that this mono scripting state belongs to.

Implemented in CMonoScriptingState, and CMonoScriptingState.

§ DoString()

virtual int NPL::INPLScriptingState::DoString ( const char *  sCall,
int  nLength = 0 
)
pure virtual

do string in the current state.

This function is usually called from the scripting interface. If one do not want to implement DoString for security reasons. Just put do nothing and return NPL_OK.

Parameters
sCallthe string to executed.
nLengthlength in bytes.if this is 0, length will be calculated, but must be smaller than a predefined safe length. If this is positive. any string length is allowed.

Implemented in CMonoScriptingState, and CMonoScriptingState.

§ GetState()

virtual void* NPL::INPLScriptingState::GetState ( )
pure virtual

get the Mono Domain state.

Returns
MonoDomain *

Implemented in CMonoScriptingState, and CMonoScriptingState.

§ IsScriptFileLoaded()

virtual bool NPL::INPLScriptingState::IsScriptFileLoaded ( const std::string &  filepath)
pure virtual

whether a given script file is loaded.

Parameters
filePaththe local file path in the following format: [dir0]/[dir1]/[dir2]/[filename.lua]
Returns
: return true if file is already loaded in the current state.

§ LoadFile()

virtual bool NPL::INPLScriptingState::LoadFile ( const std::string &  filePath,
bool  bReload 
)
pure virtual

load a new CS script file without running it.

If the file is already loaded, it will not be loaded again.

Parameters
filePaththe local CS script file path, such as "test.dll/test.cs", "test.dll/ParaMono.test.cs", where ParaMono can be a namespace.
bReloadif true, the file will be reloaded even if it is already loaded. otherwise, the file will only be loaded if it is not loaded yet.
Returns
: return true, if file is loaded.

§ SetNPLRuntimeState()

virtual void NPL::INPLScriptingState::SetNPLRuntimeState ( INPLRuntimeState pState)
pure virtual

set the NPL runtime state that this mono scripting state belongs to.

This function is used internally by NPLRuntimeState.

Implemented in CMonoScriptingState, and CMonoScriptingState.


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