From 80b7d91264bbe5fe0c2505fcaee0c4fe7fd82b5b Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 25 May 2014 13:01:36 -0400 Subject: [PATCH] emit prototype method (to eliminate horrible copy/paste mess someone thought was good programming style) --- wrap/Argument.cpp | 22 ++++++++++++++++++---- wrap/Argument.h | 7 +++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/wrap/Argument.cpp b/wrap/Argument.cpp index c3798e5ce..0f5961a48 100644 --- a/wrap/Argument.cpp +++ b/wrap/Argument.cpp @@ -16,13 +16,14 @@ * @author Richard Roberts **/ -#include -#include -#include +#include "Argument.h" + #include #include -#include "Argument.h" +#include +#include +#include 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 << ")"; +} +/* ************************************************************************* */ diff --git a/wrap/Argument.h b/wrap/Argument.h index f46eaa427..da15cda36 100644 --- a/wrap/Argument.h +++ b/wrap/Argument.h @@ -68,6 +68,13 @@ struct ArgumentList: public std::vector { */ 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