From: Mikko Rasa Date: Wed, 28 Dec 2022 11:42:34 +0000 (+0200) Subject: Collapse the component loading functions in SourcePackage::Loader X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=36078a036ecf771ce0f020338f7e812c08a37479;p=builder.git Collapse the component loading functions in SourcePackage::Loader --- diff --git a/source/lib/sourcepackage.cpp b/source/lib/sourcepackage.cpp index 3648df7..0913592 100644 --- a/source/lib/sourcepackage.cpp +++ b/source/lib/sourcepackage.cpp @@ -179,9 +179,9 @@ SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions *o): add("generate", &Loader::generate); add("install", &Loader::component); add("interface_version", &Loader::interface_version); - add("library", &Loader::component_arg, BinaryComponent::LIBRARY); - add("module", &Loader::component_arg, BinaryComponent::MODULE); - add("program", &Loader::component_arg, BinaryComponent::PROGRAM); + add("library", &Loader::component, BinaryComponent::LIBRARY); + add("module", &Loader::component, BinaryComponent::MODULE); + add("program", &Loader::component, BinaryComponent::PROGRAM); add("source_archive", &Loader::source_archive); add("source_tarball", &Loader::source_archive); add("tarball", &Loader::tarball); @@ -216,18 +216,10 @@ void SourcePackage::Loader::feature(const string &n, const string &d) } } -template -void SourcePackage::Loader::component(const string &n) +template +void SourcePackage::Loader::component(Args... args, const string &n) { - C *comp = new C(obj, n); - load_sub(*comp); - obj.components.push_back(comp); -} - -template -void SourcePackage::Loader::component_arg(A a, const string &n) -{ - C *comp = new C(obj, n, a); + C *comp = new C(obj, n, args...); load_sub(*comp); obj.components.push_back(comp); } diff --git a/source/lib/sourcepackage.h b/source/lib/sourcepackage.h index 8be8ada..d37ecf4 100644 --- a/source/lib/sourcepackage.h +++ b/source/lib/sourcepackage.h @@ -34,10 +34,8 @@ public: void finish() override; void feature(const std::string &, const std::string &); - template - void component(const std::string &); - template - void component_arg(A, const std::string &); + template + void component(Args..., const std::string &); void build_info(); void generate(const std::string &); void interface_version(const std::string &);