Commit 568b600c authored by Aleksey R.'s avatar Aleksey R.

Merge branch 'dev-1.0' of https://githomelab.ru/kdlibcpp/kdlibcpp into dev-1.0

parents 7fe500ff 65930b33
...@@ -93,6 +93,7 @@ public: ...@@ -93,6 +93,7 @@ public:
virtual TypeInfoPtr getMethod( const std::wstring &name, const std::wstring& prototype = L"") = 0; virtual TypeInfoPtr getMethod( const std::wstring &name, const std::wstring& prototype = L"") = 0;
virtual TypeInfoPtr getMethod( const std::wstring &name, TypeInfoPtr prototype) = 0; virtual TypeInfoPtr getMethod( const std::wstring &name, TypeInfoPtr prototype) = 0;
virtual TypeInfoPtr getMethod( size_t index ) = 0; virtual TypeInfoPtr getMethod( size_t index ) = 0;
virtual std::wstring getMethodName(size_t index) = 0;
virtual size_t getMethodsCount() = 0; virtual size_t getMethodsCount() = 0;
virtual TypeInfoPtr getBaseClass( const std::wstring& className) = 0; virtual TypeInfoPtr getBaseClass( const std::wstring& className) = 0;
......
...@@ -183,6 +183,10 @@ protected: ...@@ -183,6 +183,10 @@ protected:
NOT_IMPLEMENTED(); NOT_IMPLEMENTED();
} }
virtual std::wstring getMethodName(size_t index) {
NOT_IMPLEMENTED();
}
virtual size_t getMethodsCount() { virtual size_t getMethodsCount() {
NOT_IMPLEMENTED(); NOT_IMPLEMENTED();
} }
......
...@@ -1167,6 +1167,21 @@ TypeInfoPtr TypeInfoUdt::getMethod(size_t index) ...@@ -1167,6 +1167,21 @@ TypeInfoPtr TypeInfoUdt::getMethod(size_t index)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
std::wstring TypeInfoUdt::getMethodName(size_t index)
{
SymbolPtrList methods = m_symbol->findChildren(SymTagFunction);
if (index >= methods.size())
throw IndexException(index);
SymbolPtrList::iterator it = methods.begin();
std::advance(it, index);
return (*it)->getName();
}
///////////////////////////////////////////////////////////////////////////////
size_t TypeInfoUdt::getMethodsCount() size_t TypeInfoUdt::getMethodsCount()
{ {
SymbolPtrList methods = m_symbol->findChildren(SymTagFunction); SymbolPtrList methods = m_symbol->findChildren(SymTagFunction);
......
...@@ -190,6 +190,10 @@ protected: ...@@ -190,6 +190,10 @@ protected:
throw TypeException( getName(), L"type has no methods" ); throw TypeException( getName(), L"type has no methods" );
} }
virtual std::wstring getMethodName(size_t index) {
throw TypeException(getName(), L"type has no methods");
}
virtual size_t getMethodsCount() { virtual size_t getMethodsCount() {
throw TypeException( getName(), L"type has no methods" ); throw TypeException( getName(), L"type has no methods" );
} }
...@@ -424,6 +428,7 @@ protected: ...@@ -424,6 +428,7 @@ protected:
virtual TypeInfoPtr getMethod( const std::wstring &name, const std::wstring& prototype=L""); virtual TypeInfoPtr getMethod( const std::wstring &name, const std::wstring& prototype=L"");
virtual TypeInfoPtr getMethod( size_t index ); virtual TypeInfoPtr getMethod( size_t index );
virtual size_t getMethodsCount(); virtual size_t getMethodsCount();
virtual std::wstring getMethodName(size_t index);
virtual TypeInfoPtr getBaseClass( const std::wstring& className); virtual TypeInfoPtr getBaseClass( const std::wstring& className);
virtual TypeInfoPtr getBaseClass( size_t index ); virtual TypeInfoPtr getBaseClass( size_t index );
......
...@@ -548,6 +548,18 @@ TEST_F(TypeInfoTest, GetMethod) ...@@ -548,6 +548,18 @@ TEST_F(TypeInfoTest, GetMethod)
EXPECT_THROW( g_classChild->getElement(L"NotExistMethod"), TypeException ); EXPECT_THROW( g_classChild->getElement(L"NotExistMethod"), TypeException );
} }
TEST_F(TypeInfoTest, GetMethodName)
{
TypeInfoPtr typeClassChild;
ASSERT_NO_THROW(typeClassChild = loadType(L"g_classChild"));
EXPECT_EQ(L"virtMethod3", typeClassChild->getMethodName(3));
EXPECT_EQ(L"classChild", typeClassChild->getMethodName(10));
EXPECT_THROW(typeClassChild->getMethodName(333), IndexException);
}
TEST_F(TypeInfoTest, GetOverloadedMethod) TEST_F(TypeInfoTest, GetOverloadedMethod)
{ {
TypeInfoPtr g_classChild; TypeInfoPtr g_classChild;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment