mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-22 18:22:20 +00:00
Кеширование всех событий, полей, свойств и методов класса включая родительские
This commit is contained in:
parent
488bb0ed4c
commit
a79c28940a
@ -16,12 +16,74 @@ CMonoClass::CMonoClass( MonoClass* pMonoClass, CMonoDomain* pDomain )
|
|||||||
{
|
{
|
||||||
this->m_pClass = pMonoClass;
|
this->m_pClass = pMonoClass;
|
||||||
this->m_pDomain = pDomain;
|
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 )
|
CMonoClass::~CMonoClass( void )
|
||||||
{
|
{
|
||||||
|
this->m_pDomain->ReleaseClass( this );
|
||||||
|
|
||||||
this->m_pDomain = nullptr;
|
this->m_pDomain = nullptr;
|
||||||
this->m_pClass = 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 )
|
MonoObject* CMonoClass::New( void )
|
||||||
@ -111,3 +173,13 @@ MonoMethod* CMonoClass::GetMethod( const char* szMethodName )
|
|||||||
|
|
||||||
return nullptr;
|
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;
|
||||||
|
}
|
@ -17,31 +17,44 @@ class CMonoClass;
|
|||||||
|
|
||||||
#include "CMonoDomain.h"
|
#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
|
class CMonoClass
|
||||||
{
|
{
|
||||||
private:
|
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:
|
public:
|
||||||
CMonoClass ( MonoClass* pMonoClass, CMonoDomain* pDomain );
|
CMonoClass ( MonoClass* pMonoClass, CMonoDomain* pDomain );
|
||||||
~CMonoClass ( void );
|
~CMonoClass ( void );
|
||||||
|
|
||||||
MonoObject* New ( void );
|
MonoObject* New ( void );
|
||||||
MonoObject* New ( SColor& pColor );
|
MonoObject* New ( SColor& pColor );
|
||||||
MonoObject* New ( Vector2& vecVector );
|
MonoObject* New ( Vector2& vecVector );
|
||||||
MonoObject* New ( Vector3& vecVector );
|
MonoObject* New ( Vector3& vecVector );
|
||||||
MonoObject* New ( void** args, int argc );
|
MonoObject* New ( void** args, int argc );
|
||||||
|
|
||||||
const char* GetName ( void );
|
const char* GetName ( void );
|
||||||
const char* GetNameSpace ( void );
|
const char* GetNameSpace ( void );
|
||||||
|
|
||||||
MonoMethod* GetMethod ( const char* szMethodName, int iParamCount );
|
MonoMethod* GetMethod ( const char* szMethodName, int iParamCount );
|
||||||
MonoMethod* GetMethod ( const char* szMethodName );
|
MonoMethod* GetMethod ( const char* szMethodName );
|
||||||
|
|
||||||
MonoClass* GetMonoPtr ( void ) { return this->m_pClass; }
|
MonoEvent* GetEvent ( const char* szEventName );
|
||||||
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
|
MonoClassField* GetField ( const char* szFieldName );
|
||||||
|
|
||||||
|
MonoClass* GetMonoPtr ( void ) { return this->m_pClass; }
|
||||||
|
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user