global function parsing now tested and working

release/4.3a0
Alex Cunningham 2012-07-23 14:09:42 +00:00
parent 26fce2d400
commit e7e564268d
3 changed files with 44 additions and 2 deletions

View File

@ -294,7 +294,7 @@ Module::Module(const string& interfacePath,
(str_p("namespace")
>> namespace_name_p[push_back_a(namespaces)]
>> ch_p('{')
>> *(include_p | class_p | templateSingleInstantiation_p | namespace_def_p | comments_p)
>> *(include_p | class_p | templateSingleInstantiation_p | global_function_p | namespace_def_p | comments_p)
>> str_p("}///\\namespace") // end namespace, avoid confusion with classes // FIXME: check for absense of semicolon to disambiguate
>> !namespace_name_p)
[pop_a(namespaces)];

View File

@ -14,6 +14,9 @@ class ClassB {
ClassB();
};
// check namespace handling
Vector aGlobalFunction();
}///\namespace ns1
#include <path/to/ns2.h>
@ -41,6 +44,9 @@ class ClassC {
ClassC();
};
// separate namespace global function, same name
Vector aGlobalFunction();
}///\namespace ns2
class ClassD {

View File

@ -88,6 +88,8 @@ TEST( wrap, parse_geometry ) {
strvec exp_includes; exp_includes += "folder/path/to/Test.h";
EXPECT(assert_equal(exp_includes, module.includes));
LONGS_EQUAL(3, module.classes.size());
// check first class, Point2
{
Class cls = module.classes.at(0);
@ -133,7 +135,6 @@ TEST( wrap, parse_geometry ) {
// Test class is the third one
{
LONGS_EQUAL(3, module.classes.size());
Class testCls = module.classes.at(2);
EXPECT_LONGS_EQUAL( 2, testCls.constructor.args_list.size());
EXPECT_LONGS_EQUAL(19, testCls.methods.size());
@ -149,6 +150,20 @@ TEST( wrap, parse_geometry ) {
EXPECT(m2.returnVals.front().category1 == ReturnValue::EIGEN);
EXPECT(m2.returnVals.front().category2 == ReturnValue::EIGEN);
}
// evaluate global functions
// Vector aGlobalFunction();
LONGS_EQUAL(1, module.global_functions.size());
CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end());
{
GlobalFunction gfunc = module.global_functions.at("aGlobalFunction");
EXPECT(assert_equal("aGlobalFunction", gfunc.name));
LONGS_EQUAL(1, gfunc.returnVals.size());
EXPECT(assert_equal("Vector", gfunc.returnVals.front().type1));
EXPECT_LONGS_EQUAL(1, gfunc.argLists.size());
LONGS_EQUAL(1, gfunc.namespaces.size());
EXPECT(gfunc.namespaces.front().empty());
}
}
/* ************************************************************************* */
@ -208,6 +223,27 @@ TEST( wrap, parse_namespaces ) {
strvec exp_namespaces;
EXPECT(assert_equal(exp_namespaces, cls.namespaces));
}
// evaluate global functions
// Vector ns1::aGlobalFunction();
// Vector ns2::aGlobalFunction();
LONGS_EQUAL(1, module.global_functions.size());
CHECK(module.global_functions.find("aGlobalFunction") != module.global_functions.end());
{
GlobalFunction gfunc = module.global_functions.at("aGlobalFunction");
EXPECT(assert_equal("aGlobalFunction", gfunc.name));
LONGS_EQUAL(2, gfunc.returnVals.size());
EXPECT(assert_equal("Vector", gfunc.returnVals.front().type1));
EXPECT_LONGS_EQUAL(2, gfunc.argLists.size());
// check namespaces
LONGS_EQUAL(2, gfunc.namespaces.size());
strvec exp_namespaces1; exp_namespaces1 += "ns1";
EXPECT(assert_equal(exp_namespaces1, gfunc.namespaces.at(0)));
strvec exp_namespaces2; exp_namespaces2 += "ns2";
EXPECT(assert_equal(exp_namespaces2, gfunc.namespaces.at(1)));
}
}
/* ************************************************************************* */