Fixed proxy files and calls for static methods

release/4.3a0
dellaert 2014-11-13 23:21:05 +01:00
parent e07da1c82d
commit 67bc951ac2
8 changed files with 53 additions and 43 deletions

View File

@ -23,7 +23,11 @@
namespace wrap {
/// Method class
struct Method: public StaticMethod {
class Method: public StaticMethod {
bool is_const_;
public:
typedef const std::string& Str;
@ -32,7 +36,13 @@ struct Method: public StaticMethod {
StaticMethod(verbose), is_const_(false) {
}
bool is_const_;
virtual bool isStatic() const {
return false;
}
virtual bool isConst() const {
return is_const_;
}
// The first time this function is called, it initializes the class members
// with those in rhs, but in subsequent calls it adds additional argument

View File

@ -55,9 +55,9 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
proxy_header(proxyFile);
// Emit comments for documentation
string up_name = boost::to_upper_copy(name_);
string up_name = boost::to_upper_copy(matlabName());
proxyFile.oss << " % " << up_name << " usage: ";
usage_fragment(proxyFile, name_);
usage_fragment(proxyFile, matlabName());
// Emit URL to Doxygen page
proxyFile.oss << " % "
@ -67,9 +67,11 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
// Handle special case of single overload with all numeric arguments
if (nrOverloads() == 1 && argumentList(0).allScalar()) {
// Output proxy matlab code
// TODO: document why is it OK to not check arguments in this case
proxyFile.oss << " ";
const int id = (int) functionNames.size();
argumentList(0).emit_call(proxyFile, returnValue(0), wrapperName, id);
argumentList(0).emit_call(proxyFile, returnValue(0), wrapperName, id,
isStatic());
// Output C++ wrapper code
const string wrapFunctionName = wrapper_fragment(wrapperFile, cppClassName,
@ -85,7 +87,7 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
proxyFile.oss << " " << (i == 0 ? "" : "else");
const int id = (int) functionNames.size();
argumentList(i).emit_conditional_call(proxyFile, returnValue(i),
wrapperName, id);
wrapperName, id, isStatic());
// Output C++ wrapper code
const string wrapFunctionName = wrapper_fragment(wrapperFile,

View File

@ -33,6 +33,10 @@ struct StaticMethod: public Function, public SignatureOverloads {
Function(verbosity) {
}
virtual bool isStatic() const {
return true;
}
void addOverload(bool verbose, Str name, const ArgumentList& args,
const ReturnValue& retVal, const Qualified& instName);

View File

@ -48,27 +48,13 @@ classdef Point3 < handle
function varargout = StaticFunctionRet(varargin)
% STATICFUNCTIONRET usage: StaticFunctionRet(double z) : returns gtsam::Point3
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
% Usage
% STATICFUNCTIONRET(double z)
if length(varargin) == 1 && isa(varargin{1},'double')
varargout{1} = geometry_wrapper(15, varargin{:});
else
error('Arguments do not match any overload of function gtsam.Point3.StaticFunctionRet');
end
varargout{1} = geometry_wrapper(15, varargin{:});
end
function varargout = StaticFunction(varargin)
% STATICFUNCTION usage: staticFunction() : returns double
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
% Usage
% STATICFUNCTION()
if length(varargin) == 0
varargout{1} = geometry_wrapper(16, varargin{:});
else
error('Arguments do not match any overload of function gtsam.Point3.StaticFunction');
end
varargout{1} = geometry_wrapper(16, varargin{:});
end
end

View File

@ -107,16 +107,20 @@ classdef MyTemplatePoint2 < MyBase
end
end
function varargout = templatedMethod(this, varargin)
% TEMPLATEDMETHOD usage: templatedMethod(Point2 t), templatedMethod(Point3 t) : returns void
function varargout = templatedMethodPoint2(this, varargin)
% TEMPLATEDMETHODPOINT2 usage: templatedMethodPoint2(Point2 t) : returns void
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
% Method Overloads
% templatedMethod(Point2 t)
% templatedMethod(Point3 t)
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point2')
geometry_wrapper(54, this, varargin{:});
elseif length(varargin) == 1 && isa(varargin{1},'gtsam.Point3')
else
error('Arguments do not match any overload of function MyTemplatePoint2.templatedMethod');
end
end
function varargout = templatedMethodPoint3(this, varargin)
% TEMPLATEDMETHODPOINT3 usage: templatedMethodPoint3(Point3 t) : returns void
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point3')
geometry_wrapper(55, this, varargin{:});
else
error('Arguments do not match any overload of function MyTemplatePoint2.templatedMethod');

View File

@ -107,16 +107,20 @@ classdef MyTemplatePoint3 < MyBase
end
end
function varargout = templatedMethod(this, varargin)
% TEMPLATEDMETHOD usage: templatedMethod(Point2 t), templatedMethod(Point3 t) : returns void
function varargout = templatedMethodPoint2(this, varargin)
% TEMPLATEDMETHODPOINT2 usage: templatedMethodPoint2(Point2 t) : returns void
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
%
% Method Overloads
% templatedMethod(Point2 t)
% templatedMethod(Point3 t)
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point2')
geometry_wrapper(67, this, varargin{:});
elseif length(varargin) == 1 && isa(varargin{1},'gtsam.Point3')
else
error('Arguments do not match any overload of function MyTemplatePoint3.templatedMethod');
end
end
function varargout = templatedMethodPoint3(this, varargin)
% TEMPLATEDMETHODPOINT3 usage: templatedMethodPoint3(Point3 t) : returns void
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point3')
geometry_wrapper(68, this, varargin{:});
else
error('Arguments do not match any overload of function MyTemplatePoint3.templatedMethod');

View File

@ -65,7 +65,7 @@ classdef ClassA < handle
function varargout = Afunction(varargin)
% AFUNCTION usage: afunction() : returns double
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
varargout{1} = testNamespaces_wrapper(12, this, varargin{:});
varargout{1} = testNamespaces_wrapper(12, varargin{:});
end
end

View File

@ -98,7 +98,7 @@ TEST( wrap, Small ) {
// Method 1
Method m1 = cls.method("x");
EXPECT(assert_equal("x", m1.name()));
EXPECT(m1.is_const_);
EXPECT(m1.isConst());
LONGS_EQUAL(1, m1.nrOverloads());
ReturnValue rv1 = m1.returnValue(0);
@ -110,7 +110,7 @@ TEST( wrap, Small ) {
// Method 2
Method m2 = cls.method("returnMatrix");
EXPECT(assert_equal("returnMatrix", m2.name()));
EXPECT(m2.is_const_);
EXPECT(m2.isConst());
LONGS_EQUAL(1, m2.nrOverloads());
ReturnValue rv2 = m2.returnValue(0);
@ -122,7 +122,7 @@ TEST( wrap, Small ) {
// Method 3
Method m3 = cls.method("returnPoint2");
EXPECT(assert_equal("returnPoint2", m3.name()));
EXPECT(m3.is_const_);
EXPECT(m3.isConst());
LONGS_EQUAL(1, m3.nrOverloads());
ReturnValue rv3 = m3.returnValue(0);
@ -198,7 +198,7 @@ TEST( wrap, Geometry ) {
EXPECT(assert_equal("returnChar", m1.name()));
LONGS_EQUAL(1, m1.nrOverloads());
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
EXPECT(m1.is_const_);
EXPECT(m1.isConst());
}
{
@ -212,7 +212,7 @@ TEST( wrap, Geometry ) {
EXPECT(assert_equal("vectorConfusion", m1.name()));
LONGS_EQUAL(1, m1.nrOverloads());
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
EXPECT(!m1.is_const_);
EXPECT(!m1.isConst());
}
EXPECT_LONGS_EQUAL(0, cls.static_methods.size());
@ -254,7 +254,7 @@ TEST( wrap, Geometry ) {
EXPECT(assert_equal("norm", m1.name()));
LONGS_EQUAL(1, m1.nrOverloads());
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
EXPECT(m1.is_const_);
EXPECT(m1.isConst());
#ifndef WRAP_DISABLE_SERIALIZE
// check serialization flag