/* ---------------------------------------------------------------------------- * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) * See LICENSE for the license information * -------------------------------------------------------------------------- */ /** * @file Constructor.ccp * @author Frank Dellaert **/ #include #include #include #include "utilities.h" #include "Constructor.h" using namespace std; using namespace wrap; /* ************************************************************************* */ string Constructor::matlab_wrapper_name(const string& className) const { string str = "new_" + className + "_" + args.signature(); return str; } /* ************************************************************************* */ void Constructor::matlab_proxy_fragment(FileWriter& file, const string& className) const { size_t nrArgs = args.size(); // check for number of arguments... file.oss << " if (nargin == " << nrArgs; if (nrArgs>0) file.oss << " && "; // ...and their types bool first = true; for(size_t i=0;i& using_namespaces, const vector& includes) const { string matlabName = matlab_wrapper_name(matlabClassName); // open destination wrapperFile string wrapperFile = toolboxPath + "/" + matlabName + ".cpp"; FileWriter file(wrapperFile, verbose_, "//"); // generate code generateIncludes(file, name, includes); generateUsingNamespace(file, using_namespaces); file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl; file.oss << "{" << endl; file.oss << " checkArguments(\"" << matlabName << "\",nargout,nargin," << args.size() << ");" << endl; args.matlab_unwrap(file); // unwrap arguments file.oss << " " << cppClassName << "* self = new " << cppClassName << "(" << args.names() << ");" << endl; // need qualified name, delim: "::" file.oss << " out[0] = wrap_constructed(self,\"" << matlabClassName << "\");" << endl; // need matlab qualified name file.oss << "}" << endl; // close file file.emit(true); } /* ************************************************************************* */