My Project
Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
CMonoScriptingState Class Reference

Mono scripting state. More...

#include <MonoScriptingState.h>

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

Public Member Functions

void Init ()
 call this function before calling anything else. More...
 
const char * GetName () const
 return the name of this runtime state. More...
 
MonoDomain * GetMonoDomain ()
 get the mono domain.
 
void LoadNPLLib ()
 load only NPL related functions.
 
void LoadParaLib ()
 load only Para related functions.
 
virtual void Release ()
 this is something like delete this
 
virtual void * GetState ()
 get the Mono Domain state. More...
 
virtual bool IsValid ()
 return true if the runtime state is valid
 
virtual bool IsScriptFileLoaded (const string &filepath)
 whether a given script file is loaded. More...
 
virtual bool LoadFile (const string &filePath, bool bReload)
 load a new CS script file without running it. More...
 
virtual int DoString (const char *sCall, int nLength=0)
 do string in the current state. More...
 
virtual NPL::NPLReturnCode ActivateFile (const string &filepath, const char *code=NULL, int nLength=0)
 Activate a local file. More...
 
virtual bool CreateState (const char *name, NPL::INPLRuntimeState *pState=0)
 load or restore the runtime state More...
 
virtual void DestroyState ()
 destroy the runtime state careful with this function, it will make the state invalid.
 
virtual void SetNPLRuntimeState (NPL::INPLRuntimeState *pState)
 set the NPL runtime state that this mono scripting state belongs to. More...
 
virtual NPL::INPLRuntimeStateGetNPLRuntimeState ()
 Get the NPL runtime state that this mono scripting state belongs to.
 
void Init ()
 call this function before calling anything else. More...
 
const char * GetName () const
 return the name of this runtime state. More...
 
MonoDomain * GetMonoDomain ()
 get the mono domain.
 
void LoadNPLLib ()
 load only NPL related functions.
 
void LoadParaLib ()
 load only Para related functions.
 
virtual void Release ()
 this is something like delete this
 
virtual void * GetState ()
 get the Mono Domain state. More...
 
virtual bool IsValid ()
 return true if the runtime state is valid
 
virtual bool IsScriptFileLoaded (const string &filepath)
 whether a given script file is loaded. More...
 
virtual bool LoadFile (const string &filePath, bool bReload)
 load a new CS script file without running it. More...
 
virtual int DoString (const char *sCall, int nLength=0)
 do string in the current state. More...
 
virtual NPL::NPLReturnCode ActivateFile (const string &filepath, const char *code=NULL, int nLength=0)
 Activate a local file. More...
 
virtual bool CreateState (const char *name, NPL::INPLRuntimeState *pState=0)
 load or restore the runtime state More...
 
virtual void DestroyState ()
 destroy the runtime state careful with this function, it will make the state invalid.
 
virtual void SetNPLRuntimeState (NPL::INPLRuntimeState *pState)
 set the NPL runtime state that this mono scripting state belongs to. More...
 
virtual NPL::INPLRuntimeStateGetNPLRuntimeState ()
 Get the NPL runtime state that this mono scripting state belongs to.
 
- Public Member Functions inherited from NPL::INPLScriptingState
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 NPL::NPLReturnCode ActivateFile (const std::string &filepath, const char *code=NULL, int nLength=0)=0
 Activate a local file. More...
 

Protected Member Functions

void CreateAppDomain ()
 it is safe to call this multiple times. More...
 
void CreateAppDomain ()
 it is safe to call this multiple times. More...
 

Static Protected Member Functions

static const char * GetStringProperty (const char *propertyName, MonoClass *classType, MonoObject *classObject)
 

Detailed Description

Mono scripting state.

Member Function Documentation

§ ActivateFile() [1/2]

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

Activate a local file.

The file should be loaded already.

Parameters
filepathpointer to the file path.
Returns
: NPLReturnCode

§ ActivateFile() [2/2]

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

Activate a local file.

The file should be loaded already.

Parameters
filepathpointer to the file path.
Returns
: NPLReturnCode

§ CreateAppDomain() [1/2]

void CMonoScriptingState::CreateAppDomain ( )
protected

it is safe to call this multiple times.

however only the first time does the init. it will set the mono dir and load the mono configuration for all mono domains.

§ CreateAppDomain() [2/2]

void CMonoScriptingState::CreateAppDomain ( )
protected

it is safe to call this multiple times.

however only the first time does the init. it will set the mono dir and load the mono configuration for all mono domains.

in 3.8 which fixed following configuration exception under win32. System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.

§ CreateState() [1/2]

virtual bool CMonoScriptingState::CreateState ( const char *  name,
NPL::INPLRuntimeState pState = 0 
)
virtual

load or restore the runtime state

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

Implements NPL::INPLScriptingState.

§ CreateState() [2/2]

bool CMonoScriptingState::CreateState ( const char *  name,
NPL::INPLRuntimeState pState = 0 
)
virtual

load or restore the runtime state

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

The official doc says: If your applications has threads that will access Mono, access Mono variables, point to Mono objects, be called back by Mono, these threads must be registered with the Mono runtime using the mono_thread_attach

Implements NPL::INPLScriptingState.

§ DoString() [1/2]

virtual int CMonoScriptingState::DoString ( const char *  sCall,
int  nLength = 0 
)
virtual

do string in the current state.

This function is usually called from the scripting interface.

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.

Implements NPL::INPLScriptingState.

§ DoString() [2/2]

int CMonoScriptingState::DoString ( const char *  sCall,
int  nLength = 0 
)
virtual

do string in the current state.

This function is usually called from the scripting interface.

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.

Implements NPL::INPLScriptingState.

§ GetName() [1/2]

const char* CMonoScriptingState::GetName ( ) const

return the name of this runtime state.

if "", it is considered an anonymous name

§ GetName() [2/2]

const char * CMonoScriptingState::GetName ( ) const

return the name of this runtime state.

if "", it is considered an anonymous name

§ GetState() [1/2]

virtual void* CMonoScriptingState::GetState ( )
inlinevirtual

get the Mono Domain state.

Returns
MonoDomain *

Implements NPL::INPLScriptingState.

§ GetState() [2/2]

virtual void* CMonoScriptingState::GetState ( )
inlinevirtual

get the Mono Domain state.

Returns
MonoDomain *

Implements NPL::INPLScriptingState.

§ Init() [1/2]

void CMonoScriptingState::Init ( )

call this function before calling anything else.

It will load all NPL modules into the runtime state.

§ Init() [2/2]

void CMonoScriptingState::Init ( void  )

call this function before calling anything else.

It will load all NPL modules into the runtime state.

§ IsScriptFileLoaded() [1/2]

virtual bool CMonoScriptingState::IsScriptFileLoaded ( const string &  filepath)
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.

§ IsScriptFileLoaded() [2/2]

bool CMonoScriptingState::IsScriptFileLoaded ( const string &  filepath)
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() [1/2]

virtual bool CMonoScriptingState::LoadFile ( const string &  filePath,
bool  bReload 
)
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.

§ LoadFile() [2/2]

bool CMonoScriptingState::LoadFile ( const string &  filePath,
bool  bReload 
)
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() [1/2]

virtual void CMonoScriptingState::SetNPLRuntimeState ( NPL::INPLRuntimeState pState)
virtual

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

This function is used internally by NPLRuntimeState.

Implements NPL::INPLScriptingState.

§ SetNPLRuntimeState() [2/2]

void CMonoScriptingState::SetNPLRuntimeState ( NPL::INPLRuntimeState pState)
virtual

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

This function is used internally by NPLRuntimeState.

Implements NPL::INPLScriptingState.


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