Добавлен поиск и получение метода по имени из кэша класса

This commit is contained in:
Kernell 2015-12-01 00:04:40 +03:00
parent 14eae5496a
commit 3001c4cd55
2 changed files with 35 additions and 16 deletions

View File

@ -153,14 +153,14 @@ const char* CMonoClass::GetNameSpace( void )
return mono_class_get_namespace( this->m_pClass );
}
MonoMethod* CMonoClass::GetMethod( const char* szMethodName, int iParamCount )
MonoMethod* CMonoClass::GetMethodFromName( string strMethodName, int iParamCount )
{
return mono_class_get_method_from_name( this->m_pClass, szMethodName, iParamCount );
return mono_class_get_method_from_name( this->m_pClass, strMethodName.c_str(), iParamCount );
}
MonoMethod* CMonoClass::GetMethod( const char* szMethodName )
MonoMethod* CMonoClass::GetMethod( string strMethodName )
{
MonoMethodDesc* pMonoMethodDesc = mono_method_desc_new( szMethodName, false );
MonoMethodDesc* pMonoMethodDesc = mono_method_desc_new( strMethodName.c_str(), false );
if( pMonoMethodDesc )
{
@ -174,12 +174,30 @@ MonoMethod* CMonoClass::GetMethod( const char* szMethodName )
return nullptr;
}
MonoEvent* CMonoClass::GetEvent( const char* szEventName )
MonoMethod* CMonoClass::GetMethod( string strMethodName, uint uiIndex )
{
return this->m_Events.count( szEventName ) > 0 ? this->m_Events[ szEventName ] : nullptr;
if( this->m_Methods[ strMethodName ].size() > 0 )
{
uint i = 0;
for( auto ptr : this->m_Methods[ strMethodName ] )
{
if( i++ == uiIndex )
{
return ptr;
}
}
}
return nullptr;
}
MonoClassField* CMonoClass::GetField( const char* szFieldName )
MonoEvent* CMonoClass::GetEvent( string strEventName )
{
return this->m_Fields.count( szFieldName ) > 0 ? this->m_Fields[ szFieldName ] : nullptr;
return this->m_Events[ strEventName ];
}
MonoClassField* CMonoClass::GetField( string strFieldName )
{
return this->m_Fields[ strFieldName ];
}

View File

@ -17,10 +17,10 @@ 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;
typedef map< string, list< MonoMethod* > > MonoMethodMap;
typedef map< string, list< MonoProperty* > > MonoPropertyMap;
typedef map< string, MonoEvent* > MonoEventMap;
typedef map< string, MonoClassField* > MonoClassFieldMap;
class CMonoClass
{
@ -47,11 +47,12 @@ public:
const char* GetName ( void );
const char* GetNameSpace ( void );
MonoMethod* GetMethod ( const char* szMethodName, int iParamCount );
MonoMethod* GetMethod ( const char* szMethodName );
MonoMethod* GetMethodFromName ( string strMethodName, int iParamCount );
MonoMethod* GetMethod ( string strMethodName );
MonoMethod* GetMethod ( string strMethodName, uint uiIndex );
MonoEvent* GetEvent ( const char* szEventName );
MonoClassField* GetField ( const char* szFieldName );
MonoEvent* GetEvent ( string strEventName );
MonoClassField* GetField ( string strFieldName );
MonoClass* GetMonoPtr ( void ) { return this->m_pClass; }
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }