Fixed proxy files and calls for static methods
parent
e07da1c82d
commit
67bc951ac2
|
@ -23,7 +23,11 @@
|
||||||
namespace wrap {
|
namespace wrap {
|
||||||
|
|
||||||
/// Method class
|
/// Method class
|
||||||
struct Method: public StaticMethod {
|
class Method: public StaticMethod {
|
||||||
|
|
||||||
|
bool is_const_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
typedef const std::string& Str;
|
typedef const std::string& Str;
|
||||||
|
|
||||||
|
@ -32,7 +36,13 @@ struct Method: public StaticMethod {
|
||||||
StaticMethod(verbose), is_const_(false) {
|
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
|
// The first time this function is called, it initializes the class members
|
||||||
// with those in rhs, but in subsequent calls it adds additional argument
|
// with those in rhs, but in subsequent calls it adds additional argument
|
||||||
|
|
|
@ -55,9 +55,9 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
|
||||||
proxy_header(proxyFile);
|
proxy_header(proxyFile);
|
||||||
|
|
||||||
// Emit comments for documentation
|
// 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: ";
|
proxyFile.oss << " % " << up_name << " usage: ";
|
||||||
usage_fragment(proxyFile, name_);
|
usage_fragment(proxyFile, matlabName());
|
||||||
|
|
||||||
// Emit URL to Doxygen page
|
// Emit URL to Doxygen page
|
||||||
proxyFile.oss << " % "
|
proxyFile.oss << " % "
|
||||||
|
@ -67,9 +67,11 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
|
||||||
// Handle special case of single overload with all numeric arguments
|
// Handle special case of single overload with all numeric arguments
|
||||||
if (nrOverloads() == 1 && argumentList(0).allScalar()) {
|
if (nrOverloads() == 1 && argumentList(0).allScalar()) {
|
||||||
// Output proxy matlab code
|
// Output proxy matlab code
|
||||||
|
// TODO: document why is it OK to not check arguments in this case
|
||||||
proxyFile.oss << " ";
|
proxyFile.oss << " ";
|
||||||
const int id = (int) functionNames.size();
|
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
|
// Output C++ wrapper code
|
||||||
const string wrapFunctionName = wrapper_fragment(wrapperFile, cppClassName,
|
const string wrapFunctionName = wrapper_fragment(wrapperFile, cppClassName,
|
||||||
|
@ -85,7 +87,7 @@ void StaticMethod::proxy_wrapper_fragments(FileWriter& proxyFile,
|
||||||
proxyFile.oss << " " << (i == 0 ? "" : "else");
|
proxyFile.oss << " " << (i == 0 ? "" : "else");
|
||||||
const int id = (int) functionNames.size();
|
const int id = (int) functionNames.size();
|
||||||
argumentList(i).emit_conditional_call(proxyFile, returnValue(i),
|
argumentList(i).emit_conditional_call(proxyFile, returnValue(i),
|
||||||
wrapperName, id);
|
wrapperName, id, isStatic());
|
||||||
|
|
||||||
// Output C++ wrapper code
|
// Output C++ wrapper code
|
||||||
const string wrapFunctionName = wrapper_fragment(wrapperFile,
|
const string wrapFunctionName = wrapper_fragment(wrapperFile,
|
||||||
|
|
|
@ -33,6 +33,10 @@ struct StaticMethod: public Function, public SignatureOverloads {
|
||||||
Function(verbosity) {
|
Function(verbosity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool isStatic() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void addOverload(bool verbose, Str name, const ArgumentList& args,
|
void addOverload(bool verbose, Str name, const ArgumentList& args,
|
||||||
const ReturnValue& retVal, const Qualified& instName);
|
const ReturnValue& retVal, const Qualified& instName);
|
||||||
|
|
||||||
|
|
|
@ -48,27 +48,13 @@ classdef Point3 < handle
|
||||||
function varargout = StaticFunctionRet(varargin)
|
function varargout = StaticFunctionRet(varargin)
|
||||||
% STATICFUNCTIONRET usage: StaticFunctionRet(double z) : returns gtsam::Point3
|
% 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
|
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
||||||
%
|
varargout{1} = geometry_wrapper(15, varargin{:});
|
||||||
% 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function varargout = StaticFunction(varargin)
|
function varargout = StaticFunction(varargin)
|
||||||
% STATICFUNCTION usage: staticFunction() : returns double
|
% STATICFUNCTION usage: staticFunction() : returns double
|
||||||
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
||||||
%
|
varargout{1} = geometry_wrapper(16, varargin{:});
|
||||||
% 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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,16 +107,20 @@ classdef MyTemplatePoint2 < MyBase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function varargout = templatedMethod(this, varargin)
|
function varargout = templatedMethodPoint2(this, varargin)
|
||||||
% TEMPLATEDMETHOD usage: templatedMethod(Point2 t), templatedMethod(Point3 t) : returns void
|
% TEMPLATEDMETHODPOINT2 usage: templatedMethodPoint2(Point2 t) : returns void
|
||||||
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
% 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')
|
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point2')
|
||||||
geometry_wrapper(54, this, varargin{:});
|
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{:});
|
geometry_wrapper(55, this, varargin{:});
|
||||||
else
|
else
|
||||||
error('Arguments do not match any overload of function MyTemplatePoint2.templatedMethod');
|
error('Arguments do not match any overload of function MyTemplatePoint2.templatedMethod');
|
||||||
|
|
|
@ -107,16 +107,20 @@ classdef MyTemplatePoint3 < MyBase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function varargout = templatedMethod(this, varargin)
|
function varargout = templatedMethodPoint2(this, varargin)
|
||||||
% TEMPLATEDMETHOD usage: templatedMethod(Point2 t), templatedMethod(Point3 t) : returns void
|
% TEMPLATEDMETHODPOINT2 usage: templatedMethodPoint2(Point2 t) : returns void
|
||||||
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
% 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')
|
if length(varargin) == 1 && isa(varargin{1},'gtsam.Point2')
|
||||||
geometry_wrapper(67, this, varargin{:});
|
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{:});
|
geometry_wrapper(68, this, varargin{:});
|
||||||
else
|
else
|
||||||
error('Arguments do not match any overload of function MyTemplatePoint3.templatedMethod');
|
error('Arguments do not match any overload of function MyTemplatePoint3.templatedMethod');
|
||||||
|
|
|
@ -65,7 +65,7 @@ classdef ClassA < handle
|
||||||
function varargout = Afunction(varargin)
|
function varargout = Afunction(varargin)
|
||||||
% AFUNCTION usage: afunction() : returns double
|
% AFUNCTION usage: afunction() : returns double
|
||||||
% Doxygen can be found at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html
|
% 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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,7 +98,7 @@ TEST( wrap, Small ) {
|
||||||
// Method 1
|
// Method 1
|
||||||
Method m1 = cls.method("x");
|
Method m1 = cls.method("x");
|
||||||
EXPECT(assert_equal("x", m1.name()));
|
EXPECT(assert_equal("x", m1.name()));
|
||||||
EXPECT(m1.is_const_);
|
EXPECT(m1.isConst());
|
||||||
LONGS_EQUAL(1, m1.nrOverloads());
|
LONGS_EQUAL(1, m1.nrOverloads());
|
||||||
|
|
||||||
ReturnValue rv1 = m1.returnValue(0);
|
ReturnValue rv1 = m1.returnValue(0);
|
||||||
|
@ -110,7 +110,7 @@ TEST( wrap, Small ) {
|
||||||
// Method 2
|
// Method 2
|
||||||
Method m2 = cls.method("returnMatrix");
|
Method m2 = cls.method("returnMatrix");
|
||||||
EXPECT(assert_equal("returnMatrix", m2.name()));
|
EXPECT(assert_equal("returnMatrix", m2.name()));
|
||||||
EXPECT(m2.is_const_);
|
EXPECT(m2.isConst());
|
||||||
LONGS_EQUAL(1, m2.nrOverloads());
|
LONGS_EQUAL(1, m2.nrOverloads());
|
||||||
|
|
||||||
ReturnValue rv2 = m2.returnValue(0);
|
ReturnValue rv2 = m2.returnValue(0);
|
||||||
|
@ -122,7 +122,7 @@ TEST( wrap, Small ) {
|
||||||
// Method 3
|
// Method 3
|
||||||
Method m3 = cls.method("returnPoint2");
|
Method m3 = cls.method("returnPoint2");
|
||||||
EXPECT(assert_equal("returnPoint2", m3.name()));
|
EXPECT(assert_equal("returnPoint2", m3.name()));
|
||||||
EXPECT(m3.is_const_);
|
EXPECT(m3.isConst());
|
||||||
LONGS_EQUAL(1, m3.nrOverloads());
|
LONGS_EQUAL(1, m3.nrOverloads());
|
||||||
|
|
||||||
ReturnValue rv3 = m3.returnValue(0);
|
ReturnValue rv3 = m3.returnValue(0);
|
||||||
|
@ -198,7 +198,7 @@ TEST( wrap, Geometry ) {
|
||||||
EXPECT(assert_equal("returnChar", m1.name()));
|
EXPECT(assert_equal("returnChar", m1.name()));
|
||||||
LONGS_EQUAL(1, m1.nrOverloads());
|
LONGS_EQUAL(1, m1.nrOverloads());
|
||||||
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
|
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()));
|
EXPECT(assert_equal("vectorConfusion", m1.name()));
|
||||||
LONGS_EQUAL(1, m1.nrOverloads());
|
LONGS_EQUAL(1, m1.nrOverloads());
|
||||||
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
|
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
|
||||||
EXPECT(!m1.is_const_);
|
EXPECT(!m1.isConst());
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_LONGS_EQUAL(0, cls.static_methods.size());
|
EXPECT_LONGS_EQUAL(0, cls.static_methods.size());
|
||||||
|
@ -254,7 +254,7 @@ TEST( wrap, Geometry ) {
|
||||||
EXPECT(assert_equal("norm", m1.name()));
|
EXPECT(assert_equal("norm", m1.name()));
|
||||||
LONGS_EQUAL(1, m1.nrOverloads());
|
LONGS_EQUAL(1, m1.nrOverloads());
|
||||||
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
|
EXPECT_LONGS_EQUAL(0, m1.argumentList(0).size());
|
||||||
EXPECT(m1.is_const_);
|
EXPECT(m1.isConst());
|
||||||
|
|
||||||
#ifndef WRAP_DISABLE_SERIALIZE
|
#ifndef WRAP_DISABLE_SERIALIZE
|
||||||
// check serialization flag
|
// check serialization flag
|
||||||
|
|
Loading…
Reference in New Issue