cmPropertyMap: Remove chaining logic.

The chaining logic doesn't belong to the container, and the
CMakeInstance pointer doesn't need to be in cmPropertyMap.

Size goes from 56 to 48 bytes with GNU libstdc++-5.1.
This commit is contained in:
Stephen Kelly 2015-06-06 09:41:30 +02:00
parent 3ac4b90bfd
commit 5181fae264
12 changed files with 42 additions and 73 deletions

View File

@ -526,11 +526,9 @@ void * CCONV cmCreateSourceFile(void)
return (void*)new cmCPluginAPISourceFile; return (void*)new cmCPluginAPISourceFile;
} }
void * CCONV cmCreateNewSourceFile(void *arg) void * CCONV cmCreateNewSourceFile(void *)
{ {
cmMakefile *mf = static_cast<cmMakefile *>(arg);
cmCPluginAPISourceFile *sf = new cmCPluginAPISourceFile; cmCPluginAPISourceFile *sf = new cmCPluginAPISourceFile;
sf->Properties.SetCMakeInstance(mf->GetCMakeInstance());
return (void*)sf; return (void*)sf;
} }
@ -630,11 +628,7 @@ const char * CCONV cmSourceFileGetProperty(void *arg,const char *prop)
{ {
return sf->FullPath.c_str(); return sf->FullPath.c_str();
} }
bool chain = false; return sf->Properties.GetPropertyValue(prop);
// Ignore chain because old code will not expect it and it is a
// pain to implement here anyway.
return sf->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE,
chain);
} }
} }

View File

