From 699943d63259871d32ba1c362cf7bb45b5643cd3 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 7 Feb 2016 20:33:48 -0800 Subject: [PATCH 1/2] Changes to wrap from FixedValues branch/PR. Since unrelated to that PR and useful for OptionalJacobian wrapping in py_wrap, made this a separate PR. --- wrap/Class.cpp | 20 ++++++++++++++++ wrap/Class.h | 4 ++++ wrap/Module.cpp | 12 ++++++---- wrap/Template.h | 48 +++++++++++++++++++++++++++++++++++-- wrap/tests/geometry.h | 6 +++++ wrap/tests/testClass.cpp | 23 ++++++++++++++++++ wrap/tests/testTemplate.cpp | 9 +++++++ wrap/tests/testWrap.cpp | 4 ++-- 8 files changed, 117 insertions(+), 9 deletions(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 6e415065d..e62e31bc1 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include // std::ostream_iterator //#include // on Linux GCC: fails with error regarding needing C++0x std flags //#include // same failure as above @@ -314,6 +315,25 @@ vector Class::expandTemplate(Str templateArg, return result; } +/* ************************************************************************* */ +vector Class::expandTemplate(Str templateArg, + const vector& integers) const { + vector result; + BOOST_FOREACH(int i, integers) { + Qualified expandedClass = (Qualified) (*this); + stringstream ss; ss << i; + string instName = ss.str(); + expandedClass.expand(instName); + const TemplateSubstitution ts(templateArg, instName, expandedClass); + Class inst = expandTemplate(ts); + inst.name_ = expandedClass.name(); + inst.templateArgs.clear(); + inst.typedefName = qualifiedName("::") + "<" + instName + ">"; + result.push_back(inst); + } + return result; +} + /* ************************************************************************* */ void Class::addMethod(bool verbose, bool is_const, Str methodName, const ArgumentList& argumentList, const ReturnValue& returnValue, diff --git a/wrap/Class.h b/wrap/Class.h index f4c687eca..2f7457f06 100644 --- a/wrap/Class.h +++ b/wrap/Class.h @@ -106,6 +106,10 @@ public: std::vector expandTemplate(Str templateArg, const std::vector& instantiations) const; + // Create new classes with integer template arguments + std::vector expandTemplate(Str templateArg, + const std::vector& integers) const; + /// Add potentially overloaded, potentially templated method void addMethod(bool verbose, bool is_const, Str methodName, const ArgumentList& argumentList, const ReturnValue& returnValue, diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 092c732f7..9d505a525 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -47,15 +47,17 @@ namespace fs = boost::filesystem; // If a number of template arguments were given, generate a number of expanded // class names, e.g., PriorFactor -> PriorFactorPose2, and add those classes static void handle_possible_template(vector& classes, const Class& cls, - const vector& instantiations) { - if (cls.templateArgs.empty() || instantiations.empty()) { + const Template& t) { + if (cls.templateArgs.empty() || t.empty()) { classes.push_back(cls); } else { if (cls.templateArgs.size() != 1) throw std::runtime_error( "In-line template instantiations only handle a single template argument"); - vector classInstantiations = // - cls.expandTemplate(cls.templateArgs.front(), instantiations); + string arg = cls.templateArgs.front(); + vector classInstantiations = + (t.nrValues() > 0) ? cls.expandTemplate(arg, t.argValues()) : + cls.expandTemplate(arg, t.intList()); BOOST_FOREACH(const Class& c, classInstantiations) classes.push_back(c); } @@ -107,7 +109,7 @@ void Module::parseMarkup(const std::string& data) { Rule class_p = class_g // [assign_a(cls.namespaces_, namespaces)] [bl::bind(&handle_possible_template, bl::var(classes), bl::var(cls), - bl::var(classTemplate.argValues()))] + bl::var(classTemplate))] [clear_a(classTemplate)] // [assign_a(cls,cls0)]; diff --git a/wrap/Template.h b/wrap/Template.h index 5a64412ed..991c6c883 100644 --- a/wrap/Template.h +++ b/wrap/Template.h @@ -26,6 +26,7 @@ namespace wrap { class Template { std::string argName_; std::vector argValues_; + std::vector intList_; friend struct TemplateGrammar; public: /// The only way to get values into a Template is via our friendly Grammar @@ -34,13 +35,20 @@ public: void clear() { argName_.clear(); argValues_.clear(); + intList_.clear(); } const std::string& argName() const { return argName_; } + const std::vector& intList() const { + return intList_; + } const std::vector& argValues() const { return argValues_; } + bool empty() const { + return argValues_.empty() && intList_.empty(); + } size_t nrValues() const { return argValues_.size(); } @@ -53,16 +61,52 @@ public: }; +/* ************************************************************************* */ +// http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html +struct IntListGrammar: public classic::grammar { + + typedef std::vector IntList; + IntList& result_; ///< successful parse will be placed in here + + /// Construct type grammar and specify where result is placed + IntListGrammar(IntList& result) : + result_(result) { + } + + /// Definition of type grammar + template + struct definition { + + classic::rule integer_p, intList_p; + + definition(IntListGrammar const& self) { + using namespace classic; + + integer_p = int_p[push_back_a(self.result_)]; + + intList_p = '{' >> !integer_p >> *(',' >> integer_p) >> '}'; + } + + classic::rule const& start() const { + return intList_p; + } + + }; +}; +// IntListGrammar + /* ************************************************************************* */ // http://boost-spirit.com/distrib/spirit_1_8_2/libs/spirit/doc/grammar.html struct TemplateGrammar: public classic::grammar { Template& result_; ///< successful parse will be placed in here TypeListGrammar<'{', '}'> argValues_g; ///< TypeList parser + IntListGrammar intList_g; ///< TypeList parser /// Construct type grammar and specify where result is placed TemplateGrammar(Template& result) : - result_(result), argValues_g(result.argValues_) { + result_(result), argValues_g(result.argValues_), // + intList_g(result.intList_) { } /// Definition of type grammar @@ -76,7 +120,7 @@ struct TemplateGrammar: public classic::grammar { using classic::assign_a; templateArgValues_p = (str_p("template") >> '<' >> (BasicRules::name_p)[assign_a(self.result_.argName_)] - >> '=' >> self.argValues_g >> '>'); + >> '=' >> (self.argValues_g | self.intList_g) >> '>'); } classic::rule const& start() const { diff --git a/wrap/tests/geometry.h b/wrap/tests/geometry.h index 69bc7e3be..376e39b62 100644 --- a/wrap/tests/geometry.h +++ b/wrap/tests/geometry.h @@ -127,6 +127,12 @@ class MyFactor { // and a typedef specializing it typedef MyFactor MyFactorPosePoint2; +// A class with integer template arguments +template +class MyVector { + MyVector(); +}; + // comments at the end! // even more comments at the end! diff --git a/wrap/tests/testClass.cpp b/wrap/tests/testClass.cpp index a133e15ac..3d8d79b33 100644 --- a/wrap/tests/testClass.cpp +++ b/wrap/tests/testClass.cpp @@ -221,6 +221,29 @@ TEST( Class, TemplateSubstition ) { } +//****************************************************************************** +TEST( Class, TemplateSubstitionIntList ) { + + using classic::space_p; + + // Create type grammar that will place result in cls + Class cls; + Template t; + ClassGrammar g(cls, t); + + string markup(string("template" + "class Point2 {" + " void myMethod(Matrix A) const;" + "};")); + + EXPECT(parse(markup.c_str(), g, space_p).full); + + vector classes = cls.expandTemplate(t.argName(), t.intList()); + + // check the number of new classes is 2 + EXPECT_LONGS_EQUAL(2, classes.size()); +} + //****************************************************************************** TEST(Class, Template) { diff --git a/wrap/tests/testTemplate.cpp b/wrap/tests/testTemplate.cpp index 37cb95205..eed144677 100644 --- a/wrap/tests/testTemplate.cpp +++ b/wrap/tests/testTemplate.cpp @@ -47,6 +47,15 @@ TEST( Template, grammar ) { EXPECT(actual[2]==Qualified("Vector",Qualified::EIGEN)); EXPECT(actual[3]==Qualified("Matrix",Qualified::EIGEN)); actual.clear(); + + EXPECT(parse("template", g, space_p).full); + EXPECT_LONGS_EQUAL(4, actual.intList().size()); + EXPECT(actual.argName()=="N"); + EXPECT_LONGS_EQUAL(1,actual.intList()[0]); + EXPECT_LONGS_EQUAL(2,actual.intList()[1]); + EXPECT_LONGS_EQUAL(3,actual.intList()[2]); + EXPECT_LONGS_EQUAL(4,actual.intList()[3]); + actual.clear(); } //****************************************************************************** diff --git a/wrap/tests/testWrap.cpp b/wrap/tests/testWrap.cpp index c03c40444..d8d952413 100644 --- a/wrap/tests/testWrap.cpp +++ b/wrap/tests/testWrap.cpp @@ -144,7 +144,7 @@ TEST( wrap, Small ) { TEST( wrap, Geometry ) { string markup_header_path = topdir + "/wrap/tests"; Module module(markup_header_path.c_str(), "geometry",enable_verbose); - EXPECT_LONGS_EQUAL(7, module.classes.size()); + EXPECT_LONGS_EQUAL(9, module.classes.size()); // forward declarations LONGS_EQUAL(2, module.forward_declarations.size()); @@ -155,7 +155,7 @@ TEST( wrap, Geometry ) { strvec exp_includes; exp_includes += "folder/path/to/Test.h"; EXPECT(assert_equal(exp_includes, module.includes)); - LONGS_EQUAL(7, module.classes.size()); + LONGS_EQUAL(9, module.classes.size()); // Key for ReturnType::return_category // CLASS = 1, From 5b581a36c9497b8b9d44dda270434356b2cfbd60 Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 7 Feb 2016 20:34:16 -0800 Subject: [PATCH 2/2] Made tests succeed, added templated Vector templates --- .../tests/expected-python/geometry_python.cpp | 8 ++ wrap/tests/expected/MyFactorPosePoint2.m | 6 +- wrap/tests/expected/MyVector12.m | 36 +++++ wrap/tests/expected/MyVector3.m | 36 +++++ wrap/tests/expected/aGlobalFunction.m | 2 +- wrap/tests/expected/geometry_wrapper.cpp | 126 ++++++++++++++++-- .../tests/expected/overloadedGlobalFunction.m | 4 +- wrap/tests/testWrap.cpp | 10 +- 8 files changed, 206 insertions(+), 22 deletions(-) create mode 100644 wrap/tests/expected/MyVector12.m create mode 100644 wrap/tests/expected/MyVector3.m diff --git a/wrap/tests/expected-python/geometry_python.cpp b/wrap/tests/expected-python/geometry_python.cpp index 609b67476..582fdfc13 100644 --- a/wrap/tests/expected-python/geometry_python.cpp +++ b/wrap/tests/expected-python/geometry_python.cpp @@ -79,6 +79,14 @@ class_("MyTemplateMatrix") .def("templatedMethod", &MyTemplateMatrix::templatedMethod); ; +class_("MyVector3") + .def("MyVector3", &MyVector3::MyVector3); +; + +class_("MyVector12") + .def("MyVector12", &MyVector12::MyVector12); +; + class_("MyFactorPosePoint2") .def("MyFactorPosePoint2", &MyFactorPosePoint2::MyFactorPosePoint2); ; diff --git a/wrap/tests/expected/MyFactorPosePoint2.m b/wrap/tests/expected/MyFactorPosePoint2.m index 2dff98803..b55488b58 100644 --- a/wrap/tests/expected/MyFactorPosePoint2.m +++ b/wrap/tests/expected/MyFactorPosePoint2.m @@ -12,9 +12,9 @@ classdef MyFactorPosePoint2 < handle function obj = MyFactorPosePoint2(varargin) if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682) my_ptr = varargin{2}; - geometry_wrapper(76, my_ptr); + geometry_wrapper(82, my_ptr); elseif nargin == 4 && isa(varargin{1},'numeric') && isa(varargin{2},'numeric') && isa(varargin{3},'double') && isa(varargin{4},'gtsam.noiseModel.Base') - my_ptr = geometry_wrapper(77, varargin{1}, varargin{2}, varargin{3}, varargin{4}); + my_ptr = geometry_wrapper(83, varargin{1}, varargin{2}, varargin{3}, varargin{4}); else error('Arguments do not match any overload of MyFactorPosePoint2 constructor'); end @@ -22,7 +22,7 @@ classdef MyFactorPosePoint2 < handle end function delete(obj) - geometry_wrapper(78, obj.ptr_MyFactorPosePoint2); + geometry_wrapper(84, obj.ptr_MyFactorPosePoint2); end function display(obj), obj.print(''); end diff --git a/wrap/tests/expected/MyVector12.m b/wrap/tests/expected/MyVector12.m new file mode 100644 index 000000000..9d32c285a --- /dev/null +++ b/wrap/tests/expected/MyVector12.m @@ -0,0 +1,36 @@ +%class MyVector12, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% +%-------Constructors------- +%MyVector12() +% +classdef MyVector12 < handle + properties + ptr_MyVector12 = 0 + end + methods + function obj = MyVector12(varargin) + if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682) + my_ptr = varargin{2}; + geometry_wrapper(79, my_ptr); + elseif nargin == 0 + my_ptr = geometry_wrapper(80); + else + error('Arguments do not match any overload of MyVector12 constructor'); + end + obj.ptr_MyVector12 = my_ptr; + end + + function delete(obj) + geometry_wrapper(81, obj.ptr_MyVector12); + end + + function display(obj), obj.print(''); end + %DISPLAY Calls print on the object + function disp(obj), obj.display; end + %DISP Calls print on the object + end + + methods(Static = true) + end +end diff --git a/wrap/tests/expected/MyVector3.m b/wrap/tests/expected/MyVector3.m new file mode 100644 index 000000000..ef4b90a00 --- /dev/null +++ b/wrap/tests/expected/MyVector3.m @@ -0,0 +1,36 @@ +%class MyVector3, see Doxygen page for details +%at http://research.cc.gatech.edu/borg/sites/edu.borg/html/index.html +% +%-------Constructors------- +%MyVector3() +% +classdef MyVector3 < handle + properties + ptr_MyVector3 = 0 + end + methods + function obj = MyVector3(varargin) + if nargin == 2 && isa(varargin{1}, 'uint64') && varargin{1} == uint64(5139824614673773682) + my_ptr = varargin{2}; + geometry_wrapper(76, my_ptr); + elseif nargin == 0 + my_ptr = geometry_wrapper(77); + else + error('Arguments do not match any overload of MyVector3 constructor'); + end + obj.ptr_MyVector3 = my_ptr; + end + + function delete(obj) + geometry_wrapper(78, obj.ptr_MyVector3); + end + + function display(obj), obj.print(''); end + %DISPLAY Calls print on the object + function disp(obj), obj.display; end + %DISP Calls print on the object + end + + methods(Static = true) + end +end diff --git a/wrap/tests/expected/aGlobalFunction.m b/wrap/tests/expected/aGlobalFunction.m index df970c759..e507ad3b0 100644 --- a/wrap/tests/expected/aGlobalFunction.m +++ b/wrap/tests/expected/aGlobalFunction.m @@ -1,6 +1,6 @@ function varargout = aGlobalFunction(varargin) if length(varargin) == 0 - varargout{1} = geometry_wrapper(79, varargin{:}); + varargout{1} = geometry_wrapper(85, varargin{:}); else error('Arguments do not match any overload of function aGlobalFunction'); end diff --git a/wrap/tests/expected/geometry_wrapper.cpp b/wrap/tests/expected/geometry_wrapper.cpp index 585918f20..226030a0d 100644 --- a/wrap/tests/expected/geometry_wrapper.cpp +++ b/wrap/tests/expected/geometry_wrapper.cpp @@ -10,6 +10,8 @@ typedef MyTemplate MyTemplatePoint2; typedef MyTemplate MyTemplateMatrix; +typedef MyVector<3> MyVector3; +typedef MyVector<12> MyVector12; typedef MyFactor MyFactorPosePoint2; BOOST_CLASS_EXPORT_GUID(gtsam::Point2, "gtsamPoint2"); @@ -27,6 +29,10 @@ typedef std::set*> Collector_MyTemplatePoint static Collector_MyTemplatePoint2 collector_MyTemplatePoint2; typedef std::set*> Collector_MyTemplateMatrix; static Collector_MyTemplateMatrix collector_MyTemplateMatrix; +typedef std::set*> Collector_MyVector3; +static Collector_MyVector3 collector_MyVector3; +typedef std::set*> Collector_MyVector12; +static Collector_MyVector12 collector_MyVector12; typedef std::set*> Collector_MyFactorPosePoint2; static Collector_MyFactorPosePoint2 collector_MyFactorPosePoint2; @@ -72,6 +78,18 @@ void _deleteAllObjects() collector_MyTemplateMatrix.erase(iter++); anyDeleted = true; } } + { for(Collector_MyVector3::iterator iter = collector_MyVector3.begin(); + iter != collector_MyVector3.end(); ) { + delete *iter; + collector_MyVector3.erase(iter++); + anyDeleted = true; + } } + { for(Collector_MyVector12::iterator iter = collector_MyVector12.begin(); + iter != collector_MyVector12.end(); ) { + delete *iter; + collector_MyVector12.erase(iter++); + anyDeleted = true; + } } { for(Collector_MyFactorPosePoint2::iterator iter = collector_MyFactorPosePoint2.begin(); iter != collector_MyFactorPosePoint2.end(); ) { delete *iter; @@ -914,7 +932,73 @@ void MyTemplateMatrix_templatedMethod_75(int nargout, mxArray *out[], int nargin out[0] = wrap< Vector >(obj->templatedMethod(t)); } -void MyFactorPosePoint2_collectorInsertAndMakeBase_76(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyVector3_collectorInsertAndMakeBase_76(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef boost::shared_ptr Shared; + + Shared *self = *reinterpret_cast (mxGetData(in[0])); + collector_MyVector3.insert(self); +} + +void MyVector3_constructor_77(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef boost::shared_ptr Shared; + + Shared *self = new Shared(new MyVector3()); + collector_MyVector3.insert(self); + out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL); + *reinterpret_cast (mxGetData(out[0])) = self; +} + +void MyVector3_deconstructor_78(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + typedef boost::shared_ptr Shared; + checkArguments("delete_MyVector3",nargout,nargin,1); + Shared *self = *reinterpret_cast(mxGetData(in[0])); + Collector_MyVector3::iterator item; + item = collector_MyVector3.find(self); + if(item != collector_MyVector3.end()) { + delete self; + collector_MyVector3.erase(item); + } +} + +void MyVector12_collectorInsertAndMakeBase_79(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef boost::shared_ptr Shared; + + Shared *self = *reinterpret_cast (mxGetData(in[0])); + collector_MyVector12.insert(self); +} + +void MyVector12_constructor_80(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + mexAtExit(&_deleteAllObjects); + typedef boost::shared_ptr Shared; + + Shared *self = new Shared(new MyVector12()); + collector_MyVector12.insert(self); + out[0] = mxCreateNumericMatrix(1, 1, mxUINT32OR64_CLASS, mxREAL); + *reinterpret_cast (mxGetData(out[0])) = self; +} + +void MyVector12_deconstructor_81(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +{ + typedef boost::shared_ptr Shared; + checkArguments("delete_MyVector12",nargout,nargin,1); + Shared *self = *reinterpret_cast(mxGetData(in[0])); + Collector_MyVector12::iterator item; + item = collector_MyVector12.find(self); + if(item != collector_MyVector12.end()) { + delete self; + collector_MyVector12.erase(item); + } +} + +void MyFactorPosePoint2_collectorInsertAndMakeBase_82(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { mexAtExit(&_deleteAllObjects); typedef boost::shared_ptr Shared; @@ -923,7 +1007,7 @@ void MyFactorPosePoint2_collectorInsertAndMakeBase_76(int nargout, mxArray *out[ collector_MyFactorPosePoint2.insert(self); } -void MyFactorPosePoint2_constructor_77(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_constructor_83(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { mexAtExit(&_deleteAllObjects); typedef boost::shared_ptr Shared; @@ -938,7 +1022,7 @@ void MyFactorPosePoint2_constructor_77(int nargout, mxArray *out[], int nargin, *reinterpret_cast (mxGetData(out[0])) = self; } -void MyFactorPosePoint2_deconstructor_78(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void MyFactorPosePoint2_deconstructor_84(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr Shared; checkArguments("delete_MyFactorPosePoint2",nargout,nargin,1); @@ -951,18 +1035,18 @@ void MyFactorPosePoint2_deconstructor_78(int nargout, mxArray *out[], int nargin } } -void aGlobalFunction_79(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void aGlobalFunction_85(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("aGlobalFunction",nargout,nargin,0); out[0] = wrap< Vector >(aGlobalFunction()); } -void overloadedGlobalFunction_80(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void overloadedGlobalFunction_86(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("overloadedGlobalFunction",nargout,nargin,1); int a = unwrap< int >(in[0]); out[0] = wrap< Vector >(overloadedGlobalFunction(a)); } -void overloadedGlobalFunction_81(int nargout, mxArray *out[], int nargin, const mxArray *in[]) +void overloadedGlobalFunction_87(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { checkArguments("overloadedGlobalFunction",nargout,nargin,2); int a = unwrap< int >(in[0]); @@ -1210,22 +1294,40 @@ void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[]) MyTemplateMatrix_templatedMethod_75(nargout, out, nargin-1, in+1); break; case 76: - MyFactorPosePoint2_collectorInsertAndMakeBase_76(nargout, out, nargin-1, in+1); + MyVector3_collectorInsertAndMakeBase_76(nargout, out, nargin-1, in+1); break; case 77: - MyFactorPosePoint2_constructor_77(nargout, out, nargin-1, in+1); + MyVector3_constructor_77(nargout, out, nargin-1, in+1); break; case 78: - MyFactorPosePoint2_deconstructor_78(nargout, out, nargin-1, in+1); + MyVector3_deconstructor_78(nargout, out, nargin-1, in+1); break; case 79: - aGlobalFunction_79(nargout, out, nargin-1, in+1); + MyVector12_collectorInsertAndMakeBase_79(nargout, out, nargin-1, in+1); break; case 80: - overloadedGlobalFunction_80(nargout, out, nargin-1, in+1); + MyVector12_constructor_80(nargout, out, nargin-1, in+1); break; case 81: - overloadedGlobalFunction_81(nargout, out, nargin-1, in+1); + MyVector12_deconstructor_81(nargout, out, nargin-1, in+1); + break; + case 82: + MyFactorPosePoint2_collectorInsertAndMakeBase_82(nargout, out, nargin-1, in+1); + break; + case 83: + MyFactorPosePoint2_constructor_83(nargout, out, nargin-1, in+1); + break; + case 84: + MyFactorPosePoint2_deconstructor_84(nargout, out, nargin-1, in+1); + break; + case 85: + aGlobalFunction_85(nargout, out, nargin-1, in+1); + break; + case 86: + overloadedGlobalFunction_86(nargout, out, nargin-1, in+1); + break; + case 87: + overloadedGlobalFunction_87(nargout, out, nargin-1, in+1); break; } } catch(const std::exception& e) { diff --git a/wrap/tests/expected/overloadedGlobalFunction.m b/wrap/tests/expected/overloadedGlobalFunction.m index 16d24021e..458779e2c 100644 --- a/wrap/tests/expected/overloadedGlobalFunction.m +++ b/wrap/tests/expected/overloadedGlobalFunction.m @@ -1,8 +1,8 @@ function varargout = overloadedGlobalFunction(varargin) if length(varargin) == 1 && isa(varargin{1},'numeric') - varargout{1} = geometry_wrapper(80, varargin{:}); + varargout{1} = geometry_wrapper(86, varargin{:}); elseif length(varargin) == 2 && isa(varargin{1},'numeric') && isa(varargin{2},'double') - varargout{1} = geometry_wrapper(81, varargin{:}); + varargout{1} = geometry_wrapper(87, varargin{:}); else error('Arguments do not match any overload of function overloadedGlobalFunction'); end diff --git a/wrap/tests/testWrap.cpp b/wrap/tests/testWrap.cpp index d8d952413..3f6ccb9f1 100644 --- a/wrap/tests/testWrap.cpp +++ b/wrap/tests/testWrap.cpp @@ -445,15 +445,17 @@ TEST( wrap, matlab_code_geometry ) { string apath = "actual/"; EXPECT(files_equal(epath + "geometry_wrapper.cpp" , apath + "geometry_wrapper.cpp" )); - EXPECT(files_equal(epath + "+gtsam/Point2.m" , apath + "+gtsam/Point2.m" )); - EXPECT(files_equal(epath + "+gtsam/Point3.m" , apath + "+gtsam/Point3.m" )); + EXPECT(files_equal(epath + "+gtsam/Point2.m" , apath + "+gtsam/Point2.m" )); + EXPECT(files_equal(epath + "+gtsam/Point3.m" , apath + "+gtsam/Point3.m" )); EXPECT(files_equal(epath + "Test.m" , apath + "Test.m" )); EXPECT(files_equal(epath + "MyBase.m" , apath + "MyBase.m" )); + EXPECT(files_equal(epath + "MyVector3.m" , apath + "MyVector3.m" )); + EXPECT(files_equal(epath + "MyVector12.m" , apath + "MyVector12.m" )); EXPECT(files_equal(epath + "MyTemplatePoint2.m" , apath + "MyTemplatePoint2.m" )); EXPECT(files_equal(epath + "MyTemplateMatrix.m" , apath + "MyTemplateMatrix.m" )); - EXPECT(files_equal(epath + "MyFactorPosePoint2.m" , apath + "MyFactorPosePoint2.m")); + EXPECT(files_equal(epath + "MyFactorPosePoint2.m" , apath + "MyFactorPosePoint2.m" )); EXPECT(files_equal(epath + "aGlobalFunction.m" , apath + "aGlobalFunction.m" )); - EXPECT(files_equal(epath + "overloadedGlobalFunction.m" , apath + "overloadedGlobalFunction.m" )); + EXPECT(files_equal(epath + "overloadedGlobalFunction.m", apath + "overloadedGlobalFunction.m")); } /* ************************************************************************* */