Further debugging and tests of parsing issue with return type flags

release/4.3a0
Alex Cunningham 2012-11-27 19:03:20 +00:00
parent d1b9185918
commit ab7655e5eb
2 changed files with 41 additions and 27 deletions

View File

@ -349,29 +349,29 @@ void Module::parseMarkup(const std::string& data) {
Rule module_p = *module_content_p >> !end_p; Rule module_p = *module_content_p >> !end_p;
//---------------------------------------------------------------------------- // //----------------------------------------------------------------------------
// for debugging, define BOOST_SPIRIT_DEBUG // // for debugging, define BOOST_SPIRIT_DEBUG
# ifdef BOOST_SPIRIT_DEBUG //# ifdef BOOST_SPIRIT_DEBUG
BOOST_SPIRIT_DEBUG_NODE(className_p); // BOOST_SPIRIT_DEBUG_NODE(className_p);
BOOST_SPIRIT_DEBUG_NODE(classPtr_p); // BOOST_SPIRIT_DEBUG_NODE(classPtr_p);
BOOST_SPIRIT_DEBUG_NODE(classRef_p); // BOOST_SPIRIT_DEBUG_NODE(classRef_p);
BOOST_SPIRIT_DEBUG_NODE(basisType_p); // BOOST_SPIRIT_DEBUG_NODE(basisType_p);
BOOST_SPIRIT_DEBUG_NODE(name_p); // BOOST_SPIRIT_DEBUG_NODE(name_p);
BOOST_SPIRIT_DEBUG_NODE(argument_p); // BOOST_SPIRIT_DEBUG_NODE(argument_p);
BOOST_SPIRIT_DEBUG_NODE(argumentList_p); // BOOST_SPIRIT_DEBUG_NODE(argumentList_p);
BOOST_SPIRIT_DEBUG_NODE(constructor_p); // BOOST_SPIRIT_DEBUG_NODE(constructor_p);
BOOST_SPIRIT_DEBUG_NODE(returnType1_p); // BOOST_SPIRIT_DEBUG_NODE(returnType1_p);
BOOST_SPIRIT_DEBUG_NODE(returnType2_p); // BOOST_SPIRIT_DEBUG_NODE(returnType2_p);
BOOST_SPIRIT_DEBUG_NODE(pair_p); // BOOST_SPIRIT_DEBUG_NODE(pair_p);
BOOST_SPIRIT_DEBUG_NODE(void_p); // BOOST_SPIRIT_DEBUG_NODE(void_p);
BOOST_SPIRIT_DEBUG_NODE(returnType_p); // BOOST_SPIRIT_DEBUG_NODE(returnType_p);
BOOST_SPIRIT_DEBUG_NODE(methodName_p); // BOOST_SPIRIT_DEBUG_NODE(methodName_p);
BOOST_SPIRIT_DEBUG_NODE(method_p); // BOOST_SPIRIT_DEBUG_NODE(method_p);
BOOST_SPIRIT_DEBUG_NODE(class_p); // BOOST_SPIRIT_DEBUG_NODE(class_p);
BOOST_SPIRIT_DEBUG_NODE(namespace_def_p); // BOOST_SPIRIT_DEBUG_NODE(namespace_def_p);
BOOST_SPIRIT_DEBUG_NODE(module_p); // BOOST_SPIRIT_DEBUG_NODE(module_p);
# endif //# endif
//---------------------------------------------------------------------------- // //----------------------------------------------------------------------------
// and parse contents // and parse contents
parse_info<const char*> info = parse(data.c_str(), module_p, space_p); parse_info<const char*> info = parse(data.c_str(), module_p, space_p);

View File

@ -78,8 +78,9 @@ TEST( wrap, small_parse ) {
string markup( string markup(
string("class Point2 { \n") + string("class Point2 { \n") +
string(" double x() const; \n") + // Method 1 string(" double x() const; \n") + // Method 1
string(" Matrix returnChar() const; \n") + // Method 2 string(" Matrix returnMatrix() const; \n") + // Method 2
string(" Point2 returnPoint2() const; \n") + // Method 3 string(" Point2 returnPoint2() const; \n") + // Method 3
string(" static Vector returnVector(); \n") + // Static Method 1
string("};\n")); string("};\n"));
module.parseMarkup(markup); module.parseMarkup(markup);
@ -89,8 +90,8 @@ TEST( wrap, small_parse ) {
EXPECT(assert_equal("Point2", cls.name)); EXPECT(assert_equal("Point2", cls.name));
EXPECT(!cls.isVirtual); EXPECT(!cls.isVirtual);
EXPECT(cls.namespaces.empty()); EXPECT(cls.namespaces.empty());
EXPECT(cls.static_methods.empty());
LONGS_EQUAL(3, cls.methods.size()); LONGS_EQUAL(3, cls.methods.size());
LONGS_EQUAL(1, cls.static_methods.size());
// Method 1 // Method 1
Method m1 = cls.methods.at("x"); Method m1 = cls.methods.at("x");
@ -106,8 +107,8 @@ TEST( wrap, small_parse ) {
EXPECT_LONGS_EQUAL(ReturnValue::BASIS, rv1.category1); EXPECT_LONGS_EQUAL(ReturnValue::BASIS, rv1.category1);
// Method 2 // Method 2
Method m2 = cls.methods.at("returnChar"); Method m2 = cls.methods.at("returnMatrix");
EXPECT(assert_equal("returnChar", m2.name)); EXPECT(assert_equal("returnMatrix", m2.name));
EXPECT(m2.is_const_); EXPECT(m2.is_const_);
LONGS_EQUAL(1, m2.argLists.size()); LONGS_EQUAL(1, m2.argLists.size());
LONGS_EQUAL(1, m2.returnVals.size()); LONGS_EQUAL(1, m2.returnVals.size());
@ -131,6 +132,19 @@ TEST( wrap, small_parse ) {
EXPECT(assert_equal("Point2", rv3.type1)); EXPECT(assert_equal("Point2", rv3.type1));
EXPECT_LONGS_EQUAL(ReturnValue::CLASS, rv3.category1); EXPECT_LONGS_EQUAL(ReturnValue::CLASS, rv3.category1);
// Static Method 1
// static Vector returnVector();
StaticMethod sm1 = cls.static_methods.at("returnVector");
EXPECT(assert_equal("returnVector", sm1.name));
LONGS_EQUAL(1, sm1.argLists.size());
LONGS_EQUAL(1, sm1.returnVals.size());
ReturnValue rv4 = sm1.returnVals.front();
EXPECT(!rv4.isPair);
EXPECT(!rv4.isPtr1);
EXPECT(assert_equal("Vector", rv4.type1));
EXPECT_LONGS_EQUAL(ReturnValue::EIGEN, rv4.category1);
} }
/* ************************************************************************* */ /* ************************************************************************* */