@ -161,7 +161,6 @@ bool cmCacheManager::LoadCache(const std::string& path,
// Format is key:type=value // Format is key:type=value
std::string helpString; std::string helpString;
CacheEntry e; CacheEntry e;
e.Properties.SetCMakeInstance(this->CMakeInstance);
cmSystemTools::GetLineFromStream(fin, buffer); cmSystemTools::GetLineFromStream(fin, buffer);
realbuffer = buffer.c_str(); realbuffer = buffer.c_str();
while(*realbuffer != '0' && while(*realbuffer != '0' &&
@ -323,7 +322,6 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
{ {
// Create an entry and store the property. // Create an entry and store the property.
CacheEntry& ne = this->Cache[key]; CacheEntry& ne = this->Cache[key];
ne.Properties.SetCMakeInstance(this->CMakeInstance);
ne.Type = cmState::UNINITIALIZED; ne.Type = cmState::UNINITIALIZED;
ne.SetProperty(*p, e.Value.c_str()); ne.SetProperty(*p, e.Value.c_str());
} }
@ -645,7 +643,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key,
cmState::CacheEntryType type) cmState::CacheEntryType type)
{ {
CacheEntry& e = this->Cache[key]; CacheEntry& e = this->Cache[key];
e.Properties.SetCMakeInstance(this->CMakeInstance);
if ( value ) if ( value )
{ {
e.Value = value; e.Value = value;
@ -744,9 +741,7 @@ cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
{ {
return this->Value.c_str(); return this->Value.c_str();
} }
bool c = false; return this->Properties.GetPropertyValue(prop);
return
this->Properties.GetPropertyValue(prop, cmProperty::CACHE, c);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -2438,7 +2438,6 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
{ {
// Package // Package
cmTarget target; cmTarget target;
target.GetProperties().SetCMakeInstance(this->CMakeInstance);
target.SetType(cmTarget::GLOBAL_TARGET, name); target.SetType(cmTarget::GLOBAL_TARGET, name);
target.SetProperty("EXCLUDE_FROM_ALL","TRUE"); target.SetProperty("EXCLUDE_FROM_ALL","TRUE");

View File

@ -213,8 +213,6 @@ cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$"); this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
#endif #endif
this->Properties.SetCMakeInstance(this->GetCMakeInstance());
{ {
const char* dir = this->GetCMakeInstance()->GetHomeDirectory(); const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
this->AddDefinition("CMAKE_SOURCE_DIR", dir); this->AddDefinition("CMAKE_SOURCE_DIR", dir);
@ -4134,11 +4132,13 @@ void cmMakefile::AppendProperty(const std::string& prop,
const char *cmMakefile::GetProperty(const std::string& prop) const const char *cmMakefile::GetProperty(const std::string& prop) const
{ {
return this->GetProperty(prop, cmProperty::DIRECTORY); const bool chain = this->GetState()->
IsPropertyChained(prop, cmProperty::DIRECTORY);
return this->GetProperty(prop, chain);
} }
const char *cmMakefile::GetProperty(const std::string& prop, const char *cmMakefile::GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const bool chain) const
{ {
// watch for specific properties // watch for specific properties
static std::string output; static std::string output;
@ -4242,15 +4242,13 @@ const char *cmMakefile::GetProperty(const std::string& prop,
return output.c_str(); return output.c_str();
} }
bool chain = false; const char *retVal = this->Properties.GetPropertyValue(prop);
const char *retVal = if (!retVal && chain)
this->Properties.GetPropertyValue(prop, scope, chain);
if (chain)
{ {
if(this->LocalGenerator->GetParent()) if(this->LocalGenerator->GetParent())
{ {
return this->LocalGenerator->GetParent()->GetMakefile()-> return this->LocalGenerator->GetParent()->GetMakefile()->
GetProperty(prop, scope); GetProperty(prop, chain);
} }
return this->GetState()->GetGlobalProperty(prop); return this->GetState()->GetGlobalProperty(prop);
} }

View File

@ -717,8 +717,7 @@ public:
void AppendProperty(const std::string& prop, const char *value, void AppendProperty(const std::string& prop, const char *value,
bool asString=false); bool asString=false);
const char *GetProperty(const std::string& prop) const; const char *GetProperty(const std::string& prop) const;
const char *GetProperty(const std::string& prop, const char *GetProperty(const std::string& prop, bool chain) const;
cmProperty::ScopeType scope) const;
bool GetPropertyAsBool(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const;
const char* GetFeature(const std::string& feature, const char* GetFeature(const std::string& feature,

View File

@ -57,22 +57,13 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
} }
const char *cmPropertyMap const char *cmPropertyMap
::GetPropertyValue(const std::string& name, ::GetPropertyValue(const std::string& name) const
cmProperty::ScopeType scope,
bool &chain) const
{ {
chain = false;
assert(!name.empty()); assert(!name.empty());
cmPropertyMap::const_iterator it = this->find(name); cmPropertyMap::const_iterator it = this->find(name);
if (it == this->end()) if (it == this->end())
{ {
// should we chain up?
if (this->CMakeInstance)
{
chain = this->CMakeInstance->GetState()->
IsPropertyChained(name,scope);
}
return 0; return 0;
} }
return it->second.GetValue(); return it->second.GetValue();

View File

@ -14,8 +14,6 @@
#include "cmProperty.h" #include "cmProperty.h"
class cmake;
class cmPropertyMap : public std::map<std::string,cmProperty> class cmPropertyMap : public std::map<std::string,cmProperty>
{ {
public: public:
@ -26,16 +24,7 @@ public:
void AppendProperty(const std::string& name, const char* value, void AppendProperty(const std::string& name, const char* value,
bool asString=false); bool asString=false);
const char *GetPropertyValue(const std::string& name, const char *GetPropertyValue(const std::string& name) const;
cmProperty::ScopeType scope,
bool &chain) const;
void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; }
cmPropertyMap() { this->CMakeInstance = 0;}
private:
cmake *CMakeInstance;
}; };
#endif #endif

View File

@ -85,8 +85,10 @@ bool cmSetTestsPropertiesCommand
unsigned int k; unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2) for (k = 0; k < propertyPairs.size(); k = k + 2)
{ {
test->SetProperty(propertyPairs[k], if (!propertyPairs[k].empty())
propertyPairs[k+1].c_str()); {
test->SetProperty(propertyPairs[k], propertyPairs[k+1].c_str());
}
} }
} }
else else

View File

@ -22,7 +22,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name):
Location(mf, name) Location(mf, name)
{ {
this->CustomCommand = 0; this->CustomCommand = 0;
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
this->FindFullPathFailed = false; this->FindFullPathFailed = false;
this->IsUiFile = (".ui" == this->IsUiFile = (".ui" ==
cmSystemTools::GetFilenameLastExtension(this->Location.GetName())); cmSystemTools::GetFilenameLastExtension(this->Location.GetName()));
@ -361,13 +360,16 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
} }
} }
bool chain = false; const char *retVal = this->Properties.GetPropertyValue(prop);
const char *retVal = if (!retVal)
this->Properties.GetPropertyValue(prop, cmProperty::SOURCE_FILE, chain);
if (chain)
{ {
cmMakefile const* mf = this->Location.GetMakefile(); cmMakefile const* mf = this->Location.GetMakefile();
return mf->GetProperty(prop,cmProperty::SOURCE_FILE); const bool chain = mf->GetState()->
IsPropertyChained(prop, cmProperty::SOURCE_FILE);
if (chain)
{
return mf->GetProperty(prop, chain);
}
} }
return retVal; return retVal;

View File

@ -482,9 +482,7 @@ const char *cmState::GetGlobalProperty(const std::string& prop)
return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
} }
#undef STRING_LIST_ELEMENT #undef STRING_LIST_ELEMENT
bool dummy = false; return this->GlobalProperties.GetPropertyValue(prop);
return this->GlobalProperties.GetPropertyValue(prop, cmProperty::GLOBAL,
dummy);
} }
bool cmState::GetGlobalPropertyAsBool(const std::string& prop) bool cmState::GetGlobalPropertyAsBool(const std::string& prop)

View File

@ -286,9 +286,6 @@ void cmTarget::SetMakefile(cmMakefile* mf)
// Set our makefile. // Set our makefile.
this->Makefile = mf; this->Makefile = mf;
// set the cmake instance of the properties
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
// Check whether this is a DLL platform. // Check whether this is a DLL platform.
this->DLLPlatform = (this->Makefile->IsOn("WIN32") || this->DLLPlatform = (this->Makefile->IsOn("WIN32") ||
this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("CYGWIN") ||
@ -3167,12 +3164,15 @@ const char *cmTarget::GetProperty(const std::string& prop,
} }
} }
bool chain = false; const char *retVal = this->Properties.GetPropertyValue(prop);
const char *retVal = if (!retVal)
this->Properties.GetPropertyValue(prop, cmProperty::TARGET, chain);
if (chain)
{ {
return this->Makefile->GetProperty(prop, cmProperty::TARGET); const bool chain = this->GetMakefile()->GetState()->
IsPropertyChained(prop, cmProperty::TARGET);
if (chain)
{
return this->Makefile->GetProperty(prop, chain);
}
} }
return retVal; return retVal;
} }

View File

@ -21,7 +21,6 @@ cmTest::cmTest(cmMakefile* mf)
{ {
this->Makefile = mf; this->Makefile = mf;
this->OldStyle = true; this->OldStyle = true;
this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -50,12 +49,15 @@ void cmTest::SetCommand(std::vector<std::string> const& command)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char *cmTest::GetProperty(const std::string& prop) const const char *cmTest::GetProperty(const std::string& prop) const
{ {
bool chain = false; const char *retVal = this->Properties.GetPropertyValue(prop);
const char *retVal = if (!retVal)
this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
if (chain)
{ {
return this->Makefile->GetProperty(prop,cmProperty::TEST); const bool chain = this->Makefile->GetState()->
IsPropertyChained(prop, cmProperty::TEST);
if (chain)
{
return this->Makefile->GetProperty(prop, chain);
}
} }
return retVal; return retVal;
} }