Add an 'overridable' attribute on defines.

Suggestion by Marc Piulachs

svn path=/trunk/; revision=29684
This commit is contained in:
Hervé Poussineau 2007-10-19 15:06:11 +00:00
parent 29cfc91618
commit f33633bbf7
4 changed files with 32 additions and 11 deletions

View file

@ -813,25 +813,35 @@ MingwModuleHandler::GenerateMacro (
}
for ( i = 0; i < data.defines.size(); i++ )
{
const Define& d = *data.defines[i];
if (used_defs && used_defs->find(d.name) != used_defs->end())
const Define& define = *data.defines[i];
if ( used_defs && used_defs->find ( define.name ) != used_defs->end () )
{
#if 0 /* FIXME: activate */
if ( !define.overridable )
{
throw InvalidOperationException ( __FILE__,
__LINE__,
"Invalid override of define '%s' in '%s'",
define.name.c_str (),
module.name.c_str () );
}
#endif
if ( backend->configuration.Verbose )
printf("%s define overridden in '%s' module\n",
d.name.c_str (), module.name.c_str () );
define.name.c_str (), module.name.c_str () );
continue;
}
fprintf (
fMakefile,
" -D%s",
d.name.c_str() );
if ( d.value.size() )
define.name.c_str() );
if ( define.value.size() )
fprintf (
fMakefile,
"=%s",
d.value.c_str() );
if (used_defs)
used_defs->insert(used_defs->begin(), d.name);
define.value.c_str() );
if ( used_defs )
used_defs->insert(used_defs->begin(), define.name);
}
if ( generateAssignment )
{

View file

@ -63,12 +63,21 @@ void
Define::Initialize()
{
const XMLAttribute* att = node->GetAttribute ( "name", true );
const XMLAttribute* bck = node->GetAttribute ( "backend", false );
att = node->GetAttribute ( "name", true );
assert(att);
name = att->value;
value = node->value;
if ( bck )
backend = bck->value;
att = node->GetAttribute ( "backend", false );
if ( att )
backend = att->value;
att = node->GetAttribute ( "overridable", false );
if ( att )
overridable = ( att->value == "true" || att->value == "yes" );
else
overridable = false;
}
void

View file

@ -37,6 +37,7 @@
<!ELEMENT define (#PCDATA)>
<!ATTLIST define
name %CIdentifier; #REQUIRED
overridable (true) #IMPLIED
>
<!ELEMENT directory (compilationunit*|directory*|group*|cdfile|file*|if*|ifnot*|module+|pch*|xi:include*)+>

View file

@ -426,6 +426,7 @@ public:
std::string name;
std::string value;
std::string backend;
bool overridable;
Define ( const Project& project,
const XMLElement& defineNode );