Commit b7dc8d26 authored by ussrhero's avatar ussrhero

added TypeInfo::isTemplate method

parent 739aa68c
......@@ -67,6 +67,7 @@ public:
virtual bool isFunction() = 0;
virtual bool isVtbl() = 0;
virtual bool isNoType() = 0;
virtual bool isTemplate() = 0;
virtual BITOFFSET getBitOffset() = 0;
virtual BITOFFSET getBitWidth() = 0;
......
......@@ -465,6 +465,22 @@ class TestClassTemplate
extern TestClassTemplate<int> g_testClassTemplate;
template<typename T1, typename T2>
class TestTemplateTwoTypes
{
T1 field1;
T2 field2;
};
extern TestTemplateTwoTypes<int, TestClassTemplate<int> > g_testTemplateTwoTypes;
template<int t1, int t2>
class TestTemplateTwoValues
{
};
extern TestTemplateTwoValues<2, 10> g_testTemplateTwoValues;
////////////////////////////////////////////////////////////////////////////////
#pragma pack ( pop )
......
......@@ -103,6 +103,10 @@ protected:
NOT_IMPLEMENTED();
}
virtual bool isTemplate() {
return false;
}
virtual BITOFFSET getBitOffset() {
NOT_IMPLEMENTED();
}
......
......@@ -819,6 +819,13 @@ TypedVarPtr TypeInfoImp::getVar(const DataAccessorPtr &dataSource)
///////////////////////////////////////////////////////////////////////////////
bool TypeInfoImp::isTemplate()
{
return getName().find_first_of(L'<') != std::wstring::npos;
}
///////////////////////////////////////////////////////////////////////////////
std::wstring TypeInfoReference::getName()
{
std::wstring name;
......
......@@ -133,6 +133,8 @@ protected:
throw TypeException( getName(), L"type is not class method" );
}
bool isTemplate() override;
TypeInfoPtr getElement( const std::wstring &name ) override
{
throw TypeException( getName(), L" type has no fields or array elements");
......
......@@ -219,4 +219,6 @@ TemplateStruct<TemplateStruct<int>[4]> g_template4;
std::list<int> g_stdIntList;
TestStructTemplate<int> g_testStructTemplate;
TestClassTemplate<int> g_testClassTemplate;
\ No newline at end of file
TestClassTemplate<int> g_testClassTemplate;
TestTemplateTwoTypes<int,TestClassTemplate<int>> g_testTemplateTwoTypes;
TestTemplateTwoValues<2,10> g_testTemplateTwoValues;
\ No newline at end of file
......@@ -452,6 +452,7 @@ TEST_F(ClangTest, TemplateStruct)
EXPECT_EQ(L"Int4B", typeProvider->getTypeByName(L"TestStruct<int,float>")->getElement(0)->getName());
EXPECT_EQ(L"UInt4B", typeProvider->getTypeByName(L"TestStruct<char,unsigned long>")->getElement(1)->getName());
EXPECT_TRUE(typeProvider->getTypeByName(L"TestStruct<char,unsigned long>")->isTemplate());
EXPECT_THROW(typeProvider->getTypeByName(L"TestStruct"), TypeException);
EXPECT_THROW(typeProvider->getTypeByName(L"TestStruct<float>"), TypeException);
}
......
......@@ -639,3 +639,12 @@ TEST_F(TypeInfoTest, StructNestedEnum)
EXPECT_EQ(structWithNested::NestConst1, *loadType(L"structWithNested")->getElement(L"NestConst1"));
}
TEST_F(TypeInfoTest, isTemplate)
{
EXPECT_TRUE(loadType(L"TemplateStruct<int>")->isTemplate());
EXPECT_TRUE(loadType(L"TestTemplateTwoTypes<int,TestClassTemplate<int> >")->isTemplate());
EXPECT_TRUE(loadType(L"TestTemplateTwoValues<2,10>")->isTemplate());
EXPECT_FALSE(loadType(L"UInt4B")->isTemplate());
EXPECT_FALSE(loadType(L"structWithNested")->isTemplate());
}
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