Simple namespace works
parent
1130cf43e0
commit
1aecb58807
|
@ -162,12 +162,12 @@ Module::Module(const string& interfacePath,
|
||||||
|
|
||||||
Rule namespace_p = str_p("namespace") >>
|
Rule namespace_p = str_p("namespace") >>
|
||||||
namespace_name_p[assign_a(namespaces_parent, namespaces)][push_back_a(namespaces)] // save previous state
|
namespace_name_p[assign_a(namespaces_parent, namespaces)][push_back_a(namespaces)] // save previous state
|
||||||
>> confix_p('{', // start namespace
|
>> ch_p('{') >>
|
||||||
+(comments_p | class_p | namespace_p),
|
*(class_p | namespace_p | comments_p) >>
|
||||||
('}' >> (*anychar_p - ch_p(';'))) // end namespace, avoid confusion with classes
|
str_p("}//\\namespace") // end namespace, avoid confusion with classes
|
||||||
)[assign_a(namespaces, namespaces_parent)]; // switch back to parent namespace
|
[assign_a(namespaces, namespaces_parent)]; // switch back to parent namespace
|
||||||
|
|
||||||
Rule module_content_p = comments_p | namespace_p | class_p;
|
Rule module_content_p = comments_p | class_p | namespace_p ;
|
||||||
|
|
||||||
Rule module_p = *module_content_p >> !end_p;
|
Rule module_p = *module_content_p >> !end_p;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ class Point3 {
|
||||||
|
|
||||||
// another comment
|
// another comment
|
||||||
|
|
||||||
|
// NOTE: you *must* end namespaces as follows:
|
||||||
|
}//\namespace
|
||||||
|
|
||||||
// another comment
|
// another comment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,8 +74,6 @@ class Test {
|
||||||
// even more comments at the end!
|
// even more comments at the end!
|
||||||
};
|
};
|
||||||
|
|
||||||
} // \ns_inner
|
|
||||||
|
|
||||||
// comments at the end!
|
// comments at the end!
|
||||||
|
|
||||||
// even more comments at the end!
|
// even more comments at the end!
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -56,12 +57,11 @@ TEST( wrap, check_exception ) {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST( wrap, parse ) {
|
TEST( wrap, parse ) {
|
||||||
string path = topdir + "/wrap/tests";
|
string header_path = topdir + "/wrap/tests";
|
||||||
|
|
||||||
Module module(path.c_str(), "geometry",enable_verbose);
|
Module module(header_path.c_str(), "geometry",enable_verbose);
|
||||||
EXPECT_LONGS_EQUAL(3, module.classes.size());
|
EXPECT_LONGS_EQUAL(3, module.classes.size());
|
||||||
//Hack to solve issues with instantiating Modules
|
string path = topdir + "/wrap";
|
||||||
path = topdir + "/wrap";
|
|
||||||
|
|
||||||
// check first class, Point2
|
// check first class, Point2
|
||||||
{
|
{
|
||||||
|
@ -102,26 +102,32 @@ TEST( wrap, parse ) {
|
||||||
EXPECT(m1.is_const_);
|
EXPECT(m1.is_const_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Test class is the third one
|
// Test class is the third one
|
||||||
// LONGS_EQUAL(3, module.classes.size());
|
{
|
||||||
// Class testCls = module.classes.at(2);
|
LONGS_EQUAL(3, module.classes.size());
|
||||||
// EXPECT_LONGS_EQUAL( 2, testCls.constructors.size());
|
Class testCls = module.classes.at(2);
|
||||||
// EXPECT_LONGS_EQUAL(19, testCls.methods.size());
|
EXPECT_LONGS_EQUAL( 2, testCls.constructors.size());
|
||||||
// EXPECT_LONGS_EQUAL( 0, testCls.static_methods.size());
|
EXPECT_LONGS_EQUAL(19, testCls.methods.size());
|
||||||
//
|
EXPECT_LONGS_EQUAL( 0, testCls.static_methods.size());
|
||||||
// // function to parse: pair<Vector,Matrix> return_pair (Vector v, Matrix A) const;
|
|
||||||
// Method m2 = testCls.methods.front();
|
// function to parse: pair<Vector,Matrix> return_pair (Vector v, Matrix A) const;
|
||||||
// EXPECT(m2.returnVal_.isPair);
|
Method m2 = testCls.methods.front();
|
||||||
// EXPECT(m2.returnVal_.category1 == ReturnValue::EIGEN);
|
EXPECT(m2.returnVal_.isPair);
|
||||||
// EXPECT(m2.returnVal_.category2 == ReturnValue::EIGEN);
|
EXPECT(m2.returnVal_.category1 == ReturnValue::EIGEN);
|
||||||
|
EXPECT(m2.returnVal_.category2 == ReturnValue::EIGEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
TEST( wrap, matlab_code ) {
|
TEST( wrap, matlab_code ) {
|
||||||
// Parse into class object
|
// Parse into class object
|
||||||
string path = topdir + "/wrap/tests";
|
string header_path = topdir + "/wrap/tests";
|
||||||
Module module(path,"geometry",enable_verbose);
|
Module module(header_path,"geometry",enable_verbose);
|
||||||
path = topdir + "/wrap";
|
string path = topdir + "/wrap";
|
||||||
|
|
||||||
|
// clean out previous generated code
|
||||||
|
string cleanCmd = "rm -rf actual";
|
||||||
|
system(cleanCmd.c_str());
|
||||||
|
|
||||||
// emit MATLAB code
|
// emit MATLAB code
|
||||||
// make_geometry will not compile, use make testwrap to generate real make
|
// make_geometry will not compile, use make testwrap to generate real make
|
||||||
|
|
Loading…
Reference in New Issue