emit prototype method (to eliminate horrible copy/paste mess someone thought was good programming style)

release/4.3a0
dellaert 2014-05-25 13:01:36 -04:00
parent 82d6bae4b9
commit 80b7d91264
2 changed files with 25 additions and 4 deletions

View File

@ -16,13 +16,14 @@
* @author Richard Roberts
**/
#include <iostream>
#include <fstream>
#include <sstream>
#include "Argument.h"
#include <boost/foreach.hpp>
#include <boost/regex.hpp>
#include "Argument.h"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace wrap;
@ -128,4 +129,17 @@ void ArgumentList::matlab_unwrap(FileWriter& file, int start) const {
}
/* ************************************************************************* */
void ArgumentList::emit_prototype(FileWriter& file, const string& name) const {
file.oss << name << "(";
unsigned int i = 0;
BOOST_FOREACH(Argument arg, *this) {
if (i != size() - 1)
file.oss << arg.type << " " << arg.name << ", ";
else
file.oss << arg.type << " " << arg.name;
i++;
}
file.oss << ")";
}
/* ************************************************************************* */

View File

@ -68,6 +68,13 @@ struct ArgumentList: public std::vector<Argument> {
*/
void matlab_unwrap(FileWriter& file, int start = 0) const; // MATLAB to C++
/**
* emit MATLAB prototype
* @param file output stream
* @param name of method or function
*/
void emit_prototype(FileWriter& file, const std::string& name) const;
};
} // \namespace wrap