From f76c063eb9b792088e034ffb4c2f173b843e8c57 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 23 Jul 2012 23:18:29 +0300 Subject: [PATCH] Eliminate all global typedefs, making misc.h finally unnecessary --- source/architecture.h | 2 -- source/builder.cpp | 11 +++++------ source/builder.h | 7 ++++--- source/buildinfo.h | 2 +- source/cache.h | 1 - source/component.cpp | 30 +++++++++++++++--------------- source/component.h | 13 +++++++------ source/condition.cpp | 8 ++++---- source/condition.h | 12 +++++++----- source/config.h | 1 - source/csourcefile.cpp | 2 +- source/csourcefile.h | 8 +++++--- source/feature.h | 2 -- source/misc.h | 13 ------------- source/package.cpp | 3 +-- source/package.h | 8 ++++---- source/pkgconfiggenerator.cpp | 4 ++-- source/problem.h | 4 ---- source/sourcepackage.cpp | 16 ++++++++-------- source/sourcepackage.h | 2 ++ source/virtualfilesystem.cpp | 1 - 21 files changed, 66 insertions(+), 84 deletions(-) delete mode 100644 source/misc.h diff --git a/source/architecture.h b/source/architecture.h index 2d7ca5f..4db809f 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -57,6 +57,4 @@ private: void parse_specification(const std::string &); }; -typedef std::map ArchMap; - #endif diff --git a/source/builder.cpp b/source/builder.cpp index 92f639c..f894de0 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -56,7 +56,6 @@ Builder::Builder(int argc, char **argv): string work_dir; bool full_paths = false; unsigned max_depth = 4; - StringList cmdline_warn; string prfx; string temp_str; string arch; @@ -145,7 +144,7 @@ Builder::Builder(int argc, char **argv): { string::size_type equal = i->find('='); if(equal!=string::npos) - cmdline_options.insert(StringMap::value_type(i->substr(0, equal), i->substr(equal+1))); + cmdline_options.insert(Config::InputOptions::value_type(i->substr(0, equal), i->substr(equal+1))); else cmdline_targets.push_back(*i); } @@ -384,7 +383,7 @@ bool Builder::prepare_build() // Make the cmdline target depend on all targets mentioned on the command line Target *cmdline = new VirtualTarget(*this, "cmdline"); - for(list::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i) + for(NameList::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i) { Target *tgt = get_target(*i); if(!tgt) @@ -403,7 +402,7 @@ bool Builder::prepare_build() cmdline->prepare(); // Apply what-ifs - for(StringList::iterator i=what_if.begin(); i!=what_if.end(); ++i) + for(NameList::iterator i=what_if.begin(); i!=what_if.end(); ++i) { FileTarget *tgt = vfs.get_target(cwd/ *i); if(!tgt) @@ -571,8 +570,8 @@ void Builder::package_help() const Config::OptionMap &options = config.get_options(); IO::print("Required packages:\n "); - const PackageList &requires = main_pkg->get_required_packages(); - for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) + const Package::Requirements &requires = main_pkg->get_required_packages(); + for(Package::Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i) { if(i!=requires.begin()) IO::print(", "); diff --git a/source/builder.h b/source/builder.h index b10d460..2f70fbd 100644 --- a/source/builder.h +++ b/source/builder.h @@ -11,7 +11,6 @@ #include "buildtype.h" #include "config.h" #include "logger.h" -#include "misc.h" #include "packagemanager.h" #include "problem.h" #include "target.h" @@ -46,9 +45,11 @@ public: typedef std::map TargetMap; private: + typedef std::list NameList; typedef std::map BuildTypeMap; + typedef std::list ProblemList; - StringList cmdline_targets; + NameList cmdline_targets; Config::InputOptions cmdline_options; Msp::FS::Path cwd; @@ -74,7 +75,7 @@ private: bool show_progress; std::string build_file; unsigned jobs; - StringList what_if; + NameList what_if; bool conf_all; bool conf_only; bool build_all; diff --git a/source/buildinfo.h b/source/buildinfo.h index e0929e7..595fe1a 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -4,7 +4,7 @@ #include #include #include -#include "misc.h" +#include /** Stores information about compiler command line parameters in a more abstract diff --git a/source/cache.h b/source/cache.h index 86a5f47..9873957 100644 --- a/source/cache.h +++ b/source/cache.h @@ -2,7 +2,6 @@ #define CACHE_H_ #include -#include "misc.h" class SourcePackage; class Target; diff --git a/source/component.cpp b/source/component.cpp index a63e3b0..4a889cb 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -32,7 +32,7 @@ Component::Component(SourcePackage &p, Type t, const string &n): void Component::prepare() { - for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) + for(Package::Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i) (*i)->prepare(); } @@ -40,20 +40,20 @@ void Component::create_build_info() { BuildInfo final_build_info; - const PackageList &pkg_reqs = package.get_required_packages(); - PackageList direct_reqs = requires; + const Package::Requirements &pkg_reqs = package.get_required_packages(); + Package::Requirements direct_reqs = requires; direct_reqs.insert(direct_reqs.end(), pkg_reqs.begin(), pkg_reqs.end()); - PackageList all_reqs = direct_reqs; - for(PackageList::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i) + Package::Requirements all_reqs = direct_reqs; + for(Package::Requirements::iterator i=all_reqs.begin(); i!=all_reqs.end(); ++i) { BuildInfo::UpdateLevel level = BuildInfo::CHAINED; if(find(direct_reqs.begin(), direct_reqs.end(), *i)!=direct_reqs.end()) level = BuildInfo::DEPENDENCY; final_build_info.update_from((*i)->get_exported_build_info(), level); - const PackageList &reqs = (*i)->get_required_packages(); - for(PackageList::const_iterator j=reqs.begin(); j!=reqs.end(); ++j) + const Package::Requirements &reqs = (*i)->get_required_packages(); + for(Package::Requirements::const_iterator j=reqs.begin(); j!=reqs.end(); ++j) if(find(all_reqs.begin(), all_reqs.end(), *j)==all_reqs.end()) all_reqs.push_back(*j); } @@ -74,7 +74,7 @@ void Component::create_build_info() if(build_info.libmodeget_exported_build_info(); build_info.libpath.insert(build_info.libpath.end(), ebi.libpath.begin(), ebi.libpath.end()); @@ -87,7 +87,7 @@ void Component::create_targets() const Builder &builder = package.get_builder(); const Toolchain &toolchain = builder.get_toolchain(); - PathList source_filenames = collect_source_files(); + SourceList source_filenames = collect_source_files(); list inst_list; string inst_loc; @@ -96,7 +96,7 @@ void Component::create_targets() const const Tool &tar = toolchain.get_tool("TAR"); list files; - for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) + for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { FileTarget *file = builder.get_vfs().get_target(*i); if(!file) @@ -126,7 +126,7 @@ void Component::create_targets() const else if(type==INSTALL) { inst_loc = name; - for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) + for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { FileTarget *ft; if(Target *tgt = builder.get_vfs().get_target(*i)) @@ -155,7 +155,7 @@ void Component::create_targets() const if(type==PROGRAM || type==LIBRARY || type==MODULE) { list objs; - for(PathList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) + for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { string ext = FS::extpart(FS::basename(*i)); const Tool *tool = toolchain.get_tool_for_suffix(ext, true); @@ -207,10 +207,10 @@ void Component::create_targets() const } } -PathList Component::collect_source_files() const +Component::SourceList Component::collect_source_files() const { - PathList files; - for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i) + SourceList files; + for(SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i) { FS::Path path(*i); if(FS::is_dir(path)) diff --git a/source/component.h b/source/component.h index 32cbe0a..e68bc38 100644 --- a/source/component.h +++ b/source/component.h @@ -6,7 +6,6 @@ #include #include "buildinfo.h" #include "installmap.h" -#include "misc.h" #include "package.h" class SourcePackage; @@ -41,14 +40,16 @@ public: TARBALL }; + typedef std::list SourceList; + protected: SourcePackage &package; Type type; std::string name; - StringList sources; + SourceList sources; bool install; BuildInfo build_info; - PackageList requires; + Package::Requirements requires; bool deflt; InstallMap install_map; @@ -61,16 +62,16 @@ public: /** Returns a list of sources for the component. They may refer to directories or individual files. */ - const StringList &get_sources() const { return sources; } + const SourceList &get_sources() const { return sources; } protected: /** Returns a list of all source files for the component. */ - PathList collect_source_files() const; + SourceList collect_source_files() const; public: bool get_install() const { return install; } const InstallMap &get_install_map() const { return install_map; } - const PackageList &get_required_packages() const { return requires; } + const Package::Requirements &get_required_packages() const { return requires; } bool is_default() const { return deflt; } /** Prepares any required packages. */ diff --git a/source/condition.cpp b/source/condition.cpp index 13861ba..413870e 100644 --- a/source/condition.cpp +++ b/source/condition.cpp @@ -18,11 +18,11 @@ Condition::Condition(SourcePackage &p, const string &expr): string::size_type token = i->find_first_of("=!"); if(token==string::npos) - expression.insert(StringMap::value_type(*i, "=")); + expression.insert(Expression::value_type(*i, "=")); else if(token==0 && (*i)[0]=='!') - expression.insert(StringMap::value_type(i->substr(1), "!")); + expression.insert(Expression::value_type(i->substr(1), "!")); else - expression.insert(StringMap::value_type(i->substr(0, token), i->substr(token))); + expression.insert(Expression::value_type(i->substr(0, token), i->substr(token))); } } @@ -31,7 +31,7 @@ bool Condition::eval() const Config &conf = pkg.get_config(); bool result = true; - for(StringMap::iterator i=expression.begin(); i!=expression.end(); ++i) + for(Expression::iterator i=expression.begin(); i!=expression.end(); ++i) { bool neg = (i->second[0]=='!'); unsigned start = 1; diff --git a/source/condition.h b/source/condition.h index c1bf7a3..0cdc2bb 100644 --- a/source/condition.h +++ b/source/condition.h @@ -3,7 +3,6 @@ #include #include "buildinfo.h" -#include "misc.h" class Config; class SourcePackage; @@ -20,18 +19,21 @@ public: void build_info(); }; + typedef std::list RequireList; + private: + typedef std::map Expression; + SourcePackage &pkg; - StringMap expression; - StringList requires; + Expression expression; + RequireList requires; BuildInfo build_info; public: Condition(SourcePackage &, const std::string &); - const StringList &get_requires() const { return requires; } + const RequireList &get_requires() const { return requires; } const BuildInfo &get_build_info() const { return build_info; } bool eval(); }; -typedef std::list ConditionList; #endif diff --git a/source/config.h b/source/config.h index 92f5585..9499775 100644 --- a/source/config.h +++ b/source/config.h @@ -6,7 +6,6 @@ #include #include #include -#include "misc.h" class SourcePackage; diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index 5531287..ee301d7 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -52,7 +52,7 @@ void CSourceFile::find_dependencies() BuildInfo::PathList local_incpath = incpath; local_incpath.push_front(FS::dirname(path).str()); - for(list::iterator i=includes.begin(); i!=includes.end(); ++i) + for(IncludeList::iterator i=includes.begin(); i!=includes.end(); ++i) { Target *hdr = builder.get_vfs().find_header(i->substr(1), ((*i)[0]=='"' ? local_incpath : incpath)); if(hdr) diff --git a/source/csourcefile.h b/source/csourcefile.h index b83c0db..8c61a51 100644 --- a/source/csourcefile.h +++ b/source/csourcefile.h @@ -1,7 +1,6 @@ #ifndef CSOURCEFILE_H_ #define CSOURCEFILE_H_ -#include "misc.h" #include "sourcefile.h" /** @@ -9,15 +8,18 @@ Represents a C or C++ source file. */ class CSourceFile: public SourceFile { +public: + typedef std::list IncludeList; + private: - StringList includes; + IncludeList includes; public: CSourceFile(Builder &, const Msp::FS::Path &); CSourceFile(Builder &, const Component &, const Msp::FS::Path &); virtual const char *get_type() const { return "CSourceFile"; } - const StringList &get_includes() const { return includes; } + const IncludeList &get_includes() const { return includes; } private: virtual void find_dependencies(); }; diff --git a/source/feature.h b/source/feature.h index 657c860..8d496b3 100644 --- a/source/feature.h +++ b/source/feature.h @@ -18,6 +18,4 @@ struct Feature Feature(const std::string &n): name(n) { } }; -typedef std::list FeatureList; - #endif diff --git a/source/misc.h b/source/misc.h deleted file mode 100644 index 45c6636..0000000 --- a/source/misc.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef MISC_H_ -#define MISC_H_ - -#include -#include -#include -#include - -typedef std::list StringList; -typedef std::list PathList; -typedef std::map StringMap; - -#endif diff --git a/source/package.cpp b/source/package.cpp index 44444ad..6cbc932 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -2,7 +2,6 @@ #include #include #include "builder.h" -#include "misc.h" #include "package.h" using namespace std; @@ -22,7 +21,7 @@ void Package::prepare() if(prepared) return; - for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i) + for(Requirements::const_iterator i=requires.begin(); i!=requires.end(); ++i) (*i)->prepare(); do_prepare(); diff --git a/source/package.h b/source/package.h index 8811390..3a7ba3a 100644 --- a/source/package.h +++ b/source/package.h @@ -10,8 +10,6 @@ class Builder; class Package; -typedef std::list PackageList; - /** A package is a distributable piece of software. Package information may be obtained in several ways: Build files of source packages, pkg-config for binary @@ -29,12 +27,14 @@ public: void require(const std::string &); }; + typedef std::list Requirements; + protected: Builder &builder; std::string name; - PackageList requires; + Requirements requires; BuildInfo export_binfo; bool prepared; @@ -46,7 +46,7 @@ public: const std::string &get_name() const { return name; } Builder &get_builder() const { return builder; } - const PackageList &get_required_packages() const { return requires; } + const Requirements &get_required_packages() const { return requires; } const BuildInfo &get_exported_build_info() const { return export_binfo; } diff --git a/source/pkgconfiggenerator.cpp b/source/pkgconfiggenerator.cpp index bd807d4..b4ba545 100644 --- a/source/pkgconfiggenerator.cpp +++ b/source/pkgconfiggenerator.cpp @@ -44,8 +44,8 @@ void PkgConfigGenerator::Worker::main() IO::print(out, "Version: %s\n", spkg.get_version()); IO::print(out, "Requires:"); - const PackageList &reqs = spkg.get_required_packages(); - for(PackageList::const_iterator i=reqs.begin(); i!=reqs.end(); ++i) + const Package::Requirements &reqs = spkg.get_required_packages(); + for(Package::Requirements::const_iterator i=reqs.begin(); i!=reqs.end(); ++i) if((*i)->get_use_pkgconfig()) IO::print(out, " %s", (*i)->get_name()); out.put('\n'); diff --git a/source/problem.h b/source/problem.h index 83de7df..d3d10d4 100644 --- a/source/problem.h +++ b/source/problem.h @@ -4,8 +4,6 @@ #include #include -class Package; - struct Problem { std::string package; @@ -14,6 +12,4 @@ struct Problem Problem(const std::string &p, const std::string &d): package(p), descr(d) { } }; -typedef std::list ProblemList; - #endif diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 77440d6..1c5ca24 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -6,7 +6,6 @@ #include "binarypackage.h" #include "builder.h" #include "file.h" -#include "misc.h" #include "pkgconfigfile.h" #include "tool.h" #include "sourcepackage.h" @@ -168,10 +167,11 @@ void SourcePackage::Loader::finish() { for(ComponentList::iterator j=obj.components.begin(); j!=obj.components.end(); ++j) { - const StringList &sources = j->get_sources(); - for(StringList::const_iterator k=sources.begin(); k!=sources.end(); ++k) + const Component::SourceList &sources = j->get_sources(); + for(Component::SourceList::const_iterator k=sources.begin(); k!=sources.end(); ++k) { - if(!i->first.compare(0, k->size(), *k)) + string k_str = k->str(); + if(!i->first.compare(0, k_str.size(), k_str)) { const_cast(j->get_install_map()).add_mapping(obj.source_dir/i->first, i->second); } @@ -223,9 +223,9 @@ void SourcePackage::Loader::headers(const string &n) IO::print("%s: Note: headers components are deprecated\n", get_source()); Component comp(obj, Component::LIBRARY, n); load_sub(comp); - const StringList &sources = comp.get_sources(); - for(StringList::const_iterator i=sources.begin(); i!=sources.end(); ++i) - install_map[*i] = "include/"+comp.get_name(); + const Component::SourceList &sources = comp.get_sources(); + for(Component::SourceList::const_iterator i=sources.begin(); i!=sources.end(); ++i) + install_map[i->str()] = "include/"+comp.get_name(); } void SourcePackage::Loader::if_feature(const string &cond) @@ -278,5 +278,5 @@ void SourcePackage::Loader::tar_file(const string &f) IO::print("%s: Note: tar_file is deprecated\n", get_source()); for(ComponentList::iterator i=obj.components.begin(); i!=obj.components.end(); ++i) if(i->get_type()==Component::TARBALL && i->get_name()=="@src") - const_cast(i->get_sources()).push_back((obj.source_dir/f).str()); + const_cast(i->get_sources()).push_back((obj.source_dir/f).str()); } diff --git a/source/sourcepackage.h b/source/sourcepackage.h index f274019..0aab392 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -55,6 +55,8 @@ public: typedef std::list ComponentList; private: + typedef std::list FeatureList; + std::string version; std::string description; diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index ec23ef5..19bc8db 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -6,7 +6,6 @@ #include "builder.h" #include "csourcefile.h" #include "executable.h" -#include "misc.h" #include "sharedlibrary.h" #include "staticlibrary.h" #include "tool.h" -- 2.45.2