Now using ArgumentList::emit_prototype everywhere, for non copy/paste code

release/4.3a0
dellaert 2014-05-25 13:22:10 -04:00
parent 4403d47865
commit 95b85e8494
5 changed files with 43 additions and 85 deletions

View File

@ -29,7 +29,6 @@
//#include <cstdint> // on Linux GCC: fails with error regarding needing C++0x std flags
//#include <cinttypes> // same failure as above
#include <stdint.h> // works on Linux GCC
using namespace std;
using namespace wrap;
@ -389,17 +388,9 @@ void Class::comment_fragment(FileWriter& proxyFile) const {
if (!constructor.args_list.empty())
proxyFile.oss << "%\n%-------Constructors-------\n";
BOOST_FOREACH(ArgumentList argList, constructor.args_list) {
string up_name = boost::to_upper_copy(name);
proxyFile.oss << "%" << name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
proxyFile.oss << ")\n";
proxyFile.oss << "%";
argList.emit_prototype(proxyFile, name);
proxyFile.oss << "\n";
}
if (!methods.empty())
@ -419,18 +410,9 @@ void Class::comment_fragment(FileWriter& proxyFile) const {
BOOST_FOREACH(const StaticMethods::value_type& name_m, static_methods) {
const StaticMethod& m = name_m.second;
BOOST_FOREACH(ArgumentList argList, m.argLists) {
string up_name = boost::to_upper_copy(m.name);
proxyFile.oss << "%" << m.name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
proxyFile.oss << ") : returns "
proxyFile.oss << "%";
argList.emit_prototype(proxyFile, m.name);
proxyFile.oss << " : returns "
<< m.returnVals[0].return_type(false, m.returnVals[0].pair) << endl;
}
}

View File

@ -15,14 +15,15 @@
* @author Richard Roberts
**/
#include <iostream>
#include <fstream>
#include "Method.h"
#include "utilities.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include "Method.h"
#include "utilities.h"
#include <iostream>
#include <fstream>
using namespace std;
using namespace wrap;
@ -44,47 +45,38 @@ void Method::proxy_wrapper_fragments(FileWriter& proxyFile,
const string& wrapperName, const TypeAttributesTable& typeAttributes,
vector<string>& functionNames) const {
// Create function header
proxyFile.oss << " function varargout = " << name << "(this, varargin)\n";
//Comments for documentation
// Emit comments for documentation
string up_name = boost::to_upper_copy(name);
proxyFile.oss << " % " << up_name << " usage:";
proxyFile.oss << " % " << up_name << " usage: ";
unsigned int argLCount = 0;
BOOST_FOREACH(ArgumentList argList, argLists) {
proxyFile.oss << " " << name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
argList.emit_prototype(proxyFile, name);
if (argLCount != argLists.size() - 1)
proxyFile.oss << "), ";
proxyFile.oss << ", ";
else
proxyFile.oss << ") : returns "
proxyFile.oss << " : returns "
<< returnVals[0].return_type(false, returnVals[0].pair) << endl;
argLCount++;
}
// Emit URL to Doxygen page
proxyFile.oss << " % "
<< "Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html"
<< endl;
// Document all overloads, if any
proxyFile.oss << " % " << "" << endl;
proxyFile.oss << " % " << "Method Overloads" << endl;
BOOST_FOREACH(ArgumentList argList, argLists) {
proxyFile.oss << " % " << name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
proxyFile.oss << ")" << endl;
proxyFile.oss << " % ";
argList.emit_prototype(proxyFile, name);
proxyFile.oss << endl;
}
// For all overloads, check the number of arguments
for (size_t overload = 0; overload < argLists.size(); ++overload) {
const ArgumentList& args = argLists[overload];
const ReturnValue& returnVal = returnVals[overload];

View File

@ -18,13 +18,12 @@
#pragma once
#include <string>
#include <list>
#include "Argument.h"
#include "ReturnValue.h"
#include "TypeAttributesTable.h"
#include <boost/algorithm/string.hpp>
#include <string>
#include <list>
namespace wrap {

View File

@ -16,14 +16,15 @@
* @author Richard Roberts
**/
#include <iostream>
#include <fstream>
#include "StaticMethod.h"
#include "utilities.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include "StaticMethod.h"
#include "utilities.h"
#include <iostream>
#include <fstream>
using namespace std;
using namespace wrap;
@ -50,22 +51,14 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
proxyFile.oss << " function varargout = " << upperName << "(varargin)\n";
//Comments for documentation
string up_name = boost::to_upper_copy(name);
proxyFile.oss << " % " << up_name << " usage:";
proxyFile.oss << " % " << up_name << " usage: ";
unsigned int argLCount = 0;
BOOST_FOREACH(ArgumentList argList, argLists) {
proxyFile.oss << " " << name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
argList.emit_prototype(proxyFile, name);
if (argLCount != argLists.size() - 1)
proxyFile.oss << "), ";
proxyFile.oss << ", ";
else
proxyFile.oss << ") : returns "
proxyFile.oss << " : returns "
<< returnVals[0].return_type(false, returnVals[0].pair) << endl;
argLCount++;
}
@ -76,16 +69,9 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
proxyFile.oss << " % " << "" << endl;
proxyFile.oss << " % " << "Usage" << endl;
BOOST_FOREACH(ArgumentList argList, argLists) {
proxyFile.oss << " % " << up_name << "(";
unsigned int i = 0;
BOOST_FOREACH(const Argument& arg, argList) {
if (i != argList.size() - 1)
proxyFile.oss << arg.type << " " << arg.name << ", ";
else
proxyFile.oss << arg.type << " " << arg.name;
i++;
}
proxyFile.oss << ")" << endl;
proxyFile.oss << " % ";
argList.emit_prototype(proxyFile, up_name);
proxyFile.oss << endl;
}
for (size_t overload = 0; overload < argLists.size(); ++overload) {

View File

@ -19,13 +19,12 @@
#pragma once
#include <string>
#include <list>
#include "Argument.h"
#include "ReturnValue.h"
#include "TypeAttributesTable.h"
#include <boost/algorithm/string.hpp>
#include <string>
#include <list>
namespace wrap {