Now using emit_conditional_call (changed indenting)
parent
925f23515d
commit
5e9632e781
|
@ -84,32 +84,13 @@ void GlobalFunction::generateSingleFunction(const std::string& toolboxPath,
|
||||||
for (size_t overload = 0; overload < argLists.size(); ++overload) {
|
for (size_t overload = 0; overload < argLists.size(); ++overload) {
|
||||||
const ArgumentList& args = argLists[overload];
|
const ArgumentList& args = argLists[overload];
|
||||||
const ReturnValue& returnVal = returnVals[overload];
|
const ReturnValue& returnVal = returnVals[overload];
|
||||||
size_t nrArgs = args.size();
|
|
||||||
|
|
||||||
const int id = functionNames.size();
|
const int id = functionNames.size();
|
||||||
|
|
||||||
// Output proxy matlab code
|
// Output proxy matlab code
|
||||||
|
mfunctionFile.oss << " " << (overload == 0 ? "" : "else");
|
||||||
// check for number of arguments...
|
argLists[overload].emit_conditional_call(mfunctionFile,
|
||||||
mfunctionFile.oss << (overload == 0 ? "" : "else")
|
returnVals[overload], wrapperName, id, true); // true omits "this"
|
||||||
<< "if length(varargin) == " << nrArgs;
|
|
||||||
if (nrArgs > 0)
|
|
||||||
mfunctionFile.oss << " && ";
|
|
||||||
// ...and their types
|
|
||||||
bool first = true;
|
|
||||||
for (size_t i = 0; i < nrArgs; i++) {
|
|
||||||
if (!first)
|
|
||||||
mfunctionFile.oss << " && ";
|
|
||||||
mfunctionFile.oss << "isa(varargin{" << i + 1 << "},'"
|
|
||||||
<< args[i].matlabClass(".") << "')";
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
mfunctionFile.oss << "\n";
|
|
||||||
|
|
||||||
// output call to C++ wrapper
|
|
||||||
mfunctionFile.oss << " ";
|
|
||||||
returnVal.emit_matlab(mfunctionFile);
|
|
||||||
mfunctionFile.oss << wrapperName << "(" << id << ", varargin{:});\n";
|
|
||||||
|
|
||||||
// Output C++ wrapper code
|
// Output C++ wrapper code
|
||||||
|
|
||||||
|
@ -146,11 +127,11 @@ void GlobalFunction::generateSingleFunction(const std::string& toolboxPath,
|
||||||
functionNames.push_back(wrapFunctionName);
|
functionNames.push_back(wrapFunctionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
mfunctionFile.oss << "else\n";
|
mfunctionFile.oss << " else\n";
|
||||||
mfunctionFile.oss
|
mfunctionFile.oss
|
||||||
<< " error('Arguments do not match any overload of function "
|
<< " error('Arguments do not match any overload of function "
|
||||||
<< matlabQualName << "');" << endl;
|
<< matlabQualName << "');" << endl;
|
||||||
mfunctionFile.oss << "end" << endl;
|
mfunctionFile.oss << " end" << endl;
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
mfunctionFile.emit(true);
|
mfunctionFile.emit(true);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function varargout = aGlobalFunction(varargin)
|
function varargout = aGlobalFunction(varargin)
|
||||||
if length(varargin) == 0
|
if length(varargin) == 0
|
||||||
varargout{1} = geometry_wrapper(42, varargin{:});
|
varargout{1} = geometry_wrapper(42, varargin{:});
|
||||||
else
|
else
|
||||||
error('Arguments do not match any overload of function aGlobalFunction');
|
error('Arguments do not match any overload of function aGlobalFunction');
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue