Prevent some FileLocation copies (in LinkerScript and PchFile classes)

svn path=/trunk/; revision=32593
This commit is contained in:
Hervé Poussineau 2008-03-07 08:16:26 +00:00
parent 57640e2c83
commit 6e49f8efc8
7 changed files with 24 additions and 17 deletions

View file

@ -301,7 +301,7 @@ AutomaticDependency::GetModuleFiles ( const Module& module,
if ( module.pch != NULL ) if ( module.pch != NULL )
{ {
const FileLocation& pch = module.pch->file; const FileLocation& pch = *module.pch->file;
File *file = new File ( pch.directory, pch.relative_path, pch.name , false, "", true ); File *file = new File ( pch.directory, pch.relative_path, pch.name , false, "", true );
files.push_back ( file ); files.push_back ( file );
} }

View file

@ -399,7 +399,7 @@ CBBackend::_generate_cbproj ( const Module& module )
if ( module.pch != NULL ) if ( module.pch != NULL )
{ {
string pch_path = Path::RelativeFromDirectory ( string pch_path = Path::RelativeFromDirectory (
module.pch->file.name, module.pch->file->name,
module.output->relative_path ); module.output->relative_path );
header_files.push_back ( pch_path ); header_files.push_back ( pch_path );

View file

@ -1236,8 +1236,8 @@ MingwModuleHandler::GetPrecompiledHeaderFilename () const
if ( !module.pch || !use_pch ) if ( !module.pch || !use_pch )
return NULL; return NULL;
return new FileLocation ( IntermediateDirectory, return new FileLocation ( IntermediateDirectory,
module.pch->file.relative_path, module.pch->file->relative_path,
ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) ); ReplaceExtension ( module.pch->file->name, "_" + module.name + ".gch" ) );
} }
Rule arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n", Rule arRule1 ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).a: $($(module_name)_OBJS) | $(INTERMEDIATE)$(SEP)$(source_dir)\n",
@ -1649,7 +1649,7 @@ MingwModuleHandler::GenerateLinkerCommand (
string linkerScriptArgument; string linkerScriptArgument;
if ( module.linkerScript != NULL ) if ( module.linkerScript != NULL )
linkerScriptArgument = ssprintf ( " -Wl,-T,%s", backend->GetFullName ( module.linkerScript->file ).c_str () ); linkerScriptArgument = ssprintf ( " -Wl,-T,%s", backend->GetFullName ( *module.linkerScript->file ).c_str () );
else else
linkerScriptArgument = ""; linkerScriptArgument = "";
@ -1807,7 +1807,7 @@ MingwModuleHandler::GenerateObjectFileTargets ()
string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" ); string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" );
string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" ); string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" );
const FileLocation& baseHeaderFile = module.pch->file; const FileLocation& baseHeaderFile = *module.pch->file;
CLEAN_FILE ( *pchFilename ); CLEAN_FILE ( *pchFilename );
string dependencies = backend->GetFullName ( baseHeaderFile ); string dependencies = backend->GetFullName ( baseHeaderFile );
/* WIDL generated headers may be used */ /* WIDL generated headers may be used */

View file

@ -427,7 +427,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
{ {
fprintf ( OUT, "\t\t\t\tUsePrecompiledHeader=\"2\"\r\n" ); fprintf ( OUT, "\t\t\t\tUsePrecompiledHeader=\"2\"\r\n" );
string pch_path = Path::RelativeFromDirectory ( string pch_path = Path::RelativeFromDirectory (
module.pch->file.name, module.pch->file->name,
module.output->relative_path ); module.output->relative_path );
string::size_type pos = pch_path.find_last_of ("/"); string::size_type pos = pch_path.find_last_of ("/");
if ( pos != string::npos ) if ( pos != string::npos )

View file

@ -22,13 +22,14 @@
LinkerScript::LinkerScript ( const XMLElement& node_, LinkerScript::LinkerScript ( const XMLElement& node_,
const Module& module_, const Module& module_,
const FileLocation& file_ ) const FileLocation *file_ )
: node(node_), module(module_), file(file_) : node(node_), module(module_), file(file_)
{ {
} }
LinkerScript::~LinkerScript () LinkerScript::~LinkerScript ()
{ {
delete file;
} }
void void

View file

@ -779,14 +779,14 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
if ( pos == string::npos ) if ( pos == string::npos )
{ {
linkerScript = new LinkerScript ( linkerScript = new LinkerScript (
e, *this, FileLocation ( SourceDirectory, relative_path, e.value, &e ) ); e, *this, new FileLocation ( SourceDirectory, relative_path, e.value, &e ) );
} }
else else
{ {
string dir = e.value.substr ( 0, pos ); string dir = e.value.substr ( 0, pos );
string name = e.value.substr ( pos + 1); string name = e.value.substr ( pos + 1);
linkerScript = new LinkerScript ( linkerScript = new LinkerScript (
e, *this, FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) ); e, *this, new FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) );
} }
subs_invalid = true; subs_invalid = true;
} }
@ -824,14 +824,14 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
if ( pos == string::npos ) if ( pos == string::npos )
{ {
pch = new PchFile ( pch = new PchFile (
e, *this, FileLocation ( SourceDirectory, relative_path, e.value, &e ) ); e, *this, new FileLocation ( SourceDirectory, relative_path, e.value, &e ) );
} }
else else
{ {
string dir = e.value.substr ( 0, pos ); string dir = e.value.substr ( 0, pos );
string name = e.value.substr ( pos + 1); string name = e.value.substr ( pos + 1);
pch = new PchFile ( pch = new PchFile (
e, *this, FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) ); e, *this, new FileLocation ( SourceDirectory, relative_path + sSep + dir, name, &e ) );
} }
subs_invalid = true; subs_invalid = true;
} }
@ -1704,11 +1704,16 @@ Property::ProcessXML()
PchFile::PchFile ( PchFile::PchFile (
const XMLElement& node_, const XMLElement& node_,
const Module& module_, const Module& module_,
const FileLocation& file_ ) const FileLocation *file_ )
: node(node_), module(module_), file(file_) : node(node_), module(module_), file(file_)
{ {
} }
PchFile::~PchFile()
{
delete file;
}
void void
PchFile::ProcessXML() PchFile::ProcessXML()
{ {

View file

@ -639,11 +639,11 @@ class LinkerScript
public: public:
const XMLElement& node; const XMLElement& node;
const Module& module; const Module& module;
FileLocation file; const FileLocation *file;
LinkerScript ( const XMLElement& node, LinkerScript ( const XMLElement& node,
const Module& module, const Module& module,
const FileLocation& file ); const FileLocation *file );
~LinkerScript (); ~LinkerScript ();
void ProcessXML(); void ProcessXML();
}; };
@ -843,12 +843,13 @@ class PchFile
public: public:
const XMLElement& node; const XMLElement& node;
const Module& module; const Module& module;
FileLocation file; const FileLocation *file;
PchFile ( PchFile (
const XMLElement& node, const XMLElement& node,
const Module& module, const Module& module,
const FileLocation& file ); const FileLocation *file );
~PchFile();
void ProcessXML(); void ProcessXML();
}; };