From 24bce99cbff13cb337c543dce55f056351caa2fc Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 19 Apr 2001 13:28:46 -0400 Subject: cleaned up the coding style made ivars private etc --- Source/cmCablePackageCommand.cxx | 2 +- Source/cmCustomCommand.h | 35 +++++++++++++++++++++++++++++++++++ Source/cmDSPMakefile.cxx | 10 +++++----- Source/cmDSPWriter.cxx | 10 +++++----- Source/cmDSWMakefile.cxx | 2 +- Source/cmDSWWriter.cxx | 2 +- Source/cmMakefile.cxx | 10 +++++----- Source/cmSourceGroup.cxx | 20 ++++++++++---------- Source/cmTarget.h | 22 +++++++++++++++++++++- Source/cmUnixMakefileGenerator.cxx | 14 +++++++------- 10 files changed, 91 insertions(+), 36 deletions(-) diff --git a/Source/cmCablePackageCommand.cxx b/Source/cmCablePackageCommand.cxx index 3b19f15..19fac7d 100644 --- a/Source/cmCablePackageCommand.cxx +++ b/Source/cmCablePackageCommand.cxx @@ -117,7 +117,7 @@ bool cmCablePackageCommand::Invoke(std::vector& args) outputs, m_TargetName.c_str()); // add the source list to the target - m_Makefile->GetTargets()[m_TargetName.c_str()].m_SourceLists.push_back(m_PackageName); + m_Makefile->GetTargets()[m_TargetName.c_str()].GetSourceLists().push_back(m_PackageName); return true; } diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 1e0374e..e7353e6 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -19,6 +19,11 @@ #include "cmStandardIncludes.h" class cmMakefile; +/** \class cmCustomCommand + * \brief A class to encapsulate a custom command + * + * cmCustomCommand encapsulates the properties of a custom command + */ class cmCustomCommand { public: @@ -26,8 +31,38 @@ public: std::vector dep, std::vector out); cmCustomCommand(const cmCustomCommand& r); + + /** + * Use the cmMakefile's Expand commands to expand any variables in + * this objects members. + */ void ExpandVariables(const cmMakefile &); + + /** + * Return the name of the source file. I'm not sure if this is a full path or not. + */ + std::string GetSourceName() const {return m_Source;} + void SetSourceName(const char *name) {m_Source = name;} + + /** + * Return the command to execute + */ + std::string GetCommand() const {return m_Command;} + void SetCommand(const char *cmd) {m_Command = cmd;} + + /** + * Return the vector that holds the list of dependencies + */ + const std::vector &GetDepends() const {return m_Depends;} + std::vector &GetDepends() {return m_Depends;} + + /** + * Return the vector that holds the list of outputs of this command + */ + const std::vector &GetOutputs() const {return m_Outputs;} + std::vector &GetOutputs() {return m_Outputs;} +private: std::string m_Source; std::string m_Command; std::vector m_Depends; diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx index 0469228..8c9a62b 100644 --- a/Source/cmDSPMakefile.cxx +++ b/Source/cmDSPMakefile.cxx @@ -91,7 +91,7 @@ void cmDSPMakefile::OutputDSPFile() for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.m_IsALibrary) + if (l->second.IsALibrary()) { this->SetBuildType(m_LibraryBuildType, l->first.c_str()); } @@ -196,7 +196,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, // get the classes from the source lists then add them to the groups std::vector classes = - m_Makefile->GetClassesFromSourceLists(target.m_SourceLists); + m_Makefile->GetClassesFromSourceLists(target.GetSourceLists()); for(std::vector::iterator i = classes.begin(); i != classes.end(); i++) { @@ -212,11 +212,11 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, // add any custom rules to the source groups for (std::vector::const_iterator cr = - target.m_CustomCommands.begin(); - cr != target.m_CustomCommands.end(); ++cr) + target.GetCustomCommands().begin(); + cr != target.GetCustomCommands().end(); ++cr) { cmSourceGroup& sourceGroup = - m_Makefile->FindSourceGroup(cr->m_Source.c_str(), + m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(), sourceGroups); cmCustomCommand cc(*cr); cc.ExpandVariables(*m_Makefile); diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index 0469228..8c9a62b 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -91,7 +91,7 @@ void cmDSPMakefile::OutputDSPFile() for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.m_IsALibrary) + if (l->second.IsALibrary()) { this->SetBuildType(m_LibraryBuildType, l->first.c_str()); } @@ -196,7 +196,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, // get the classes from the source lists then add them to the groups std::vector classes = - m_Makefile->GetClassesFromSourceLists(target.m_SourceLists); + m_Makefile->GetClassesFromSourceLists(target.GetSourceLists()); for(std::vector::iterator i = classes.begin(); i != classes.end(); i++) { @@ -212,11 +212,11 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout, // add any custom rules to the source groups for (std::vector::const_iterator cr = - target.m_CustomCommands.begin(); - cr != target.m_CustomCommands.end(); ++cr) + target.GetCustomCommands().begin(); + cr != target.GetCustomCommands().end(); ++cr) { cmSourceGroup& sourceGroup = - m_Makefile->FindSourceGroup(cr->m_Source.c_str(), + m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(), sourceGroups); cmCustomCommand cc(*cr); cc.ExpandVariables(*m_Makefile); diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx index 99fd26d..8e37083 100644 --- a/Source/cmDSWMakefile.cxx +++ b/Source/cmDSWMakefile.cxx @@ -134,7 +134,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, { if(*i != dspname) { - if (!l.m_IsALibrary || + if (!l.IsALibrary() || project->GetLibraryBuildType() == cmDSPMakefile::DLL) { fout << "Begin Project Dependency\n"; diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx index 99fd26d..8e37083 100644 --- a/Source/cmDSWWriter.cxx +++ b/Source/cmDSWWriter.cxx @@ -134,7 +134,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, { if(*i != dspname) { - if (!l.m_IsALibrary || + if (!l.IsALibrary() || project->GetLibraryBuildType() == cmDSPMakefile::DLL) { fout << "Begin Project Dependency\n"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 69856b4..139bcd0 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -304,7 +304,7 @@ void cmMakefile::AddCustomCommand(const char* source, if (m_Targets.find(target) != m_Targets.end()) { cmCustomCommand cc(source,command,depends,outputs); - m_Targets[target].m_CustomCommands.push_back(cc); + m_Targets[target].GetCustomCommands().push_back(cc); } } @@ -368,8 +368,8 @@ void cmMakefile::SetProjectName(const char* p) void cmMakefile::AddLibrary(const char* lname, const std::vector &srcs) { cmTarget target; - target.m_IsALibrary = 1; - target.m_SourceLists = srcs; + target.SetIsALibrary(1); + target.GetSourceLists() = srcs; m_Targets.insert(cmTargets::value_type(lname,target)); } @@ -377,8 +377,8 @@ void cmMakefile::AddExecutable(const char *exeName, const std::vector &srcs) { cmTarget target; - target.m_IsALibrary = 0; - target.m_SourceLists = srcs; + target.SetIsALibrary(0); + target.GetSourceLists() = srcs; m_Targets.insert(cmTargets::value_type(exeName,target)); } diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 7025751..6a9e6ff 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -55,30 +55,30 @@ bool cmSourceGroup::Matches(const char* name) */ void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) { - CustomCommands::iterator s = m_CustomCommands.find(cmd.m_Source); + CustomCommands::iterator s = m_CustomCommands.find(cmd.GetSourceName()); if(s == m_CustomCommands.end()) { // The source was not found. Add it with this command. - m_CustomCommands[cmd.m_Source][cmd.m_Command]. - m_Depends.insert(cmd.m_Depends.begin(),cmd.m_Depends.end()); - m_CustomCommands[cmd.m_Source][cmd.m_Command]. - m_Outputs.insert(cmd.m_Outputs.begin(),cmd.m_Outputs.end()); + m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()]. + m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end()); + m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()]. + m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end()); return; } // The source already exists. See if the command exists. Commands& commands = s->second; - Commands::iterator c = commands.find(cmd.m_Command); + Commands::iterator c = commands.find(cmd.GetCommand()); if(c == commands.end()) { // The command did not exist. Add it. - commands[cmd.m_Command].m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end()); - commands[cmd.m_Command].m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end()); + commands[cmd.GetCommand()].m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end()); + commands[cmd.GetCommand()].m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end()); return; } // The command already exists for this source. Merge the sets. CommandFiles& commandFiles = c->second; - commandFiles.m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end()); - commandFiles.m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end()); + commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end()); + commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end()); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 73c03b2..d72ec18 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -28,9 +28,29 @@ class cmTarget { public: + /** + * is this target a library? + */ + bool IsALibrary() const { return m_IsALibrary; } + bool GetIsALibrary() const { return m_IsALibrary; } + void SetIsALibrary(bool f) { m_IsALibrary = f; } + + /** + * Get the list of the custom commands for this target + */ + const std::vector &GetCustomCommands() const {return m_CustomCommands;} + std::vector &GetCustomCommands() {return m_CustomCommands;} + + /** + * Get the list of the source lists used by this target + */ + const std::vector &GetSourceLists() const {return m_SourceLists;} + std::vector &GetSourceLists() {return m_SourceLists;} + +private: std::vector m_CustomCommands; - bool m_IsALibrary; std::vector m_SourceLists; + bool m_IsALibrary; }; typedef std::map cmTargets; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index c1d4958..60941fe 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -74,7 +74,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.m_IsALibrary) + if (l->second.IsALibrary()) { fout << " \\\nlib" << l->first.c_str() << "${CMAKE_LIB_EXT}"; } @@ -83,7 +83,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { - if (!l->second.m_IsALibrary) + if (!l->second.IsALibrary()) { fout << "\\\n" << l->first.c_str(); } @@ -95,7 +95,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) l != tgts.end(); l++) { std::vector classes = - m_Makefile->GetClassesFromSourceLists(l->second.m_SourceLists); + m_Makefile->GetClassesFromSourceLists(l->second.GetSourceLists()); fout << l->first << "_SRC_OBJS = "; for(std::vector::iterator i = classes.begin(); i != classes.end(); i++) @@ -174,7 +174,7 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout) for(cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); l++) { - if (l->second.m_IsALibrary) + if (l->second.IsALibrary()) { fout << "#---------------------------------------------------------\n"; fout << "# rules for a library\n"; @@ -432,11 +432,11 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) { // add any custom rules to the source groups for (std::vector::const_iterator cr = - tgt->second.m_CustomCommands.begin(); - cr != tgt->second.m_CustomCommands.end(); ++cr) + tgt->second.GetCustomCommands().begin(); + cr != tgt->second.GetCustomCommands().end(); ++cr) { cmSourceGroup& sourceGroup = - m_Makefile->FindSourceGroup(cr->m_Source.c_str(), + m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(), sourceGroups); cmCustomCommand cc(*cr); cc.ExpandVariables(*m_Makefile); -- cgit v0.12