Added 'verbose' flag, making unit tests silent
parent
47a01b1d90
commit
1df4385d84
|
@ -18,7 +18,7 @@ void Class::matlab_proxy(const string& classFile) {
|
|||
// open destination classFile
|
||||
ofstream ofs(classFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(classFile);
|
||||
cerr << "generating " << classFile << endl;
|
||||
if(verbose_) cerr << "generating " << classFile << endl;
|
||||
|
||||
// emit class proxy code
|
||||
emit_header_comment(ofs,"%");
|
||||
|
|
|
@ -17,6 +17,9 @@ struct Class {
|
|||
std::string name;
|
||||
std::list<Constructor> constructors;
|
||||
std::list<Method> methods;
|
||||
bool verbose_;
|
||||
|
||||
Class(bool verbose=true) : verbose_(verbose) {}
|
||||
|
||||
// MATLAB code generation:
|
||||
void matlab_proxy(const std::string& classFile); // proxy class
|
||||
|
|
|
@ -41,7 +41,7 @@ void Constructor::matlab_mfile(const string& toolboxPath, const string& classNam
|
|||
string wrapperFile = toolboxPath + "/" + name + ".m";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
cerr << "generating " << wrapperFile << endl;
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
||||
// generate code
|
||||
emit_header_comment(ofs, "%");
|
||||
|
@ -67,7 +67,7 @@ void Constructor::matlab_wrapper(const string& toolboxPath,
|
|||
string wrapperFile = toolboxPath + "/" + name + ".cpp";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
cerr << "generating " << wrapperFile << endl;
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
||||
// generate code
|
||||
emit_header_comment(ofs, "//");
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
// Constructor class
|
||||
struct Constructor {
|
||||
ArgumentList args;
|
||||
bool verbose_;
|
||||
|
||||
Constructor(bool verbose=true) : verbose_(verbose) {}
|
||||
|
||||
// MATLAB code generation
|
||||
// toolboxPath is main toolbox directory, e.g., ../matlab
|
||||
|
|
|
@ -41,7 +41,7 @@ void Method::matlab_mfile(const string& classPath) {
|
|||
string wrapperFile = classPath + "/" + name + ".m";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
cerr << "generating " << wrapperFile << endl;
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
||||
// generate code
|
||||
emit_header_comment(ofs, "%");
|
||||
|
@ -66,7 +66,7 @@ void Method::matlab_wrapper(const string& classPath,
|
|||
string wrapperFile = classPath + "/" + name + ".cpp";
|
||||
ofstream ofs(wrapperFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(wrapperFile);
|
||||
cerr << "generating " << wrapperFile << endl;
|
||||
if(verbose_) cerr << "generating " << wrapperFile << endl;
|
||||
|
||||
// generate code
|
||||
|
||||
|
|
|
@ -17,8 +17,9 @@ struct Method {
|
|||
ArgumentList args;
|
||||
std::string returns, returns2, name;
|
||||
bool returns_ptr, returns_ptr2, returns_pair;
|
||||
bool verbose_;
|
||||
|
||||
Method() : returns_ptr(false), returns_ptr2(false), returns_pair(false) {}
|
||||
Method(bool verbose=true) : returns_ptr(false), returns_ptr2(false), returns_pair(false), verbose_(verbose) {}
|
||||
|
||||
enum pairing {arg1, arg2, pair};
|
||||
std::string return_type(bool add_ptr, pairing p);
|
||||
|
|
|
@ -27,15 +27,15 @@ typedef rule<BOOST_SPIRIT_CLASSIC_NS::phrase_scanner_t> Rule;
|
|||
/* ************************************************************************* */
|
||||
|
||||
Module::Module(const string& interfacePath,
|
||||
const string& moduleName) : name(moduleName)
|
||||
const string& moduleName, bool verbose) : name(moduleName), verbose_(verbose)
|
||||
{
|
||||
// these variables will be imperatively updated to gradually build [cls]
|
||||
// The one with postfix 0 are used to reset the variables after parse.
|
||||
Argument arg0, arg;
|
||||
ArgumentList args0, args;
|
||||
Constructor constructor0, constructor;
|
||||
Method method0, method;
|
||||
Class cls0,cls;
|
||||
Constructor constructor0(verbose), constructor(verbose);
|
||||
Method method0(verbose), method(verbose);
|
||||
Class cls0(verbose),cls(verbose);
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Grammar with actions that build the Class object. Actions are
|
||||
|
@ -166,8 +166,7 @@ Module::Module(const string& interfacePath,
|
|||
/* ************************************************************************* */
|
||||
void Module::matlab_code(const string& toolboxPath,
|
||||
const string& nameSpace,
|
||||
const string& mexFlags,
|
||||
bool verbose)
|
||||
const string& mexFlags)
|
||||
{
|
||||
try {
|
||||
string installCmd = "install -d " + toolboxPath;
|
||||
|
@ -178,7 +177,7 @@ void Module::matlab_code(const string& toolboxPath,
|
|||
ofstream ofs(makeFile.c_str());
|
||||
if(!ofs) throw CantOpenFile(makeFile);
|
||||
|
||||
if (verbose) cerr << "generating " << makeFile << endl;
|
||||
if (verbose_) cerr << "generating " << makeFile << endl;
|
||||
emit_header_comment(ofs,"%");
|
||||
ofs << "echo on" << endl << endl;
|
||||
ofs << "toolboxpath = pwd" << endl;
|
||||
|
|
|
@ -15,19 +15,20 @@
|
|||
struct Module {
|
||||
std::string name;
|
||||
std::list<Class> classes;
|
||||
bool verbose_;
|
||||
|
||||
/**
|
||||
* constructor that parses interface file
|
||||
*/
|
||||
Module(const std::string& interfacePath,
|
||||
const std::string& moduleName);
|
||||
const std::string& moduleName,
|
||||
bool verbose=true);
|
||||
|
||||
/**
|
||||
* MATLAB code generation:
|
||||
*/
|
||||
void matlab_code(const std::string& path,
|
||||
const std::string& nameSpace,
|
||||
const std::string& mexFlags,
|
||||
bool verbose);
|
||||
const std::string& mexFlags);
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST( wrap, ArgumentList ) {
|
|||
|
||||
/* ************************************************************************* */
|
||||
TEST( wrap, parse ) {
|
||||
Module module(".", "geometry");
|
||||
Module module(".", "geometry",false);
|
||||
CHECK(module.classes.size()==3);
|
||||
|
||||
// check second class, Point3
|
||||
|
@ -59,11 +59,11 @@ TEST( wrap, parse ) {
|
|||
/* ************************************************************************* */
|
||||
TEST( wrap, matlab_code ) {
|
||||
// Parse into class object
|
||||
Module module(".","geometry");
|
||||
Module module(".","geometry",false);
|
||||
|
||||
// emit MATLAB code
|
||||
// make_geometry will not compile, use make testwrap to generate real make
|
||||
module.matlab_code("actual", "", "-O5", verbose);
|
||||
module.matlab_code("actual", "", "-O5");
|
||||
|
||||
CHECK(files_equal("expected/@Point2/Point2.m" , "actual/@Point2/Point2.m" ));
|
||||
CHECK(files_equal("expected/@Point2/x.cpp" , "actual/@Point2/x.cpp" ));
|
||||
|
|
|
@ -22,10 +22,10 @@ void generate_matlab_toolbox(const string& interfacePath,
|
|||
const string& mexFlags)
|
||||
{
|
||||
// Parse into class object
|
||||
Module module(interfacePath, moduleName);
|
||||
Module module(interfacePath, moduleName, false);
|
||||
|
||||
// emit MATLAB code
|
||||
module.matlab_code(toolboxPath,nameSpace,mexFlags,true);
|
||||
module.matlab_code(toolboxPath,nameSpace,mexFlags);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
Loading…
Reference in New Issue