From: Mikko Rasa Date: Mon, 19 Dec 2022 17:18:11 +0000 (+0200) Subject: Remove most container typedefs and refactor others X-Git-Url: http://git.tdb.fi/?p=builder.git;a=commitdiff_plain;h=3938f8030b1f62802decce19777ce70fdafaff10 Remove most container typedefs and refactor others --- diff --git a/source/analyzer.h b/source/analyzer.h index 5464dac..373150b 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -25,12 +25,11 @@ public: }; private: - typedef std::vector TableRow; - typedef std::list Table; + using TableRow = std::vector; Builder &builder; Mode mode; - Table table; + std::list table; unsigned max_depth; bool full_paths; std::map > rdepends; diff --git a/source/architecture.h b/source/architecture.h index 5b894b1..7f3c4b2 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -21,8 +21,6 @@ public: Loader(Architecture &); }; - typedef std::list PatternList; - private: Builder &builder; std::string type; @@ -34,7 +32,7 @@ private: std::string name; bool native; std::string cross_prefix; - std::map filename_patterns; + std::map> filename_patterns; public: Architecture(Builder &b, const std::string &spec); @@ -54,7 +52,7 @@ public: const std::string &get_cross_prefix() const { return cross_prefix; } template - const PatternList &get_patterns() const; + const std::list &get_patterns() const; template std::string create_filename(const std::string &) const; @@ -69,20 +67,20 @@ private: }; template -inline const Architecture::PatternList &Architecture::get_patterns() const +inline const std::list &Architecture::get_patterns() const { auto i = filename_patterns.find(typeid(T).name()); if(i!=filename_patterns.end()) return i->second; - static PatternList empty; + static std::list empty; return empty; } template inline std::string Architecture::create_filename(const std::string &base) const { - const PatternList &patterns = get_patterns(); + const std::list &patterns = get_patterns(); return patterns.empty() ? base : patterns.front().apply(base); } diff --git a/source/binarycomponent.cpp b/source/binarycomponent.cpp index 816b385..f1aaa0e 100644 --- a/source/binarycomponent.cpp +++ b/source/binarycomponent.cpp @@ -54,7 +54,7 @@ void BinaryComponent::create_targets() const const Toolchain &pkg_tools = package.get_toolchain(); list objs; - SourceList source_filenames = collect_source_files(); + list source_filenames = collect_source_files(); for(auto i=source_filenames.begin(); i!=source_filenames.end(); ++i) { string ext = FS::extpart(FS::basename(*i)); diff --git a/source/binarycomponent.h b/source/binarycomponent.h index 7c84534..c31fff2 100644 --- a/source/binarycomponent.h +++ b/source/binarycomponent.h @@ -22,10 +22,8 @@ public: }; private: - typedef std::list UseList; - Type type; - UseList uses; + std::list uses; public: BinaryComponent(SourcePackage &, const std::string &, Type); diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index 02b9be2..c0d688a 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -83,7 +83,7 @@ void BinaryPackage::do_prepare() prefix /= arch.get_cross_prefix(); } - BuildInfo::PathList libpath = export_binfo.libpath; + VirtualFileSystem::SearchPath libpath = export_binfo.libpath; if(!system && libpath.empty()) libpath.push_back("lib"); for(FS::Path &p: libpath) @@ -93,7 +93,7 @@ void BinaryPackage::do_prepare() for(const string &l: export_binfo.libs) all_found &= (builder.get_vfs().find_library(l, libpath, export_binfo.libmode, system)!=0); - BuildInfo::PathList incpath = export_binfo.incpath; + VirtualFileSystem::SearchPath incpath = export_binfo.incpath; if(!system && incpath.empty()) incpath.push_back("include"); for(FS::Path &p: incpath) @@ -135,7 +135,7 @@ void BinaryPackage::do_prepare() if(!static_binfo.libs.empty()) { - BuildInfo::PathList combined_libpath = static_binfo.libpath; + VirtualFileSystem::SearchPath combined_libpath = static_binfo.libpath; combined_libpath.insert(combined_libpath.end(), export_binfo.libpath.begin(), export_binfo.libpath.end()); for(const string &l: export_binfo.libs) diff --git a/source/binarypackage.h b/source/binarypackage.h index f015ee5..b960155 100644 --- a/source/binarypackage.h +++ b/source/binarypackage.h @@ -19,13 +19,11 @@ public: void header(const std::string &); }; - typedef std::vector Flags; + using Flags = std::vector; private: - typedef std::list HeaderList; - Msp::FS::Path base_path; - HeaderList headers; + std::list headers; BuildInfo static_binfo; public: diff --git a/source/builder.h b/source/builder.h index 70ca861..e6eb0ea 100644 --- a/source/builder.h +++ b/source/builder.h @@ -45,13 +45,11 @@ private: }; private: - typedef std::map BuildTypeMap; - PackageManager package_manager; Architecture native_arch; Architecture *current_arch; - BuildTypeMap build_types; + std::map build_types; BuildType *build_type; Toolchain toolchain; VirtualFileSystem vfs; diff --git a/source/buildercli.cpp b/source/buildercli.cpp index 94b8f52..1952f59 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -353,7 +353,7 @@ void BuilderCLI::package_help() SourcePackage &main_pkg = dynamic_cast(package_manager.get_main_package()); const Config &config = main_pkg.get_config(); - const Config::OptionMap &options = config.get_options(); + const auto &options = config.get_options(); const Package::Requirements &requires = main_pkg.get_required_packages(); if(!requires.empty() || !options.empty()) diff --git a/source/buildercli.h b/source/buildercli.h index 77e58ca..28388a0 100644 --- a/source/buildercli.h +++ b/source/buildercli.h @@ -12,9 +12,7 @@ Provides a command-line interface for Builder. class BuilderCLI: public Msp::RegisteredApplication { private: - typedef std::list NameList; - - NameList cmdline_targets; + std::list cmdline_targets; Config::InputOptions cmdline_options; Msp::FS::Path cwd; @@ -29,7 +27,7 @@ private: bool show_progress; std::string build_file; unsigned jobs; - NameList what_if; + std::list what_if; bool conf_all; bool conf_only; bool build_all; diff --git a/source/buildgraph.h b/source/buildgraph.h index 1636e27..371b544 100644 --- a/source/buildgraph.h +++ b/source/buildgraph.h @@ -12,12 +12,9 @@ Manages a graph of targets. */ class BuildGraph { -public: - typedef std::map TargetMap; - private: Builder &builder; - TargetMap targets; + std::map targets; Target *goals; public: @@ -27,7 +24,7 @@ public: /** Looks up a target by name. Returns 0 if no such target exists. */ Target *get_target(const std::string &) const; - const TargetMap &get_targets() const { return targets; } + const std::map &get_targets() const { return targets; } /** Adds a target. It can later be retrieved by name. Called from Target constructor. */ diff --git a/source/buildinfo.h b/source/buildinfo.h index c058400..f84315c 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -73,7 +73,7 @@ public: class Tracked { public: - typedef T LoadType; + using LoadType = T; private: T value; @@ -89,23 +89,17 @@ public: operator const T &() const { return value; } }; - typedef std::map DefineMap; - typedef std::list PathList; - typedef std::list WordList; - typedef std::map LibModeMap; - typedef std::map StandardMap; - Tracked sysroot; - DefineMap defines; - PathList incpath; - PathList local_incpath; - PathList libpath; - WordList libs; + std::map defines; + std::list incpath; + std::list local_incpath; + std::list libpath; + std::list libs; Tracked libmode; Tracked rpath_mode; - LibModeMap libmodes; - WordList keep_symbols; - StandardMap standards; + std::map libmodes; + std::list keep_symbols; + std::map standards; Tracked threads; Tracked debug; Tracked optimize; diff --git a/source/cache.cpp b/source/cache.cpp index 57b16d1..229783a 100644 --- a/source/cache.cpp +++ b/source/cache.cpp @@ -65,7 +65,7 @@ Cache::Cache(SourcePackage &p): void Cache::set_value(const Target *tgt, const string &k, const string &v) { - ValueList vl; + Values vl; vl.push_back(v); set_values(tgt, k, vl); } @@ -75,13 +75,13 @@ void Cache::append_value(const Target *tgt, const string &k, const string &v) Key key(tgt->get_name(), k); auto i = data.find(key); if(i==data.end()) - i = data.insert({ key, ValueList() }).first; + i = data.insert({ key, Values() }).first; i->second.push_back(v); changed = true; package.get_builder().get_logger().log("cache", format("Updated key %s %s+ %s", tgt->get_name(), k, v)); } -void Cache::set_values(const Target *tgt, const string &k, const ValueList &v) +void Cache::set_values(const Target *tgt, const string &k, const Values &v) { data[Key(tgt->get_name(), k)] = v; changed = true; @@ -90,13 +90,13 @@ void Cache::set_values(const Target *tgt, const string &k, const ValueList &v) const string &Cache::get_value(const Target *tgt, const string &k) { - const ValueList &values = get_values(tgt, k); + const Values &values = get_values(tgt, k); if(values.empty()) throw logic_error("values.empty()"); return values.front(); } -const Cache::ValueList &Cache::get_values(const Target *tgt, const string &k) +const Cache::Values &Cache::get_values(const Target *tgt, const string &k) { return get_item(data, Key(tgt->get_name(), k)); } @@ -120,7 +120,7 @@ void Cache::load() key.second = read_string(in); if(key.first.empty() || key.second.empty()) break; - ValueList &values = data[key]; + Values &values = data[key]; for(unsigned count = read_count(in); count; --count) values.push_back(read_string(in)); package.get_builder().get_logger().log("cache", format("Loaded key %s %s: %s", key.first, key.second, join(values.begin(), values.end()))); diff --git a/source/cache.h b/source/cache.h index 69025fd..cf7253f 100644 --- a/source/cache.h +++ b/source/cache.h @@ -20,14 +20,13 @@ unprintable characters or nuls. class Cache { public: - typedef std::list ValueList; + using Values = std::list; private: - typedef std::pair Key; - typedef std::map DataMap; + using Key = std::pair; SourcePackage &package; Msp::FS::Path filename; - DataMap data; + std::map data; Msp::Time::TimeStamp mtime; mutable bool changed; @@ -41,14 +40,14 @@ public: void append_value(const Target *, const std::string &, const std::string &); /// Sets a key to a list of values, replacing any existing values. - void set_values(const Target *, const std::string &, const ValueList &); + void set_values(const Target *, const std::string &, const Values &); /** Returns the first value from a key. The key must exist and be non-empty. */ const std::string &get_value(const Target *, const std::string &); /// Returns the values from a key. The key must exist. - const ValueList &get_values(const Target *, const std::string &); + const Values &get_values(const Target *, const std::string &); /// Indicates whether a key exists. bool has_key(const Target *, const std::string &); diff --git a/source/component.cpp b/source/component.cpp index 9636251..98b6ff7 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -88,14 +88,14 @@ BuildInfo Component::get_build_info_for_path(const FS::Path &path) const return binfo; } -Component::SourceList Component::collect_source_files() const +list Component::collect_source_files() const { - SourceList files; + list files; for(const FS::Path &p: sources) { if(FS::is_dir(p)) { - SourceList dirs; + list dirs; dirs.push_back(p); for(const string &o: overlays) { diff --git a/source/component.h b/source/component.h index 0e1efad..1db9259 100644 --- a/source/component.h +++ b/source/component.h @@ -32,14 +32,11 @@ public: void source(const std::string &); }; - typedef std::list SourceList; - typedef std::list OverlayList; - protected: SourcePackage &package; std::string name; - SourceList sources; - OverlayList overlays; + std::list sources; + std::list overlays; bool install; BuildInfo build_info; Package::Requirements requires; @@ -56,13 +53,13 @@ public: /** Returns a list of sources for the component. They may refer to directories or individual files. */ - const SourceList &get_sources() const { return sources; } + const std::list &get_sources() const { return sources; } - const OverlayList &get_overlays() const { return overlays; } + const std::list &get_overlays() const { return overlays; } protected: /** Returns a list of all source files for the component. */ - SourceList collect_source_files() const; + std::list collect_source_files() const; public: bool get_install() const { return install; } diff --git a/source/config.h b/source/config.h index 3257794..a82e536 100644 --- a/source/config.h +++ b/source/config.h @@ -25,8 +25,7 @@ public: Option(const Feature &); }; - typedef std::map OptionMap; - typedef std::map InputOptions; + using InputOptions = std::map; private: class Loader: public Msp::DataFile::ObjectLoader @@ -38,7 +37,7 @@ private: }; SourcePackage &package; - OptionMap options; + std::map options; InputOptions pending_options; Msp::Time::TimeStamp mtime; mutable bool changed; @@ -57,7 +56,7 @@ public: /** Gets a configuration option by name. */ const Option &get_option(const std::string &) const; - const OptionMap &get_options() const { return options; } + const std::map &get_options() const { return options; } const Msp::Time::TimeStamp &get_mtime() const { return mtime; } void load(); diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index 954fdba..41dbd43 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -54,8 +54,8 @@ void CSourceFile::find_dependencies() } const BuildInfo &build_info = component->get_build_info_for_path(path); - const BuildInfo::PathList &incpath = build_info.incpath; - BuildInfo::PathList local_incpath = incpath; + const auto &incpath = build_info.incpath; + VirtualFileSystem::SearchPath local_incpath = incpath; local_incpath.insert(local_incpath.begin(), build_info.local_incpath.begin(), build_info.local_incpath.end()); local_incpath.push_front(FS::dirname(path).str()); diff --git a/source/csourcefile.h b/source/csourcefile.h index 55809b0..e585721 100644 --- a/source/csourcefile.h +++ b/source/csourcefile.h @@ -9,18 +9,15 @@ Represents a C or C++ source file. */ class CSourceFile: public SourceFile { -public: - typedef std::list IncludeList; - protected: - IncludeList includes; + std::list includes; public: CSourceFile(Builder &, const Msp::FS::Path &); CSourceFile(Builder &, const Component &, const Msp::FS::Path &); const char *get_type() const override { return "CSourceFile"; } - const IncludeList &get_includes() const { return includes; } + const std::list &get_includes() const { return includes; } protected: virtual void parse_includes(Msp::IO::Base &); void find_dependencies() override; diff --git a/source/datapack.h b/source/datapack.h index 81b2e9e..f676f4a 100644 --- a/source/datapack.h +++ b/source/datapack.h @@ -5,10 +5,8 @@ class DataPack: public FileTarget { -public: - typedef std::list FileList; private: - FileList files; + std::list files; public: DataPack(Builder &, const Component &, const std::list &); @@ -18,7 +16,7 @@ private: public: const char *get_type() const override { return "DataPack"; } - const FileList &get_files() const { return files; } + const std::list &get_files() const { return files; } }; #endif diff --git a/source/externaltask.h b/source/externaltask.h index 8079613..3de1e4a 100644 --- a/source/externaltask.h +++ b/source/externaltask.h @@ -24,7 +24,7 @@ public: IGNORE //< Redirect the stream to oblivion }; - typedef Msp::Process::Arguments Arguments; + using Arguments = Msp::Process::Arguments; private: Arguments argv; diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 4048f1c..7a29016 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -232,7 +232,7 @@ Task *GnuLinker::Linker::run(const Target &target) const { const Binary &bin = dynamic_cast(target); - vector argv; + ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); FS::Path work_dir = bin.get_component()->get_package().get_source_directory(); diff --git a/source/package.h b/source/package.h index 34049d0..a7ae7d4 100644 --- a/source/package.h +++ b/source/package.h @@ -27,7 +27,7 @@ public: void require(const std::string &); }; - typedef std::list Requirements; + using Requirements = std::list; protected: Builder &builder; diff --git a/source/packagemanager.h b/source/packagemanager.h index b168d72..9da4af3 100644 --- a/source/packagemanager.h +++ b/source/packagemanager.h @@ -15,19 +15,14 @@ packages by name. */ class PackageManager { -public: - typedef std::map PackageMap; - private: - typedef std::list SearchPath; - Builder &builder; - SearchPath pkg_path; - SearchPath pkg_dirs; - SearchPath binpkg_path; - SearchPath binpkg_files; + std::list pkg_path; + std::list pkg_dirs; + std::list binpkg_path; + std::list binpkg_files; bool no_externals; - PackageMap packages; + std::map packages; Package *main_pkg; std::set not_found; bool env_set; @@ -55,7 +50,7 @@ public: the primary build target. */ Package &get_main_package() const; - const PackageMap &get_packages() const { return packages; } + const std::map &get_packages() const { return packages; } /** Locates a package and loads it if necessary. */ Package *find_package(const std::string &); diff --git a/source/sourcepackage.h b/source/sourcepackage.h index fce58a6..cb2ab9d 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -46,11 +46,7 @@ public: void version(const std::string &); }; - typedef std::list ComponentList; - private: - typedef std::list FeatureList; - std::string version; std::string interface_version; std::string description; @@ -59,9 +55,9 @@ private: Msp::FS::Path source_dir; const BuildType *build_type; Toolchain local_tools; - FeatureList features; + std::list features; BuildInfo build_info; - ComponentList components; + std::list components; SourceArchiveComponent *source_archive; Config config; mutable Cache cache; diff --git a/source/target.h b/source/target.h index e7150c2..c4a822b 100644 --- a/source/target.h +++ b/source/target.h @@ -27,7 +27,7 @@ dependencies can be used by other targets further down the chain. class Target { public: - typedef std::list Dependencies; + using Dependencies = std::list; protected: enum State diff --git a/source/tool.h b/source/tool.h index ee1fa7a..fa18ba8 100644 --- a/source/tool.h +++ b/source/tool.h @@ -5,6 +5,7 @@ #include #include #include "buildinfo.h" +#include "virtualfilesystem.h" class Architecture; class Builder; @@ -28,19 +29,16 @@ public: COMPONENT }; - typedef std::list SearchPath; - typedef std::list SuffixList; - protected: Builder &builder; const Architecture *architecture; std::string tag; std::string command; FileTarget *executable; - SuffixList input_suffixes; - SuffixList aux_suffixes; + std::list input_suffixes; + std::list aux_suffixes; ProcessingUnit processing_unit; - SearchPath system_path; + VirtualFileSystem::SearchPath system_path; BuildInfo build_info; bool prepared; std::list problems; @@ -68,11 +66,11 @@ public: FileTarget *get_executable() const { return executable; } /// Returns a list of suffixes that can be processed with this tool. - const SuffixList &get_input_suffixes() const { return input_suffixes; } + const std::list &get_input_suffixes() const { return input_suffixes; } /** Returns a list of suffixes that are associated with this tool, but can't be processed directly. For example C and C++ headers. */ - const SuffixList &get_auxiliary_suffixes() const { return aux_suffixes; } + const std::list &get_auxiliary_suffixes() const { return aux_suffixes; } /** Indicates whether the tool can accept a suffix. If aux is true, auxiliary suffixes are considered as well */ @@ -82,7 +80,7 @@ public: ProcessingUnit get_processing_unit() const { return processing_unit; } /// Returns the systemwide search path for source files. - const SearchPath &get_system_path() const { return system_path; } + const VirtualFileSystem::SearchPath &get_system_path() const { return system_path; } /** Returns tool-specific build info. This can be used by other tools down the chain. */ diff --git a/source/toolchain.h b/source/toolchain.h index 8449680..a70cdb7 100644 --- a/source/toolchain.h +++ b/source/toolchain.h @@ -13,11 +13,8 @@ A container for tools. Performs lookup based on tag or filename extension. class Toolchain { private: - typedef std::map ToolMap; - typedef std::list ToolchainList; - - ToolMap tools; - ToolchainList chains; + std::map tools; + std::list chains; public: ~Toolchain(); diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index 7855e04..783583f 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -44,10 +44,10 @@ FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const tool->prepare(); - list combined_path(path.begin(), path.end()); + SearchPath combined_path = path; if(use_syspath) { - const Tool::SearchPath &syspath = tool->get_system_path(); + const SearchPath &syspath = tool->get_system_path(); combined_path.insert(combined_path.end(), syspath.begin(), syspath.end()); } @@ -73,12 +73,12 @@ FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath &path, BuildInfo::LibraryMode mode, bool use_syspath) { - list combined_path(path.begin(), path.end()); + SearchPath combined_path = path; if(use_syspath) { Tool &linker = builder.get_toolchain().get_tool("LINK"); linker.prepare(); - const Tool::SearchPath &syspath = linker.get_system_path(); + const SearchPath &syspath = linker.get_system_path(); combined_path.insert(combined_path.end(), syspath.begin(), syspath.end()); } diff --git a/source/virtualfilesystem.h b/source/virtualfilesystem.h index a3327de..d74872c 100644 --- a/source/virtualfilesystem.h +++ b/source/virtualfilesystem.h @@ -10,6 +10,7 @@ class Builder; class FileTarget; class Pattern; +class Tool; /** Provides access to the filesystem in a way that takes known targets into @@ -19,13 +20,11 @@ possible to build them. class VirtualFileSystem { public: - typedef std::list SearchPath; + using SearchPath = std::list; private: - typedef std::map TargetMap; - Builder &builder; - TargetMap targets; + std::map targets; std::set nonexistent; public: