Добавление и удаление классов из пула

This commit is contained in:
Kernell 2015-11-30 06:23:18 +03:00
parent 1dc1390070
commit 488bb0ed4c
2 changed files with 27 additions and 7 deletions

View File

@ -14,10 +14,15 @@
CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
{
this->m_pClass = nullptr;
this->m_pObject = nullptr;
this->m_pAssembly = nullptr;
this->m_pImage = nullptr;
this->m_pDomain = pDomain;
this->m_uiGCHandle = 0;
string strPath( CMonoInterface::GetBinariesDirectory() + "/" + pDomain->GetResource()->GetName() + "/MultiTheftAuto.dll" );
this->m_pAssembly = pDomain->OpenAssembly( strPath.c_str() );
@ -32,15 +37,13 @@ CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
this->Vector2 = this->GetClass( "Vector2" );
this->Vector3 = this->GetClass( "Vector3" );
MonoClass* pMonoClass = mono_class_from_name( this->m_pImage, "MultiTheftAuto", "MultiTheftAuto" );
this->m_pClass = this->GetClass( "MultiTheftAuto" );
if( pMonoClass )
if( this->m_pClass )
{
MonoObject* pMonoObject = this->m_pDomain->CreateObject( pMonoClass );
mono_gchandle_new( pMonoObject, false );
mono_runtime_object_init( pMonoObject );
this->m_pObject = this->m_pClass->New();
//this->m_uiGCHandle = mono_gchandle_new( this->m_pObject, true );
}
}
}
@ -48,9 +51,22 @@ CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
CMonoMTALib::~CMonoMTALib( void )
{
if( this->m_uiGCHandle )
{
mono_gchandle_free( this->m_uiGCHandle );
this->m_uiGCHandle = 0;
}
SAFE_DELETE( this->Color );
SAFE_DELETE( this->Vector2 );
SAFE_DELETE( this->Vector3 );
SAFE_DELETE( this->m_pClass );
this->m_pDomain = nullptr;
this->m_pAssembly = nullptr;
this->m_pImage = nullptr;
this->m_pObject = nullptr;
}
CMonoClass* CMonoMTALib::GetClass( const char* szName )

View File

@ -23,8 +23,12 @@ class CMonoMTALib
private:
MonoAssembly* m_pAssembly;
MonoImage* m_pImage;
MonoObject* m_pObject;
CMonoClass* m_pClass;
CMonoDomain* m_pDomain;
uint32_t m_uiGCHandle;
public:
CMonoClass* Color;
CMonoClass* Vector2;