From f2b26f1929a8209a746bcf4944165b0ba9ef303f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 10 Jul 2012 23:54:55 +0300 Subject: [PATCH] Make Target::add_depend take a reference since null is not allowed --- source/binary.cpp | 4 ++-- source/builder.cpp | 8 ++++---- source/component.cpp | 12 ++++++------ source/csourcefile.cpp | 2 +- source/datafile.cpp | 2 +- source/installedfile.cpp | 2 +- source/objectfile.cpp | 4 ++-- source/sourcepackage.cpp | 2 +- source/staticlibrary.cpp | 2 +- source/tar.cpp | 2 +- source/target.cpp | 10 +++++----- source/target.h | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/source/binary.cpp b/source/binary.cpp index 2d0a409..7a3e7a5 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -20,7 +20,7 @@ Binary::Binary(Builder &b, const Component &c, const string &p, const list::const_iterator i=objs.begin(); i!=objs.end(); ++i) - add_depend(*i); + add_depend(**i); } void Binary::find_depends() @@ -68,6 +68,6 @@ void Binary::find_depends() for(list::iterator j=i; (last && j!=dep_libs.end()); ++j) last = (j==i || *j!=*i); if(last) - add_depend(*i); + add_depend(**i); } } diff --git a/source/builder.cpp b/source/builder.cpp index df6eda4..0b1cd2c 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -392,13 +392,13 @@ int Builder::create_targets() Target *world = new VirtualTarget(*this, "world"); Target *def_tgt = new VirtualTarget(*this, "default"); - world->add_depend(def_tgt); + world->add_depend(*def_tgt); Target *install = new VirtualTarget(*this, "install"); - world->add_depend(install); + world->add_depend(*install); Target *tarballs = new VirtualTarget(*this, "tarballs"); - world->add_depend(tarballs); + world->add_depend(*tarballs); const PackageManager::PackageMap &packages = package_manager.get_packages(); for(PackageManager::PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i) @@ -420,7 +420,7 @@ int Builder::create_targets() return -1; } - cmdline->add_depend(tgt); + cmdline->add_depend(*tgt); } cmdline->prepare(); diff --git a/source/component.cpp b/source/component.cpp index 0bfc2fc..708293e 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -123,7 +123,7 @@ void Component::create_targets() const /*Target *result = tar.create_target(files, tarname); Target *tarballs_tgt = builder.get_target("tarballs"); - tarballs_tgt->add_depend(result);*/ + tarballs_tgt->add_depend(*result);*/ return; } @@ -152,9 +152,9 @@ void Component::create_targets() const Target *result = dcomp.create_target(*source); if(&pkg==builder.get_main_package() && deflt) - def_tgt->add_depend(result); + def_tgt->add_depend(*result); else - world->add_depend(result); + world->add_depend(*result); if(install) inst_list.push_back(result); } @@ -197,9 +197,9 @@ void Component::create_targets() const for(list::const_iterator i=results.begin(); i!=results.end(); ++i) { if(&pkg==builder.get_main_package() && deflt) - def_tgt->add_depend(*i); + def_tgt->add_depend(**i); else - world->add_depend(*i); + world->add_depend(**i); if(install) inst_list.push_back(*i); } @@ -210,7 +210,7 @@ void Component::create_targets() const for(list::const_iterator i=inst_list.begin(); i!=inst_list.end(); ++i) { Target *inst = copy.create_target(**i, inst_loc); - inst_tgt->add_depend(inst); + inst_tgt->add_depend(*inst); } } diff --git a/source/csourcefile.cpp b/source/csourcefile.cpp index e2b029a..b0346e4 100644 --- a/source/csourcefile.cpp +++ b/source/csourcefile.cpp @@ -57,6 +57,6 @@ void CSourceFile::find_depends() { Target *hdr = builder.get_vfs().find_header(i->substr(1), ((*i)[0]=='"' ? local_incpath : incpath)); if(hdr) - add_depend(hdr); + add_depend(*hdr); } } diff --git a/source/datafile.cpp b/source/datafile.cpp index 2e9a7e5..188bbdb 100644 --- a/source/datafile.cpp +++ b/source/datafile.cpp @@ -8,7 +8,7 @@ DataFile::DataFile(Builder &b, const Component &c, File &s): component(c), source(s) { - add_depend(&source); + add_depend(source); install_location = Msp::FS::Path("share")/package->get_name(); } diff --git a/source/installedfile.cpp b/source/installedfile.cpp index 15bd08b..09cfed6 100644 --- a/source/installedfile.cpp +++ b/source/installedfile.cpp @@ -10,7 +10,7 @@ InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s, FileTarget(b, p, generate_target_path(b.get_prefix(), s, loc)), source(s) { - add_depend(&source); + add_depend(source); if(const SharedLibrary *shlib = dynamic_cast(&source)) if(!shlib->get_soname().empty()) diff --git a/source/objectfile.cpp b/source/objectfile.cpp index 70bef6c..7aafe90 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -14,7 +14,7 @@ ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): source(s) { component = &c; - add_depend(&source); + add_depend(source); } FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src) @@ -70,5 +70,5 @@ void ObjectFile::find_depends(FileTarget *tgt) for(Dependencies::const_iterator i=deps_to_add.begin(); i!=deps_to_add.end(); ++i) if(find(depends.begin(), depends.end(), *i)==depends.end()) - add_depend(*i); + add_depend(**i); } diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 63f3bba..2371d2c 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -238,7 +238,7 @@ void SourcePackage::create_targets() if(pc_needed) { PkgConfigFile *pc = new PkgConfigFile(builder, *this); - builder.get_target("install")->add_depend(builder.get_toolchain().get_tool("CP").create_target(*pc)); + builder.get_target("install")->add_depend(*builder.get_toolchain().get_tool("CP").create_target(*pc)); } } diff --git a/source/staticlibrary.cpp b/source/staticlibrary.cpp index f63eb16..8e3950f 100644 --- a/source/staticlibrary.cpp +++ b/source/staticlibrary.cpp @@ -16,7 +16,7 @@ StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list::const_iterator i=objs.begin(); i!=objs.end(); ++i) - add_depend(*i); + add_depend(**i); install_location = "lib"; } diff --git a/source/tar.cpp b/source/tar.cpp index 3bcf3cb..a85ee3d 100644 --- a/source/tar.cpp +++ b/source/tar.cpp @@ -22,7 +22,7 @@ Target *Tar::create_target(const list &sources, const string &arg) con TarBall *tarball = new TarBall(builder, *sources.front()->get_package(), arg); for(list::const_iterator i=sources.begin(); i!=sources.end(); ++i) - tarball->add_depend(*i); + tarball->add_depend(**i); return tarball; } diff --git a/source/target.cpp b/source/target.cpp index 2d4a2de..577438b 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -55,13 +55,13 @@ void Target::force_rebuild() mark_rebuild("Forced rebuild"); } -void Target::add_depend(Target *dep) +void Target::add_depend(Target &dep) { - if(dep==this) + if(&dep==this) throw invalid_argument("Target::add_depend"); - depends.push_back(dep); + depends.push_back(&dep); if(state>PREPARING) - dep->signal_bubble_rebuild.connect(sigc::mem_fun(this, &Target::check_rebuild)); + dep.signal_bubble_rebuild.connect(sigc::mem_fun(this, &Target::check_rebuild)); } void Target::prepare() @@ -79,7 +79,7 @@ void Target::prepare() if(tool) { if(FileTarget *tool_exe = tool->get_executable()) - add_depend(tool_exe); + add_depend(*tool_exe); } for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i) diff --git a/source/target.h b/source/target.h index f4a4efc..f9d8b24 100644 --- a/source/target.h +++ b/source/target.h @@ -91,7 +91,7 @@ public: /** Adds a dependency for the target. Order is preseved and is important for some target types. It is an error to create dependency cycles, although this won't be detected until the targets are prepared. */ - void add_depend(Target *); + void add_depend(Target &); /// Returns the dependencies of the target, in the order they were added. const Dependencies &get_depends() const { return depends; } -- 2.45.2