Now also expand intList
parent
11ab035380
commit
1292d324ff
|
|
@ -47,15 +47,17 @@ namespace fs = boost::filesystem;
|
||||||
// If a number of template arguments were given, generate a number of expanded
|
// If a number of template arguments were given, generate a number of expanded
|
||||||
// class names, e.g., PriorFactor -> PriorFactorPose2, and add those classes
|
// class names, e.g., PriorFactor -> PriorFactorPose2, and add those classes
|
||||||
static void handle_possible_template(vector<Class>& classes, const Class& cls,
|
static void handle_possible_template(vector<Class>& classes, const Class& cls,
|
||||||
const vector<Qualified>& instantiations) {
|
const Template& t) {
|
||||||
if (cls.templateArgs.empty() || instantiations.empty()) {
|
if (cls.templateArgs.empty() || t.empty()) {
|
||||||
classes.push_back(cls);
|
classes.push_back(cls);
|
||||||
} else {
|
} else {
|
||||||
if (cls.templateArgs.size() != 1)
|
if (cls.templateArgs.size() != 1)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"In-line template instantiations only handle a single template argument");
|
"In-line template instantiations only handle a single template argument");
|
||||||
vector<Class> classInstantiations = //
|
string arg = cls.templateArgs.front();
|
||||||
cls.expandTemplate(cls.templateArgs.front(), instantiations);
|
vector<Class> classInstantiations =
|
||||||
|
(t.nrValues() > 0) ? cls.expandTemplate(arg, t.argValues()) :
|
||||||
|
cls.expandTemplate(arg, t.intList());
|
||||||
BOOST_FOREACH(const Class& c, classInstantiations)
|
BOOST_FOREACH(const Class& c, classInstantiations)
|
||||||
classes.push_back(c);
|
classes.push_back(c);
|
||||||
}
|
}
|
||||||
|
|
@ -107,7 +109,7 @@ void Module::parseMarkup(const std::string& data) {
|
||||||
Rule class_p = class_g //
|
Rule class_p = class_g //
|
||||||
[assign_a(cls.namespaces_, namespaces)]
|
[assign_a(cls.namespaces_, namespaces)]
|
||||||
[bl::bind(&handle_possible_template, bl::var(classes), bl::var(cls),
|
[bl::bind(&handle_possible_template, bl::var(classes), bl::var(cls),
|
||||||
bl::var(classTemplate.argValues()))]
|
bl::var(classTemplate))]
|
||||||
[clear_a(classTemplate)] //
|
[clear_a(classTemplate)] //
|
||||||
[assign_a(cls,cls0)];
|
[assign_a(cls,cls0)];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ public:
|
||||||
const std::vector<Qualified>& argValues() const {
|
const std::vector<Qualified>& argValues() const {
|
||||||
return argValues_;
|
return argValues_;
|
||||||
}
|
}
|
||||||
|
bool empty() const {
|
||||||
|
return argValues_.empty() && intList_.empty();
|
||||||
|
}
|
||||||
size_t nrValues() const {
|
size_t nrValues() const {
|
||||||
return argValues_.size();
|
return argValues_.size();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue