From a79c28940a9250745c32ce2fce40706bdc31b7f6 Mon Sep 17 00:00:00 2001 From: Kernell Date: Mon, 30 Nov 2015 06:25:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=B5=D1=88=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=81=D0=B5=D1=85=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D1=8B=D1=82=D0=B8=D0=B9,=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9,=20=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=20?= =?UTF-8?q?=D0=B8=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20=D0=B2=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=BE=D0=B4=D0=B8=D1=82=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D1=81=D0=BA=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mta-mono/src/CMonoClass.cpp | 72 +++++++++++++++++++++++++++++++++++++ mta-mono/src/CMonoClass.h | 43 ++++++++++++++-------- 2 files changed, 100 insertions(+), 15 deletions(-) diff --git a/mta-mono/src/CMonoClass.cpp b/mta-mono/src/CMonoClass.cpp index e14d04f..59115b8 100644 --- a/mta-mono/src/CMonoClass.cpp +++ b/mta-mono/src/CMonoClass.cpp @@ -16,12 +16,74 @@ CMonoClass::CMonoClass( MonoClass* pMonoClass, CMonoDomain* pDomain ) { this->m_pClass = pMonoClass; this->m_pDomain = pDomain; + + MonoClass *pMonoBaseClass = pMonoClass; + + while( pMonoBaseClass ) + { + gpointer iter = nullptr; + + while( MonoMethod* pMonoMethod = mono_class_get_methods( pMonoBaseClass, &iter ) ) + { + const char* szName = mono_method_get_name( pMonoMethod ); + + this->m_Methods[ szName ].push_back( pMonoMethod ); + } + + iter = nullptr; + + while( MonoProperty* pMonoProperty = mono_class_get_properties( pMonoBaseClass, &iter ) ) + { + const char* szName = mono_property_get_name( pMonoProperty ); + + this->m_Properties[ szName ].push_back( pMonoProperty ); + } + + iter = nullptr; + + while( MonoEvent* pMonoEvent = mono_class_get_events( pMonoBaseClass, &iter ) ) + { + const char* szName = mono_event_get_name( pMonoEvent ); + + this->m_Events[ szName ] = pMonoEvent; + } + + iter = nullptr; + + while( MonoClassField* pMonoField = mono_class_get_fields( pMonoBaseClass, &iter ) ) + { + const char* szName = mono_field_get_name( pMonoField ); + + this->m_Fields[ szName ] = pMonoField; + } + + pMonoBaseClass = mono_class_get_parent( pMonoBaseClass ); + } } CMonoClass::~CMonoClass( void ) { + this->m_pDomain->ReleaseClass( this ); + this->m_pDomain = nullptr; this->m_pClass = nullptr; + + this->m_Fields.clear(); + this->m_Events.clear(); + + for( auto iter : this->m_Properties ) + { + iter.second.clear(); + } + + this->m_Properties.clear(); + + for( auto iter : this->m_Methods ) + { + iter.second.clear(); + } + + this->m_Methods.clear(); } MonoObject* CMonoClass::New( void ) @@ -110,4 +172,14 @@ MonoMethod* CMonoClass::GetMethod( const char* szMethodName ) } return nullptr; +} + +MonoEvent* CMonoClass::GetEvent( const char* szEventName ) +{ + return this->m_Events.count( szEventName ) > 0 ? this->m_Events[ szEventName ] : nullptr; +} + +MonoClassField* CMonoClass::GetField( const char* szFieldName ) +{ + return this->m_Fields.count( szFieldName ) > 0 ? this->m_Fields[ szFieldName ] : nullptr; } \ No newline at end of file diff --git a/mta-mono/src/CMonoClass.h b/mta-mono/src/CMonoClass.h index 3fe7cc9..6b89fda 100644 --- a/mta-mono/src/CMonoClass.h +++ b/mta-mono/src/CMonoClass.h @@ -17,31 +17,44 @@ class CMonoClass; #include "CMonoDomain.h" +typedef map< const char*, list< MonoMethod* > > MonoMethodMap; +typedef map< const char*, list< MonoProperty* > > MonoPropertyMap; +typedef map< const char*, MonoEvent* > MonoEventMap; +typedef map< const char*, MonoClassField* > MonoClassFieldMap; + class CMonoClass { private: - MonoClass* m_pClass; + MonoClass* m_pClass; - CMonoDomain* m_pDomain; + CMonoDomain* m_pDomain; + + MonoEventMap m_Events; + MonoMethodMap m_Methods; + MonoPropertyMap m_Properties; + MonoClassFieldMap m_Fields; public: - CMonoClass ( MonoClass* pMonoClass, CMonoDomain* pDomain ); - ~CMonoClass ( void ); + CMonoClass ( MonoClass* pMonoClass, CMonoDomain* pDomain ); + ~CMonoClass ( void ); - MonoObject* New ( void ); - MonoObject* New ( SColor& pColor ); - MonoObject* New ( Vector2& vecVector ); - MonoObject* New ( Vector3& vecVector ); - MonoObject* New ( void** args, int argc ); + MonoObject* New ( void ); + MonoObject* New ( SColor& pColor ); + MonoObject* New ( Vector2& vecVector ); + MonoObject* New ( Vector3& vecVector ); + MonoObject* New ( void** args, int argc ); - const char* GetName ( void ); - const char* GetNameSpace ( void ); + const char* GetName ( void ); + const char* GetNameSpace ( void ); - MonoMethod* GetMethod ( const char* szMethodName, int iParamCount ); - MonoMethod* GetMethod ( const char* szMethodName ); + MonoMethod* GetMethod ( const char* szMethodName, int iParamCount ); + MonoMethod* GetMethod ( const char* szMethodName ); - MonoClass* GetMonoPtr ( void ) { return this->m_pClass; } - CMonoDomain* GetDomain ( void ) { return this->m_pDomain; } + MonoEvent* GetEvent ( const char* szEventName ); + MonoClassField* GetField ( const char* szFieldName ); + + MonoClass* GetMonoPtr ( void ) { return this->m_pClass; } + CMonoDomain* GetDomain ( void ) { return this->m_pDomain; } }; #endif \ No newline at end of file