Don't pass objects ( particularly vectors ) by value unless absolutely
necessary. Also applied some const-correctness
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
2005-01-08 00:25:48 UTC (rev 12877)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
2005-01-08 02:33:09 UTC (rev 12878)
@@ -100,7 +100,7 @@
}
void
-MingwBackend::GetModuleHandlers ( MingwModuleHandlerList&
moduleHandlers )
+MingwBackend::GetModuleHandlers ( MingwModuleHandlerList&
moduleHandlers ) const
{
moduleHandlers.push_back ( new MingwKernelModuleHandler (
fMakefile ) );
moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler (
fMakefile ) );
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
2005-01-08 00:25:48 UTC (rev 12877)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
2005-01-08 02:33:09 UTC (rev 12878)
@@ -7,6 +7,9 @@
class MingwModuleHandlerList : public std::vector<MingwModuleHandler*>
{
public:
+ MingwModuleHandlerList()
+ {
+ }
~MingwModuleHandlerList()
{
for ( size_t i = 0; i < size(); i++ )
@@ -14,6 +17,10 @@
delete (*this)[i];
}
}
+private:
+ // disable copy semantics
+ MingwModuleHandlerList ( const MingwModuleHandlerList& );
+ MingwModuleHandlerList& operator = ( const
MingwModuleHandlerList& );
};
@@ -24,7 +31,7 @@
virtual void Process ();
private:
void ProcessModule ( Module& module );
- void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers
);
+ void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers
) const;
void CreateMakefile ();
void CloseMakefile ();
void GenerateHeader ();
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-01-08 00:25:48 UTC (rev 12877)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.cpp 2005-01-08 02:33:09 UTC (rev 12878)
@@ -15,14 +15,14 @@
}
string
-MingwModuleHandler::GetWorkingDirectory ()
+MingwModuleHandler::GetWorkingDirectory () const
{
return ".";
}
string
-MingwModuleHandler::ReplaceExtension ( string filename,
- string newExtension )
+MingwModuleHandler::ReplaceExtension ( const string& filename,
+ const string& newExtension )
const
{
size_t index = filename.find_last_of ( '.' );
if (index != string::npos)
@@ -31,14 +31,14 @@
}
string
-MingwModuleHandler::GetModuleArchiveFilename ( Module& module )
+MingwModuleHandler::GetModuleArchiveFilename ( const Module& module )
const
{
return ReplaceExtension ( module.GetPath ().c_str (),
".a" );
}
string
-MingwModuleHandler::GetImportLibraryDependencies ( Module& module )
+MingwModuleHandler::GetImportLibraryDependencies ( const Module& module
) const
{
if ( module.libraries.size () == 0 )
return "";
@@ -56,7 +56,7 @@
}
string
-MingwModuleHandler::GetSourceFilenames ( Module& module )
+MingwModuleHandler::GetSourceFilenames ( const Module& module ) const
{
if ( module.files.size () == 0 )
return "";
@@ -72,14 +72,14 @@
}
string
-MingwModuleHandler::GetObjectFilename ( string sourceFilename )
+MingwModuleHandler::GetObjectFilename ( const string& sourceFilename )
const
{
return ReplaceExtension ( sourceFilename,
".o" );
}
string
-MingwModuleHandler::GetObjectFilenames ( Module& module )
+MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
{
if ( module.files.size () == 0 )
return "";
@@ -95,7 +95,7 @@
}
string
-MingwModuleHandler::GenerateGccDefineParametersFromVector (
vector<Define*> defines )
+MingwModuleHandler::GenerateGccDefineParametersFromVector ( const
vector<Define*>& defines ) const
{
string parameters;
for (size_t i = 0; i < defines.size (); i++)
@@ -115,7 +115,7 @@
}
string
-MingwModuleHandler::GenerateGccDefineParameters ( Module& module )
+MingwModuleHandler::GenerateGccDefineParameters ( const Module& module
) const
{
string parameters = GenerateGccDefineParametersFromVector (
module.project->defines );
string s = GenerateGccDefineParametersFromVector (
module.defines );
@@ -128,8 +128,8 @@
}
string
-MingwModuleHandler::ConcatenatePaths ( string path1,
- string path2 )
+MingwModuleHandler::ConcatenatePaths ( const string& path1,
+ const string& path2 ) const
{
if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 ==
"./" ) )
return path2;
@@ -140,8 +140,8 @@
}
string
-MingwModuleHandler::GenerateGccIncludeParametersFromVector ( string
basePath,
-
vector<Include*> includes )
+MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const
string& basePath,
+ const
vector<Include*>& includes ) const
{
string parameters;
for (size_t i = 0; i < includes.size (); i++)
@@ -157,7 +157,7 @@
}
string
-MingwModuleHandler::GenerateGccIncludeParameters ( Module& module )
+MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module
) const
{
string parameters = GenerateGccIncludeParametersFromVector (
".",
module.project->includes );
@@ -172,7 +172,7 @@
}
string
-MingwModuleHandler::GenerateGccParameters ( Module& module )
+MingwModuleHandler::GenerateGccParameters ( const Module& module )
const
{
string parameters = GenerateGccDefineParameters ( module );
string s = GenerateGccIncludeParameters ( module );
@@ -185,7 +185,7 @@
}
void
-MingwModuleHandler::GenerateObjectFileTargets ( Module& module )
+MingwModuleHandler::GenerateObjectFileTargets ( const Module& module )
const
{
if ( module.files.size () == 0 )
return;
@@ -209,7 +209,7 @@
}
void
-MingwModuleHandler::GenerateArchiveTarget ( Module& module )
+MingwModuleHandler::GenerateArchiveTarget ( const Module& module )
const
{
string archiveFilename = GetModuleArchiveFilename ( module );
string sourceFilenames = GetSourceFilenames ( module );
@@ -233,19 +233,19 @@
}
bool
-MingwKernelModuleHandler::CanHandleModule ( Module& module )
+MingwKernelModuleHandler::CanHandleModule ( const Module& module )
const
{
return module.type == KernelModeDLL;
}
void
-MingwKernelModuleHandler::Process ( Module& module )
+MingwKernelModuleHandler::Process ( const Module& module )
{
GenerateKernelModuleTarget ( module );
}
void
-MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
+MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module&
module )
{
string workingDirectory = GetWorkingDirectory ( );
string archiveFilename = GetModuleArchiveFilename ( module );
@@ -292,19 +292,19 @@
}
bool
-MingwStaticLibraryModuleHandler::CanHandleModule ( Module& module )
+MingwStaticLibraryModuleHandler::CanHandleModule ( const Module& module
) const
{
return module.type == StaticLibrary;
}
void
-MingwStaticLibraryModuleHandler::Process ( Module& module )
+MingwStaticLibraryModuleHandler::Process ( const Module& module )
{
GenerateStaticLibraryModuleTarget ( module );
}
void
-MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget (
Module& module )
+MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget (
const Module& module )
{
GenerateArchiveTarget ( module );
GenerateObjectFileTargets ( module );
_____
Modified:
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h
---
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h 2005-01-08 00:25:48 UTC (rev 12877)
+++
branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler
.h 2005-01-08 02:33:09 UTC (rev 12878)
@@ -7,29 +7,29 @@
{
public:
MingwModuleHandler ( FILE* fMakefile );
- virtual bool CanHandleModule ( Module& module ) = 0;
- virtual void Process ( Module& module ) = 0;
+ virtual bool CanHandleModule ( const Module& module ) const = 0;
+ virtual void Process ( const Module& module ) = 0;
protected:
- std::string MingwModuleHandler::GetWorkingDirectory ();
- std::string ReplaceExtension ( std::string filename,
- std::string newExtension );
- std::string GetModuleArchiveFilename ( Module& module );
- std::string GetImportLibraryDependencies ( Module& module );
- std::string GetSourceFilenames ( Module& module );
- std::string GetObjectFilename ( std::string sourceFilename );
- std::string GetObjectFilenames ( Module& module );
- void GenerateObjectFileTargets ( Module& module );
- void GenerateArchiveTarget ( Module& module );
+ std::string MingwModuleHandler::GetWorkingDirectory () const;
+ std::string ReplaceExtension ( const std::string& filename,
+ const std::string& newExtension )
const;
+ std::string GetModuleArchiveFilename ( const Module& module )
const;
+ std::string GetImportLibraryDependencies ( const Module& module
) const;
+ std::string GetSourceFilenames ( const Module& module ) const;
+ std::string GetObjectFilename ( const std::string&
sourceFilename ) const;
+ std::string GetObjectFilenames ( const Module& module ) const;
+ void GenerateObjectFileTargets ( const Module& module ) const;
+ void GenerateArchiveTarget ( const Module& module ) const;
FILE* fMakefile;
private:
- std::string ConcatenatePaths ( std::string path1,
- std::string path2 );
- std::string GenerateGccDefineParametersFromVector (
std::vector<Define*> defines );
- std::string GenerateGccDefineParameters ( Module& module );
- std::string GenerateGccIncludeParametersFromVector ( std::string
basePath,
-
std::vector<Include*> includes );
- std::string GenerateGccIncludeParameters ( Module& module );
- std::string GenerateGccParameters ( Module& module );
+ std::string ConcatenatePaths ( const std::string& path1,
+ const std::string& path2 ) const;
+ std::string GenerateGccDefineParametersFromVector ( const
std::vector<Define*>& defines ) const;
+ std::string GenerateGccDefineParameters ( const Module& module )
const;
+ std::string GenerateGccIncludeParametersFromVector ( const
std::string& basePath,
+ const
std::vector<Include*>& includes ) const;
+ std::string GenerateGccIncludeParameters ( const Module& module
) const;
+ std::string GenerateGccParameters ( const Module& module )
const;
};
@@ -37,10 +37,10 @@
{
public:
MingwKernelModuleHandler ( FILE* fMakefile );
- virtual bool CanHandleModule ( Module& module );
- virtual void Process ( Module& module );
+ virtual bool CanHandleModule ( const Module& module ) const;
+ virtual void Process ( const Module& module );
private:
- void GenerateKernelModuleTarget ( Module& module );
+ void GenerateKernelModuleTarget ( const Module& module );
};
@@ -48,10 +48,10 @@
{
public:
MingwStaticLibraryModuleHandler ( FILE* fMakefile );
- virtual bool CanHandleModule ( Module& module );
- virtual void Process ( Module& module );
+ virtual bool CanHandleModule ( const Module& module ) const;
+ virtual void Process ( const Module& module );
private:
- void GenerateStaticLibraryModuleTarget ( Module& module );
+ void GenerateStaticLibraryModuleTarget ( const Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-08 00:25:48 UTC (rev 12877)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
2005-01-08 02:33:09 UTC (rev 12878)
@@ -118,7 +118,7 @@
}
string
-Module::GetPath ()
+Module::GetPath () const
{
return FixSeparator (path) + CSEP + name + extension;
}
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-08 00:25:48 UTC (rev 12877)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
2005-01-08 02:33:09 UTC (rev 12878)
@@ -77,7 +77,7 @@
const std::string& modulePath );
~Module ();
ModuleType GetModuleType (const XMLAttribute& attribute );
- std::string GetPath ();
+ std::string GetPath () const;
void ProcessXML ( const XMLElement& e, const std::string& path
);
private:
std::string GetDefaultModuleExtension ();