Class TemplateInstantiationTypedef::findAndExpand(const vector<Class>& classes) const {
		// Find matching class
		std::vector<Class>::const_iterator clsIt = classes.end();
		for(std::vector<Class>::const_iterator it = classes.begin(); it != classes.end(); ++it) {
			if(it->name == className && it->namespaces == classNamespaces && it->templateArgs.size() == typeList.size()) {
				clsIt = it;
				break;
			}
		}

		if(clsIt == classes.end())
			throw DependencyMissing(wrap::qualifiedName("::", classNamespaces, className),
			"instantiation into typedef name " + wrap::qualifiedName("::", namespaces, name) +
			".  Ensure that the typedef provides the correct number of template arguments.");

		// Instantiate it
		Class classInst = *clsIt;
		for(size_t i = 0; i < typeList.size(); ++i)
			classInst = classInst.expandTemplate(classInst.templateArgs[i], typeList[i], namespaces, name);

		// Fix class properties
		classInst.name = name;
		classInst.templateArgs.clear();
		classInst.typedefName = clsIt->qualifiedName("::") + "<";
		if(typeList.size() > 0)
			classInst.typedefName += wrap::qualifiedName("::", typeList[0]);
		for(size_t i = 1; i < typeList.size(); ++i)
			classInst.typedefName += (", " + wrap::qualifiedName("::", typeList[i]));
		classInst.typedefName += ">";
		classInst.namespaces = namespaces;

		return classInst;
	}
Пример #2
0
/* ************************************************************************* */ 
void handle_possible_template(vector<Class>& classes, const Class& cls, const string& templateArgument, const vector<vector<string> >& instantiations) { 
	if(instantiations.empty()) { 
		classes.push_back(cls); 
	} else { 
		vector<Class> classInstantiations = cls.expandTemplate(templateArgument, instantiations); 
		BOOST_FOREACH(const Class& c, classInstantiations) { 
			classes.push_back(c); 
		} 
	}