Author: hpoussin
Date: Fri Jan 11 12:09:49 2008
New Revision: 31709
URL:
http://svn.reactos.org/svn/reactos?rev=31709&view=rev
Log:
Prevent creation 1500000 temporary objects by caching value of
CompilationUnit::GetFilename().
Limit access to variables of CompilationUnit
Modified:
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
trunk/reactos/tools/rbuild/compilationunit.cpp
trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
trunk/reactos/tools/rbuild/module.cpp
trunk/reactos/tools/rbuild/rbuild.h
trunk/reactos/tools/rbuild/testsupportcode.cpp
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Fri Jan 11 12:09:49 2008
@@ -206,7 +206,7 @@
for ( i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- if ( compilationUnit.files.size () != 1 )
+ if ( compilationUnit.GetFiles ().size () != 1 )
return false;
}
// intentionally make a copy so that we can append more work in
@@ -224,7 +224,7 @@
for ( j = 0; j < compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit = *compilationUnits[j];
- if ( compilationUnit.files.size () != 1 )
+ if ( compilationUnit.GetFiles ().size () != 1 )
return false;
}
}
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Fri Jan 11 12:09:49 2008
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 Casper S. Hornstrup
+ * 2007-2008 Hervé Poussineau
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -342,12 +343,12 @@
MingwModuleHandler::GetCompilationUnitDependencies (
const CompilationUnit& compilationUnit ) const
{
- if ( compilationUnit.files.size () <= 1 )
+ if ( compilationUnit.GetFiles ().size () <= 1 )
return "";
vector<string> sourceFiles;
- for ( size_t i = 0; i < compilationUnit.files.size (); i++ )
- {
- File& file = *compilationUnit.files[i];
+ for ( size_t i = 0; i < compilationUnit.GetFiles ().size (); i++ )
+ {
+ const File& file = *compilationUnit.GetFiles ()[i];
sourceFiles.push_back ( backend->GetFullName ( file.file ) );
}
return v2s ( sourceFiles, 10 );
@@ -412,13 +413,12 @@
for ( i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation *objectFilename = GetObjectFilename ( compilationName,
importedModule, NULL );
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation *objectFilename = GetObjectFilename ( &compilationName,
importedModule, NULL );
if ( GetExtension ( *objectFilename ) == ".h" )
dep += ssprintf ( " $(%s_HEADERS)", importedModule.name.c_str () );
else if ( GetExtension ( *objectFilename ) == ".rc" )
dep += ssprintf ( " $(%s_MCHEADERS)", importedModule.name.c_str () );
- delete compilationName;
}
}
else
@@ -483,10 +483,9 @@
{
if ( includeGeneratedFiles || !compilationUnits[i]->IsGeneratedFile () )
{
- const FileLocation *compilationName = compilationUnits[i]->GetFilename ();
- const FileLocation* sourceFileLocation = GetActualSourceFilename ( compilationName );
+ const FileLocation& compilationName = compilationUnits[i]->GetFilename ();
+ const FileLocation* sourceFileLocation = GetActualSourceFilename (
&compilationName );
list.push_back ( *sourceFileLocation );
- delete compilationName;
delete sourceFileLocation;
}
}
@@ -507,10 +506,9 @@
CompilationUnit& compilationUnit = *compilationUnits[j];
if ( includeGeneratedFiles || !compilationUnit.IsGeneratedFile () )
{
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation* sourceFileLocation = GetActualSourceFilename ( compilationName
);
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation* sourceFileLocation = GetActualSourceFilename (
&compilationName );
list.push_back ( *sourceFileLocation );
- delete compilationName;
delete sourceFileLocation;
}
}
@@ -670,10 +668,9 @@
{
if ( objectFilenames.size () > 0 )
objectFilenames += " ";
- const FileLocation *compilationName = compilationUnits[i]->GetFilename ();
- const FileLocation *object_file = GetObjectFilename ( compilationName, module, NULL );
+ const FileLocation& compilationName = compilationUnits[i]->GetFilename ();
+ const FileLocation *object_file = GetObjectFilename ( &compilationName, module,
NULL );
objectFilenames += backend->GetFullName ( *object_file );
- delete compilationName;
delete object_file;
}
return objectFilenames;
@@ -1021,13 +1018,12 @@
for ( i = 0; i < compilationUnits.size(); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- const FileLocation *compilationName = compilationUnit.GetFilename ();
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
fprintf (
fMakefile,
"%s%s",
( i%10 == 9 ? " \\\n\t" : " " ),
- backend->GetFullName ( *compilationName ).c_str () );
- delete compilationName;
+ backend->GetFullName ( compilationName ).c_str () );
}
fprintf ( fMakefile, "\n" );
}
@@ -1062,13 +1058,12 @@
GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
for ( i = 0; i < sourceCompilationUnits.size (); i++ )
{
- const FileLocation *compilationName = sourceCompilationUnits[i]->GetFilename ();
+ const FileLocation& compilationName = sourceCompilationUnits[i]->GetFilename
();
fprintf (
fMakefile,
"%s += %s\n",
sourcesMacro.c_str(),
- backend->GetFullName ( *compilationName ).c_str () );
- delete compilationName;
+ backend->GetFullName ( compilationName ).c_str () );
}
CleanupCompilationUnitVector ( sourceCompilationUnits );
}
@@ -1091,15 +1086,14 @@
CompilationUnit& compilationUnit = *compilationUnits[i];
if ( compilationUnit.IsFirstFile () )
{
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation *object_file = GetObjectFilename ( compilationName, module, NULL
);
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation *object_file = GetObjectFilename ( &compilationName, module,
NULL );
fprintf ( fMakefile,
"%s := %s $(%s)\n",
objectsMacro.c_str(),
backend->GetFullName ( *object_file ).c_str (),
objectsMacro.c_str() );
delete object_file;
- delete compilationName;
}
}
fprintf (
@@ -1112,13 +1106,13 @@
CompilationUnit& compilationUnit = *compilationUnits[i];
if ( !compilationUnit.IsFirstFile () )
{
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation *objectFilename = GetObjectFilename ( compilationName, module,
NULL );
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation *objectFilename = GetObjectFilename ( &compilationName,
module, NULL );
if ( GetExtension ( *objectFilename ) == ".h" )
headers.push_back ( objectFilename );
else if ( GetExtension ( *objectFilename ) == ".rc" )
{
- const FileLocation *headerFilename = GetMcHeaderFilename (
compilationUnit.GetFilename () );
+ const FileLocation *headerFilename = GetMcHeaderFilename (
&compilationUnit.GetFilename () );
mcheaders.push_back ( headerFilename );
mcresources.push_back ( objectFilename );
}
@@ -1131,7 +1125,6 @@
backend->GetFullName ( *objectFilename ).c_str () );
delete objectFilename;
}
- delete compilationName;
}
}
fprintf ( fMakefile, "\n" );
@@ -1223,15 +1216,14 @@
GetModuleSpecificCompilationUnits ( sourceCompilationUnits );
for ( i = 0; i < sourceCompilationUnits.size (); i++ )
{
- const FileLocation *compilationName = sourceCompilationUnits[i]->GetFilename ();
- const FileLocation *object_file = GetObjectFilename ( compilationName, module, NULL );
+ const FileLocation& compilationName = sourceCompilationUnits[i]->GetFilename
();
+ const FileLocation *object_file = GetObjectFilename ( &compilationName, module,
NULL );
fprintf (
fMakefile,
"%s += %s\n",
objectsMacro.c_str(),
backend->GetFullName ( *object_file ).c_str () );
delete object_file;
- delete compilationName;
}
CleanupCompilationUnitVector ( sourceCompilationUnits );
}
@@ -1487,17 +1479,17 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string dependencies = backend->GetFullName ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string dependencies = backend->GetFullName ( sourceFile );
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( sourceFile->name );
-
- const FileLocation *generatedHeaderFilename = GetRpcServerHeaderFilename ( sourceFile
);
+ string basename = GetBasename ( sourceFile.name );
+
+ const FileLocation *generatedHeaderFilename = GetRpcServerHeaderFilename (
&sourceFile );
CLEAN_FILE ( *generatedHeaderFilename );
FileLocation generatedServerFilename ( IntermediateDirectory,
- sourceFile->relative_path,
+ sourceFile.relative_path,
basename + "_s.c" );
CLEAN_FILE ( generatedServerFilename );
@@ -1515,10 +1507,9 @@
widlflagsMacro.c_str (),
backend->GetFullName ( *generatedHeaderFilename ).c_str (),
backend->GetFullName ( generatedServerFilename ).c_str (),
- backend->GetFullName ( *sourceFile ).c_str () );
+ backend->GetFullName ( sourceFile ).c_str () );
delete generatedHeaderFilename;
- delete sourceFile;
}
/* caller needs to delete the returned object */
@@ -1550,14 +1541,14 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string dependencies = backend->GetFullName ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string dependencies = backend->GetFullName ( sourceFile );
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( sourceFile->name );
+ string basename = GetBasename ( sourceFile.name );
FileLocation EmbeddedTypeLibFilename ( IntermediateDirectory,
- sourceFile->relative_path,
+ sourceFile.relative_path,
basename + ".tlb" );
fprintf ( fMakefile,
@@ -1572,9 +1563,7 @@
GetWidlFlags ( compilationUnit ).c_str (),
widlflagsMacro.c_str (),
backend->GetFullName ( EmbeddedTypeLibFilename ).c_str(),
- backend->GetFullName ( *sourceFile ).c_str () );
-
- delete sourceFile;
+ backend->GetFullName ( sourceFile ).c_str () );
}
void
@@ -1582,17 +1571,17 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string dependencies = backend->GetFullName ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string dependencies = backend->GetFullName ( sourceFile );
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( sourceFile->name );
-
- const FileLocation *generatedHeaderFilename = GetRpcClientHeaderFilename ( sourceFile
);
+ string basename = GetBasename ( sourceFile.name );
+
+ const FileLocation *generatedHeaderFilename = GetRpcClientHeaderFilename (
&sourceFile );
CLEAN_FILE ( *generatedHeaderFilename );
FileLocation generatedClientFilename ( IntermediateDirectory,
- sourceFile->relative_path,
+ sourceFile.relative_path,
basename + "_c.c" );
CLEAN_FILE ( generatedClientFilename );
@@ -1610,10 +1599,9 @@
widlflagsMacro.c_str (),
backend->GetFullName ( *generatedHeaderFilename ).c_str (),
backend->GetFullName ( generatedClientFilename ).c_str (),
- backend->GetFullName ( *sourceFile ).c_str () );
+ backend->GetFullName ( sourceFile ).c_str () );
delete generatedHeaderFilename;
- delete sourceFile;
}
void
@@ -1621,13 +1609,13 @@
const CompilationUnit& compilationUnit,
const string& widlflagsMacro )
{
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string dependencies = backend->GetFullName ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string dependencies = backend->GetFullName ( sourceFile );
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
- string basename = GetBasename ( sourceFile->name );
-
- const FileLocation *generatedHeader = GetIdlHeaderFilename ( sourceFile );
+ string basename = GetBasename ( sourceFile.name );
+
+ const FileLocation *generatedHeader = GetIdlHeaderFilename ( &sourceFile );
CLEAN_FILE ( *generatedHeader );
fprintf ( fMakefile,
@@ -1642,10 +1630,9 @@
GetWidlFlags ( compilationUnit ).c_str (),
widlflagsMacro.c_str (),
backend->GetFullName ( *generatedHeader ).c_str (),
- backend->GetFullName ( *sourceFile ).c_str () );
+ backend->GetFullName ( sourceFile ).c_str () );
delete generatedHeader;
- delete sourceFile;
}
void
@@ -1678,11 +1665,11 @@
const string& windresflagsMacro,
const string& widlflagsMacro )
{
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string extension = GetExtension ( sourceFile );
if ( extension == ".c" || extension == ".C" )
{
- GenerateGccCommand ( sourceFile,
+ GenerateGccCommand ( &sourceFile,
GetCompilationUnitDependencies ( compilationUnit ) +
extraDependencies,
cc,
cflagsMacro );
@@ -1691,35 +1678,35 @@
extension == ".cpp" || extension == ".CPP" ||
extension == ".cxx" || extension == ".CXX" )
{
- GenerateGccCommand ( sourceFile,
+ GenerateGccCommand ( &sourceFile,
GetCompilationUnitDependencies ( compilationUnit ) +
extraDependencies,
cppc,
cflagsMacro );
}
else if ( extension == ".s" || extension == ".S" )
{
- GenerateGccAssemblerCommand ( sourceFile,
+ GenerateGccAssemblerCommand ( &sourceFile,
cc,
cflagsMacro );
}
else if ( extension == ".asm" || extension == ".ASM" )
{
- GenerateNasmCommand ( sourceFile,
+ GenerateNasmCommand ( &sourceFile,
nasmflagsMacro );
}
else if ( extension == ".rc" || extension == ".RC" )
{
- GenerateWindresCommand ( sourceFile,
+ GenerateWindresCommand ( &sourceFile,
windresflagsMacro );
}
else if ( extension == ".mc" || extension == ".MC" )
{
- GenerateWmcCommands ( sourceFile );
+ GenerateWmcCommands ( &sourceFile );
}
else if ( extension == ".spec" || extension == ".SPEC" )
{
- GenerateWinebuildCommands ( sourceFile );
- GenerateGccCommand ( sourceFile,
+ GenerateWinebuildCommands ( &sourceFile );
+ GenerateGccCommand ( &sourceFile,
extraDependencies,
cc,
cflagsMacro );
@@ -1730,8 +1717,8 @@
widlflagsMacro );
if ( (module.type == RpcServer) || (module.type == RpcClient) )
{
- GenerateGccCommand ( sourceFile,
- GetExtraDependencies ( sourceFile ),
+ GenerateGccCommand ( &sourceFile,
+ GetExtraDependencies ( &sourceFile ),
cc,
cflagsMacro );
}
@@ -1742,10 +1729,8 @@
__LINE__,
"Unsupported filename extension '%s' in
file '%s'",
extension.c_str (),
- backend->GetFullName ( *sourceFile ).c_str () );
- }
-
- delete sourceFile;
+ backend->GetFullName ( sourceFile ).c_str () );
+ }
}
void
@@ -1833,11 +1818,10 @@
for ( size_t i = 0; i < data.compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *data.compilationUnits[i];
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation *object_file = GetObjectFilename ( compilationName, module, NULL );
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation *object_file = GetObjectFilename ( &compilationName, module,
NULL );
objectFiles.push_back ( *object_file );
delete object_file;
- delete compilationName;
}
}
@@ -2023,13 +2007,12 @@
for ( i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- const FileLocation *compilationName = compilationUnit.GetFilename ();
- const FileLocation *objectFilename = GetObjectFilename ( compilationName, module, NULL
);
+ const FileLocation& compilationName = compilationUnit.GetFilename ();
+ const FileLocation *objectFilename = GetObjectFilename ( &compilationName, module,
NULL );
if ( GetExtension ( *objectFilename ) == ".h" )
moduleDependencies += ssprintf ( " $(%s_HEADERS)", module.name.c_str () );
else if ( GetExtension ( *objectFilename ) == ".rc" )
moduleDependencies += ssprintf ( " $(%s_RESOURCES)", module.name.c_str ()
);
- delete compilationName;
delete objectFilename;
}
@@ -2257,31 +2240,30 @@
for ( size_t j = 0; j <
library.importedModule->non_if_data.compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit =
*library.importedModule->non_if_data.compilationUnits[j];
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string extension = GetExtension ( sourceFile );
if ( extension == ".idl" || extension == ".IDL" )
{
- string basename = GetBasename ( sourceFile->name );
+ string basename = GetBasename ( sourceFile.name );
if ( library.importedModule->type == RpcServer )
{
- const FileLocation *header = GetRpcServerHeaderFilename ( sourceFile );
+ const FileLocation *header = GetRpcServerHeaderFilename ( &sourceFile );
dependencies.push_back ( *header );
delete header;
}
if ( library.importedModule->type == RpcClient )
{
- const FileLocation *header = GetRpcClientHeaderFilename ( sourceFile );
+ const FileLocation *header = GetRpcClientHeaderFilename ( &sourceFile );
dependencies.push_back ( *header );
delete header;
}
if ( library.importedModule->type == IdlHeader )
{
- const FileLocation *header = GetIdlHeaderFilename ( sourceFile );
+ const FileLocation *header = GetIdlHeaderFilename ( &sourceFile );
dependencies.push_back ( *header );
delete header;
}
}
- delete sourceFile;
}
}
}
@@ -2319,11 +2301,10 @@
for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string extension = GetExtension ( sourceFile );
if ( extension == ".spec" || extension == ".SPEC" )
- GetSpecObjectDependencies ( s, sourceFile );
- delete sourceFile;
+ GetSpecObjectDependencies ( s, &sourceFile );
}
}
if ( s.size () > 0 )
@@ -2573,14 +2554,13 @@
for ( size_t j = 0; j < m.non_if_data.compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit = *m.non_if_data.compilationUnits[j];
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( *sourceFile );
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string extension = GetExtension ( sourceFile );
if (extension == ".mc" || extension == ".MC" )
{
string dependency = ssprintf ( " $(%s_MCHEADERS)", m.name.c_str () );
dependencies.push_back ( dependency );
}
- delete sourceFile;
}
}
}
@@ -2749,17 +2729,16 @@
const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
for ( size_t i = 0; i < compilationUnits.size (); i++ )
{
- CompilationUnit& compilationUnit = *compilationUnits[i];
- const FileLocation* sourceFile = compilationUnit.GetFilename ();
- string extension = GetExtension ( *sourceFile );
+ const CompilationUnit& compilationUnit = *compilationUnits[i];
+ const FileLocation& sourceFile = compilationUnit.GetFilename ();
+ string extension = GetExtension ( sourceFile );
if ( extension == ".spec" || extension == ".SPEC" )
- GetSpecObjectDependencies ( dependencies, sourceFile );
+ GetSpecObjectDependencies ( dependencies, &sourceFile );
if ( extension == ".idl" || extension == ".IDL" )
{
if ( ( module.type == RpcServer ) || ( module.type == RpcClient ) )
- GetWidlObjectDependencies ( dependencies, sourceFile );
+ GetWidlObjectDependencies ( dependencies, &sourceFile );
}
- delete sourceFile;
}
}
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationun…
==============================================================================
--- trunk/reactos/tools/rbuild/compilationunit.cpp (original)
+++ trunk/reactos/tools/rbuild/compilationunit.cpp Fri Jan 11 12:09:49 2008
@@ -23,12 +23,15 @@
using std::string;
using std::vector;
-CompilationUnit::CompilationUnit ( File* file )
+CompilationUnit::CompilationUnit ( const File* file )
: project(NULL),
module(NULL),
node(NULL)
{
- local_name = file->file.name;
+ default_name = new FileLocation ( IntermediateDirectory,
+ "",
+ file->file.name );
+
name = file->file.relative_path + sSep + file->file.name;
files.push_back ( file );
}
@@ -42,7 +45,11 @@
{
const XMLAttribute* att = node->GetAttribute ( "name", true );
assert(att);
- local_name = att->value;
+
+ default_name = new FileLocation ( IntermediateDirectory,
+ module ? module->output->relative_path :
"",
+ att->value,
+ node );
name = module->output->relative_path + cSep + att->value;
}
@@ -58,7 +65,7 @@
{
size_t i;
for ( i = 0; i < files.size (); i++ )
- files[i]->ProcessXML ();
+ const_cast<File*> ( files[i] )->ProcessXML ();
}
bool
@@ -66,7 +73,7 @@
{
if ( files.size () != 1 )
return false;
- File* file = files[0];
+ const File* file = files[0];
string extension = GetExtension ( file->file );
return ( extension == ".spec" || extension == ".SPEC" || extension
== ".mc" || extension == ".MC");
}
@@ -77,7 +84,7 @@
size_t i;
for ( i = 0; i < files.size (); i++ )
{
- File& file = *files[i];
+ const File& file = *files[i];
string fileExtension = GetExtension ( file.file );
if ( !stricmp ( fileExtension.c_str (), extension.c_str () ) )
return true;
@@ -90,31 +97,39 @@
{
if ( files.size () == 0 || files.size () > 1 )
return false;
- File* file = files[0];
+ const File* file = files[0];
return file->first;
}
-const FileLocation*
+const FileLocation&
CompilationUnit::GetFilename () const
{
if ( files.size () == 0 || files.size () > 1 )
- {
- return new FileLocation ( IntermediateDirectory,
- module ? module->output->relative_path : "",
- local_name,
- node );
- }
+ return *default_name;
- File* file = files[0];
- return new FileLocation ( file->file );
+ const File* file = files[0];
+ return file->file;
}
-std::string
+const std::string&
CompilationUnit::GetSwitches () const
{
+ static const std::string empty_string = std::string("");
if ( files.size () == 0 || files.size () > 1 )
- return "";
- File* file = files[0];
+ return empty_string;
+ const File* file = files[0];
return file->switches;
}
+
+void
+CompilationUnit::AddFile ( const File * file )
+{
+ files.push_back ( file );
+}
+
+const std::vector<const File*>
+CompilationUnit::GetFiles () const
+{
+ return files;
+}
Modified: trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationun…
==============================================================================
--- trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp (original)
+++ trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp Fri Jan 11 12:09:49 2008
@@ -55,7 +55,7 @@
for ( size_t i = 0; i < module.non_if_data.compilationUnits.size () ; i++ )
{
CompilationUnit& compilationUnit = *module.non_if_data.compilationUnits[i];
- if ( compilationUnit.files.size () <= 1 )
+ if ( compilationUnit.GetFiles ().size () <= 1 )
continue;
WriteCompilationUnitFile ( module, compilationUnit );
}
@@ -83,9 +83,9 @@
s = s + sprintf ( s, "/* This file is automatically generated. */\n" );
s = s + sprintf ( s, "#define ONE_COMPILATION_UNIT\n" );
- for ( size_t i = 0; i < compilationUnit.files.size () ; i++ )
+ for ( size_t i = 0; i < compilationUnit.GetFiles ().size () ; i++ )
{
- File& file = *compilationUnit.files[i];
+ const File& file = *compilationUnit.GetFiles ()[i];
s = s + sprintf ( s, "#include <%s/%s>\n", ChangeSeparator (
file.file.relative_path, '\\', '/' ).c_str (), file.file.name.c_str () );
}
Modified: trunk/reactos/tools/rbuild/module.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?re…
==============================================================================
--- trunk/reactos/tools/rbuild/module.cpp (original)
+++ trunk/reactos/tools/rbuild/module.cpp Fri Jan 11 12:09:49 2008
@@ -585,7 +585,7 @@
switches,
false );
if ( parseContext.compilationUnit )
- parseContext.compilationUnit->files.push_back ( pFile );
+ parseContext.compilationUnit->AddFile ( pFile );
else
{
CompilationUnit* pCompilationUnit = new CompilationUnit ( pFile );
Modified: trunk/reactos/tools/rbuild/rbuild.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=…
==============================================================================
--- trunk/reactos/tools/rbuild/rbuild.h (original)
+++ trunk/reactos/tools/rbuild/rbuild.h Fri Jan 11 12:09:49 2008
@@ -895,13 +895,9 @@
class CompilationUnit
{
public:
- const Project* project;
- const Module* module;
- const XMLElement* node;
std::string name;
- std::vector<File*> files;
-
- CompilationUnit ( File* file );
+
+ CompilationUnit ( const File* file );
CompilationUnit ( const Project* project,
const Module* module,
const XMLElement* node );
@@ -910,10 +906,16 @@
bool IsGeneratedFile () const;
bool HasFileWithExtension ( const std::string& extension ) const;
bool IsFirstFile () const;
- const FileLocation* GetFilename () const;
- std::string GetSwitches () const;
-private:
- std::string local_name;
+ const FileLocation& GetFilename () const;
+ const std::string& GetSwitches () const;
+ void AddFile ( const File * file );
+ const std::vector<const File*> GetFiles () const;
+private:
+ const Project* project;
+ const Module* module;
+ const XMLElement* node;
+ std::vector<const File*> files;
+ FileLocation *default_name;
};
Modified: trunk/reactos/tools/rbuild/testsupportcode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/testsupportco…
==============================================================================
--- trunk/reactos/tools/rbuild/testsupportcode.cpp (original)
+++ trunk/reactos/tools/rbuild/testsupportcode.cpp Fri Jan 11 12:09:49 2008
@@ -307,8 +307,8 @@
const vector<CompilationUnit*>& compilationUnits =
module.non_if_data.compilationUnits;
for ( i = 0; i < compilationUnits.size (); i++ )
{
- const FileLocation* sourceFileLocation = compilationUnits[i]->GetFilename ();
- string filename = sourceFileLocation->relative_path + sSep +
sourceFileLocation->name;
+ const FileLocation& sourceFileLocation = compilationUnits[i]->GetFilename ();
+ string filename = sourceFileLocation.relative_path + sSep + sourceFileLocation.name;
if ( !compilationUnits[i]->IsGeneratedFile () && IsTestFile ( filename ) )
list.push_back ( filename );
}
@@ -327,8 +327,8 @@
for ( j = 0; j < compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit = *compilationUnits[j];
- const FileLocation* sourceFileLocation = compilationUnits[j]->GetFilename ();
- string filename = sourceFileLocation->relative_path + sSep +
sourceFileLocation->name;
+ const FileLocation& sourceFileLocation = compilationUnits[j]->GetFilename ();
+ string filename = sourceFileLocation.relative_path + sSep + sourceFileLocation.name;
if ( !compilationUnit.IsGeneratedFile () && IsTestFile ( filename ) )
list.push_back ( filename );
}