From 1292d324ff7362ab507ae8f2539cca5de0d0ce52 Mon Sep 17 00:00:00 2001 From: dellaert Date: Thu, 22 Jan 2015 03:35:08 +0100 Subject: [PATCH] Now also expand intList --- wrap/Module.cpp | 12 +++++++----- wrap/Template.h | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) 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 e04ea1792..c6f6833c8 100644 --- a/wrap/Template.h +++ b/wrap/Template.h @@ -45,6 +45,9 @@ public: const std::vector& argValues() const { return argValues_; } + bool empty() const { + return argValues_.empty() && intList_.empty(); + } size_t nrValues() const { return argValues_.size(); }