From 8ef78db9d86be040249ac2fab2721792e2a9845e Mon Sep 17 00:00:00 2001 From: dellaert Date: Thu, 13 Nov 2014 21:53:58 +0100 Subject: [PATCH] Fixed template expansion of classes --- wrap/Class.cpp | 3 --- wrap/Function.h | 11 +++-------- wrap/tests/expected2/geometry_wrapper.cpp | 2 ++ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 316f65da2..f7f9ba7ee 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -248,7 +248,6 @@ Class Class::expandTemplate(const TemplateSubstitution& ts) const { inst.static_methods = expandMethodTemplate(static_methods, ts); inst.constructor = constructor.expandTemplate(ts); inst.deconstructor.name = inst.name; - cout << inst << endl; return inst; } @@ -256,12 +255,10 @@ Class Class::expandTemplate(const TemplateSubstitution& ts) const { vector Class::expandTemplate(Str templateArg, const vector& instantiations) const { vector result; - cout << *this << endl; BOOST_FOREACH(const Qualified& instName, instantiations) { Qualified expandedClass = (Qualified) (*this); expandedClass.name += instName.name; const TemplateSubstitution ts(templateArg, instName, expandedClass); - cout << ts << endl; Class inst = expandTemplate(ts); inst.name = expandedClass.name; inst.templateArgs.clear(); diff --git a/wrap/Function.h b/wrap/Function.h index a06f35145..3af7b38fc 100644 --- a/wrap/Function.h +++ b/wrap/Function.h @@ -187,13 +187,6 @@ public: // Templated checking functions // TODO: do this via polymorphism ? -template -F expandMethodTemplate(F& method, const TemplateSubstitution& ts) { - F instMethod = method; - method.expandTemplate(ts); - return instMethod; -} - // TODO use transform template static std::map expandMethodTemplate( @@ -201,7 +194,9 @@ static std::map expandMethodTemplate( std::map result; typedef std::pair NamedMethod; BOOST_FOREACH(NamedMethod namedMethod, methods) { - namedMethod.second = expandMethodTemplate(namedMethod.second, ts); + F instMethod = namedMethod.second; + instMethod.expandTemplate(ts); + namedMethod.second = instMethod; result.insert(namedMethod); } return result; diff --git a/wrap/tests/expected2/geometry_wrapper.cpp b/wrap/tests/expected2/geometry_wrapper.cpp index 61b58b16b..ab6ae5aa7 100644 --- a/wrap/tests/expected2/geometry_wrapper.cpp +++ b/wrap/tests/expected2/geometry_wrapper.cpp @@ -672,6 +672,7 @@ void MyTemplatePoint2_templatedMethod_54(int nargout, mxArray *out[], int nargin gtsam::Point2& t = *unwrap_shared_ptr< gtsam::Point2 >(in[1], "ptr_gtsamPoint2"); obj->templatedMethod(t); } + void MyTemplatePoint2_templatedMethod_55(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr Shared; @@ -815,6 +816,7 @@ void MyTemplatePoint3_templatedMethod_67(int nargout, mxArray *out[], int nargin gtsam::Point2& t = *unwrap_shared_ptr< gtsam::Point2 >(in[1], "ptr_gtsamPoint2"); obj->templatedMethod(t); } + void MyTemplatePoint3_templatedMethod_68(int nargout, mxArray *out[], int nargin, const mxArray *in[]) { typedef boost::shared_ptr Shared;