]> git.tdb.fi Git - builder.git/commitdiff
Fix cascading of BuildInfo
authorMikko Rasa <tdb@tdb.fi>
Wed, 18 Jul 2012 15:32:47 +0000 (18:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 18 Jul 2012 15:32:47 +0000 (18:32 +0300)
source/buildinfo.cpp
source/buildinfo.h

index b7f9c5cc0c9f8cdc54d21d574892adf37c419aad..c02d115fd1b252e409191834a9ca45730efeaaf1 100644 (file)
@@ -100,7 +100,7 @@ void BuildInfo::Loader::library(const string &s)
 }
 
 
-void operator>>(LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
+void operator>>(const LexicalConverter &conv, BuildInfo::LibraryMode &libmode)
 {
        if(conv.get()=="FORCE_STATIC")
                libmode = BuildInfo::FORCE_STATIC;
index ca8819d59e55ec234fbfeb5a67aa2c5bfdf58ee6..e0929e7b1da9c8c9eec8bef0fd60e298697d8f55 100644 (file)
@@ -39,6 +39,32 @@ public:
                CHAINED      //< Include only compilation options
        };
 
+       /**
+       A wrapper which tracks the set status of the wrapped variable.  A default
+       value may be provided in initialization without causing it to be treated as
+       set.  Assigning from a raw value flags the Tracked object as set.  Assigning
+       from another Tracked object will only change the value of the target if the
+       source is set.  
+       */
+       template<typename T>
+       class Tracked
+       {
+       public:
+               typedef T LoadType;
+
+       private:
+               T value;
+               bool set;
+
+       public:
+               Tracked(): value(T()), set(false) { }
+               Tracked(T v): value(v), set(false) { }
+               Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; }
+
+               Tracked &operator=(T v) { value = v; set = true; return *this; }
+               operator T() const { return value; }
+       };
+
        typedef std::map<std::string, std::string> DefineMap;
        typedef std::list<Msp::FS::Path> PathList;
        typedef std::list<std::string> WordList;
@@ -47,13 +73,13 @@ public:
        PathList incpath;
        PathList libpath;
        WordList libs;
-       LibraryMode libmode;
-       bool threads;
-       bool debug;
-       int optimize;
-       bool strip;
-       unsigned warning_level;
-       bool fatal_warnings;
+       Tracked<LibraryMode> libmode;
+       Tracked<bool> threads;
+       Tracked<bool> debug;
+       Tracked<int> optimize;
+       Tracked<bool> strip;
+       Tracked<unsigned> warning_level;
+       Tracked<bool> fatal_warnings;
 
        BuildInfo();