mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 16:22:58 +00:00
Don't pass objects ( particularly vectors ) by value unless absolutely necessary. Also applied some const-correctness
svn path=/branches/xmlbuildsystem/; revision=12878
This commit is contained in:
parent
5f69cb429e
commit
de7c566b05
6 changed files with 61 additions and 54 deletions
|
@ -100,7 +100,7 @@ MingwBackend::ProcessModule ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers )
|
MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers ) const
|
||||||
{
|
{
|
||||||
moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) );
|
moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) );
|
||||||
moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler ( fMakefile ) );
|
moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler ( fMakefile ) );
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
class MingwModuleHandlerList : public std::vector<MingwModuleHandler*>
|
class MingwModuleHandlerList : public std::vector<MingwModuleHandler*>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MingwModuleHandlerList()
|
||||||
|
{
|
||||||
|
}
|
||||||
~MingwModuleHandlerList()
|
~MingwModuleHandlerList()
|
||||||
{
|
{
|
||||||
for ( size_t i = 0; i < size(); i++ )
|
for ( size_t i = 0; i < size(); i++ )
|
||||||
|
@ -14,6 +17,10 @@ public:
|
||||||
delete (*this)[i];
|
delete (*this)[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
// disable copy semantics
|
||||||
|
MingwModuleHandlerList ( const MingwModuleHandlerList& );
|
||||||
|
MingwModuleHandlerList& operator = ( const MingwModuleHandlerList& );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +31,7 @@ public:
|
||||||
virtual void Process ();
|
virtual void Process ();
|
||||||
private:
|
private:
|
||||||
void ProcessModule ( Module& module );
|
void ProcessModule ( Module& module );
|
||||||
void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers );
|
void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers ) const;
|
||||||
void CreateMakefile ();
|
void CreateMakefile ();
|
||||||
void CloseMakefile ();
|
void CloseMakefile ();
|
||||||
void GenerateHeader ();
|
void GenerateHeader ();
|
||||||
|
|
|
@ -15,14 +15,14 @@ MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetWorkingDirectory ()
|
MingwModuleHandler::GetWorkingDirectory () const
|
||||||
{
|
{
|
||||||
return ".";
|
return ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::ReplaceExtension ( string filename,
|
MingwModuleHandler::ReplaceExtension ( const string& filename,
|
||||||
string newExtension )
|
const string& newExtension ) const
|
||||||
{
|
{
|
||||||
size_t index = filename.find_last_of ( '.' );
|
size_t index = filename.find_last_of ( '.' );
|
||||||
if (index != string::npos)
|
if (index != string::npos)
|
||||||
|
@ -31,14 +31,14 @@ MingwModuleHandler::ReplaceExtension ( string filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetModuleArchiveFilename ( Module& module )
|
MingwModuleHandler::GetModuleArchiveFilename ( const Module& module ) const
|
||||||
{
|
{
|
||||||
return ReplaceExtension ( module.GetPath ().c_str (),
|
return ReplaceExtension ( module.GetPath ().c_str (),
|
||||||
".a" );
|
".a" );
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetImportLibraryDependencies ( Module& module )
|
MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
|
||||||
{
|
{
|
||||||
if ( module.libraries.size () == 0 )
|
if ( module.libraries.size () == 0 )
|
||||||
return "";
|
return "";
|
||||||
|
@ -56,7 +56,7 @@ MingwModuleHandler::GetImportLibraryDependencies ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetSourceFilenames ( Module& module )
|
MingwModuleHandler::GetSourceFilenames ( const Module& module ) const
|
||||||
{
|
{
|
||||||
if ( module.files.size () == 0 )
|
if ( module.files.size () == 0 )
|
||||||
return "";
|
return "";
|
||||||
|
@ -72,14 +72,14 @@ MingwModuleHandler::GetSourceFilenames ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetObjectFilename ( string sourceFilename )
|
MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const
|
||||||
{
|
{
|
||||||
return ReplaceExtension ( sourceFilename,
|
return ReplaceExtension ( sourceFilename,
|
||||||
".o" );
|
".o" );
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GetObjectFilenames ( Module& module )
|
MingwModuleHandler::GetObjectFilenames ( const Module& module ) const
|
||||||
{
|
{
|
||||||
if ( module.files.size () == 0 )
|
if ( module.files.size () == 0 )
|
||||||
return "";
|
return "";
|
||||||
|
@ -95,7 +95,7 @@ MingwModuleHandler::GetObjectFilenames ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccDefineParametersFromVector ( vector<Define*> defines )
|
MingwModuleHandler::GenerateGccDefineParametersFromVector ( const vector<Define*>& defines ) const
|
||||||
{
|
{
|
||||||
string parameters;
|
string parameters;
|
||||||
for (size_t i = 0; i < defines.size (); i++)
|
for (size_t i = 0; i < defines.size (); i++)
|
||||||
|
@ -115,7 +115,7 @@ MingwModuleHandler::GenerateGccDefineParametersFromVector ( vector<Define*> defi
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccDefineParameters ( Module& module )
|
MingwModuleHandler::GenerateGccDefineParameters ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string parameters = GenerateGccDefineParametersFromVector ( module.project->defines );
|
string parameters = GenerateGccDefineParametersFromVector ( module.project->defines );
|
||||||
string s = GenerateGccDefineParametersFromVector ( module.defines );
|
string s = GenerateGccDefineParametersFromVector ( module.defines );
|
||||||
|
@ -128,8 +128,8 @@ MingwModuleHandler::GenerateGccDefineParameters ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::ConcatenatePaths ( string path1,
|
MingwModuleHandler::ConcatenatePaths ( const string& path1,
|
||||||
string path2 )
|
const string& path2 ) const
|
||||||
{
|
{
|
||||||
if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )
|
if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )
|
||||||
return path2;
|
return path2;
|
||||||
|
@ -140,8 +140,8 @@ MingwModuleHandler::ConcatenatePaths ( string path1,
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccIncludeParametersFromVector ( string basePath,
|
MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const string& basePath,
|
||||||
vector<Include*> includes )
|
const vector<Include*>& includes ) const
|
||||||
{
|
{
|
||||||
string parameters;
|
string parameters;
|
||||||
for (size_t i = 0; i < includes.size (); i++)
|
for (size_t i = 0; i < includes.size (); i++)
|
||||||
|
@ -157,7 +157,7 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( string basePath,
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccIncludeParameters ( Module& module )
|
MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string parameters = GenerateGccIncludeParametersFromVector ( ".",
|
string parameters = GenerateGccIncludeParametersFromVector ( ".",
|
||||||
module.project->includes );
|
module.project->includes );
|
||||||
|
@ -172,7 +172,7 @@ MingwModuleHandler::GenerateGccIncludeParameters ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccParameters ( Module& module )
|
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string parameters = GenerateGccDefineParameters ( module );
|
string parameters = GenerateGccDefineParameters ( module );
|
||||||
string s = GenerateGccIncludeParameters ( module );
|
string s = GenerateGccIncludeParameters ( module );
|
||||||
|
@ -185,7 +185,7 @@ MingwModuleHandler::GenerateGccParameters ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GenerateObjectFileTargets ( Module& module )
|
MingwModuleHandler::GenerateObjectFileTargets ( const Module& module ) const
|
||||||
{
|
{
|
||||||
if ( module.files.size () == 0 )
|
if ( module.files.size () == 0 )
|
||||||
return;
|
return;
|
||||||
|
@ -209,7 +209,7 @@ MingwModuleHandler::GenerateObjectFileTargets ( Module& module )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GenerateArchiveTarget ( Module& module )
|
MingwModuleHandler::GenerateArchiveTarget ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string archiveFilename = GetModuleArchiveFilename ( module );
|
string archiveFilename = GetModuleArchiveFilename ( module );
|
||||||
string sourceFilenames = GetSourceFilenames ( module );
|
string sourceFilenames = GetSourceFilenames ( module );
|
||||||
|
@ -233,19 +233,19 @@ MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile )
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MingwKernelModuleHandler::CanHandleModule ( Module& module )
|
MingwKernelModuleHandler::CanHandleModule ( const Module& module ) const
|
||||||
{
|
{
|
||||||
return module.type == KernelModeDLL;
|
return module.type == KernelModeDLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwKernelModuleHandler::Process ( Module& module )
|
MingwKernelModuleHandler::Process ( const Module& module )
|
||||||
{
|
{
|
||||||
GenerateKernelModuleTarget ( module );
|
GenerateKernelModuleTarget ( module );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
|
MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
|
||||||
{
|
{
|
||||||
string workingDirectory = GetWorkingDirectory ( );
|
string workingDirectory = GetWorkingDirectory ( );
|
||||||
string archiveFilename = GetModuleArchiveFilename ( module );
|
string archiveFilename = GetModuleArchiveFilename ( module );
|
||||||
|
@ -292,19 +292,19 @@ MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( FILE* fMakefi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MingwStaticLibraryModuleHandler::CanHandleModule ( Module& module )
|
MingwStaticLibraryModuleHandler::CanHandleModule ( const Module& module ) const
|
||||||
{
|
{
|
||||||
return module.type == StaticLibrary;
|
return module.type == StaticLibrary;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwStaticLibraryModuleHandler::Process ( Module& module )
|
MingwStaticLibraryModuleHandler::Process ( const Module& module )
|
||||||
{
|
{
|
||||||
GenerateStaticLibraryModuleTarget ( module );
|
GenerateStaticLibraryModuleTarget ( module );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( Module& module )
|
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Module& module )
|
||||||
{
|
{
|
||||||
GenerateArchiveTarget ( module );
|
GenerateArchiveTarget ( module );
|
||||||
GenerateObjectFileTargets ( module );
|
GenerateObjectFileTargets ( module );
|
||||||
|
|
|
@ -7,29 +7,29 @@ class MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MingwModuleHandler ( FILE* fMakefile );
|
MingwModuleHandler ( FILE* fMakefile );
|
||||||
virtual bool CanHandleModule ( Module& module ) = 0;
|
virtual bool CanHandleModule ( const Module& module ) const = 0;
|
||||||
virtual void Process ( Module& module ) = 0;
|
virtual void Process ( const Module& module ) = 0;
|
||||||
protected:
|
protected:
|
||||||
std::string MingwModuleHandler::GetWorkingDirectory ();
|
std::string MingwModuleHandler::GetWorkingDirectory () const;
|
||||||
std::string ReplaceExtension ( std::string filename,
|
std::string ReplaceExtension ( const std::string& filename,
|
||||||
std::string newExtension );
|
const std::string& newExtension ) const;
|
||||||
std::string GetModuleArchiveFilename ( Module& module );
|
std::string GetModuleArchiveFilename ( const Module& module ) const;
|
||||||
std::string GetImportLibraryDependencies ( Module& module );
|
std::string GetImportLibraryDependencies ( const Module& module ) const;
|
||||||
std::string GetSourceFilenames ( Module& module );
|
std::string GetSourceFilenames ( const Module& module ) const;
|
||||||
std::string GetObjectFilename ( std::string sourceFilename );
|
std::string GetObjectFilename ( const std::string& sourceFilename ) const;
|
||||||
std::string GetObjectFilenames ( Module& module );
|
std::string GetObjectFilenames ( const Module& module ) const;
|
||||||
void GenerateObjectFileTargets ( Module& module );
|
void GenerateObjectFileTargets ( const Module& module ) const;
|
||||||
void GenerateArchiveTarget ( Module& module );
|
void GenerateArchiveTarget ( const Module& module ) const;
|
||||||
FILE* fMakefile;
|
FILE* fMakefile;
|
||||||
private:
|
private:
|
||||||
std::string ConcatenatePaths ( std::string path1,
|
std::string ConcatenatePaths ( const std::string& path1,
|
||||||
std::string path2 );
|
const std::string& path2 ) const;
|
||||||
std::string GenerateGccDefineParametersFromVector ( std::vector<Define*> defines );
|
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
|
||||||
std::string GenerateGccDefineParameters ( Module& module );
|
std::string GenerateGccDefineParameters ( const Module& module ) const;
|
||||||
std::string GenerateGccIncludeParametersFromVector ( std::string basePath,
|
std::string GenerateGccIncludeParametersFromVector ( const std::string& basePath,
|
||||||
std::vector<Include*> includes );
|
const std::vector<Include*>& includes ) const;
|
||||||
std::string GenerateGccIncludeParameters ( Module& module );
|
std::string GenerateGccIncludeParameters ( const Module& module ) const;
|
||||||
std::string GenerateGccParameters ( Module& module );
|
std::string GenerateGccParameters ( const Module& module ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ class MingwKernelModuleHandler : public MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MingwKernelModuleHandler ( FILE* fMakefile );
|
MingwKernelModuleHandler ( FILE* fMakefile );
|
||||||
virtual bool CanHandleModule ( Module& module );
|
virtual bool CanHandleModule ( const Module& module ) const;
|
||||||
virtual void Process ( Module& module );
|
virtual void Process ( const Module& module );
|
||||||
private:
|
private:
|
||||||
void GenerateKernelModuleTarget ( Module& module );
|
void GenerateKernelModuleTarget ( const Module& module );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,10 +48,10 @@ class MingwStaticLibraryModuleHandler : public MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MingwStaticLibraryModuleHandler ( FILE* fMakefile );
|
MingwStaticLibraryModuleHandler ( FILE* fMakefile );
|
||||||
virtual bool CanHandleModule ( Module& module );
|
virtual bool CanHandleModule ( const Module& module ) const;
|
||||||
virtual void Process ( Module& module );
|
virtual void Process ( const Module& module );
|
||||||
private:
|
private:
|
||||||
void GenerateStaticLibraryModuleTarget ( Module& module );
|
void GenerateStaticLibraryModuleTarget ( const Module& module );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MINGW_MODULEHANDLER_H */
|
#endif /* MINGW_MODULEHANDLER_H */
|
||||||
|
|
|
@ -118,7 +118,7 @@ Module::GetDefaultModuleExtension ()
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
Module::GetPath ()
|
Module::GetPath () const
|
||||||
{
|
{
|
||||||
return FixSeparator (path) + CSEP + name + extension;
|
return FixSeparator (path) + CSEP + name + extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
const std::string& modulePath );
|
const std::string& modulePath );
|
||||||
~Module ();
|
~Module ();
|
||||||
ModuleType GetModuleType (const XMLAttribute& attribute );
|
ModuleType GetModuleType (const XMLAttribute& attribute );
|
||||||
std::string GetPath ();
|
std::string GetPath () const;
|
||||||
void ProcessXML ( const XMLElement& e, const std::string& path );
|
void ProcessXML ( const XMLElement& e, const std::string& path );
|
||||||
private:
|
private:
|
||||||
std::string GetDefaultModuleExtension ();
|
std::string GetDefaultModuleExtension ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue