Revert 19411
[reactos.git] / reactos / tools / rbuild / module.cpp
index 3333f26..1b5644b 100644 (file)
@@ -182,22 +182,20 @@ GetBooleanValue ( const string& value )
 IfableData::~IfableData()
 {
        size_t i;
-       for ( i = 0; i < files.size (); i++ )
+       for ( i = 0; i < files.size(); i++ )
                delete files[i];
-       for ( i = 0; i < includes.size (); i++ )
+       for ( i = 0; i < includes.size(); i++ )
                delete includes[i];
-       for ( i = 0; i < defines.size (); i++ )
+       for ( i = 0; i < defines.size(); i++ )
                delete defines[i];
-       for ( i = 0; i < libraries.size (); i++ )
+       for ( i = 0; i < libraries.size(); i++ )
                delete libraries[i];
-       for ( i = 0; i < properties.size (); i++ )
+       for ( i = 0; i < properties.size(); i++ )
                delete properties[i];
-       for ( i = 0; i < compilerFlags.size (); i++ )
+       for ( i = 0; i < compilerFlags.size(); i++ )
                delete compilerFlags[i];
-       for ( i = 0; i < ifs.size (); i++ )
+       for ( i = 0; i < ifs.size(); i++ )
                delete ifs[i];
-       for ( i = 0; i < compilationUnits.size (); i++ )
-               delete compilationUnits[i];
 }
 
 void IfableData::ProcessXML ()
@@ -217,8 +215,6 @@ void IfableData::ProcessXML ()
                compilerFlags[i]->ProcessXML ();
        for ( i = 0; i < ifs.size (); i++ )
                ifs[i]->ProcessXML ();
-       for ( i = 0; i < compilationUnits.size (); i++ )
-               compilationUnits[i]->ProcessXML ();
 }
 
 Module::Module ( const Project& project,
@@ -417,10 +413,7 @@ Module::ProcessXML()
 
        size_t i;
        for ( i = 0; i < node.subElements.size(); i++ )
-       {
-               ParseContext parseContext;
-               ProcessXMLSubElement ( *node.subElements[i], path, parseContext );
-       }
+               ProcessXMLSubElement ( *node.subElements[i], path );
        for ( i = 0; i < invocations.size(); i++ )
                invocations[i]->ProcessXML ();
        for ( i = 0; i < dependencies.size(); i++ )
@@ -441,7 +434,7 @@ Module::ProcessXML()
 void
 Module::ProcessXMLSubElement ( const XMLElement& e,
                                const string& path,
-                               ParseContext& parseContext )
+                               If* pIf /*= NULL*/ )
 {
        bool subs_invalid = false;
        string subpath ( path );
@@ -477,19 +470,17 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                                         first,
                                         switches,
                                         false );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.files.push_back ( pFile );
+               if ( pIf )
+                       pIf->data.files.push_back ( pFile );
                else
                        non_if_data.files.push_back ( pFile );
-               if ( parseContext.compilationUnit )
-                       parseContext.compilationUnit->files.push_back ( pFile );
                subs_invalid = true;
        }
        else if ( e.name == "library" && e.value.size () )
        {
                Library* pLibrary = new Library ( e, *this, e.value );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.libraries.push_back ( pLibrary );
+               if ( pIf )
+                       pIf->data.libraries.push_back ( pLibrary );
                else
                        non_if_data.libraries.push_back ( pLibrary );
                subs_invalid = true;
@@ -503,8 +494,8 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        else if ( e.name == "include" )
        {
                Include* include = new Include ( project, this, &e );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.includes.push_back ( include );
+               if ( pIf )
+                       pIf->data.includes.push_back ( include );
                else
                        non_if_data.includes.push_back ( include );
                subs_invalid = true;
@@ -512,15 +503,15 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        else if ( e.name == "define" )
        {
                Define* pDefine = new Define ( project, this, e );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.defines.push_back ( pDefine );
+               if ( pIf )
+                       pIf->data.defines.push_back ( pDefine );
                else
                        non_if_data.defines.push_back ( pDefine );
                subs_invalid = true;
        }
        else if ( e.name == "invoke" )
        {
-               if ( parseContext.ifData )
+               if ( pIf )
                        throw InvalidBuildFileException (
                                e.location,
                                "<invoke> is not a valid sub-element of <if>" );
@@ -529,7 +520,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }
        else if ( e.name == "dependency" )
        {
-               if ( parseContext.ifData )
+               if ( pIf )
                        throw InvalidBuildFileException (
                                e.location,
                                "<dependency> is not a valid sub-element of <if>" );
@@ -538,7 +529,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }
        else if ( e.name == "importlibrary" )
        {
-               if ( parseContext.ifData )
+               if ( pIf )
                        throw InvalidBuildFileException (
                                e.location,
                                "<importlibrary> is not a valid sub-element of <if>" );
@@ -551,29 +542,29 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }
        else if ( e.name == "if" )
        {
-               If* pOldIf = parseContext.ifData;
-               parseContext.ifData = new If ( e, project, this );
+               If* pOldIf = pIf;
+               pIf = new If ( e, project, this );
                if ( pOldIf )
-                       pOldIf->data.ifs.push_back ( parseContext.ifData );
+                       pOldIf->data.ifs.push_back ( pIf );
                else
-                       non_if_data.ifs.push_back ( parseContext.ifData );
+                       non_if_data.ifs.push_back ( pIf );
                subs_invalid = false;
        }
        else if ( e.name == "ifnot" )
        {
-               If* pOldIf = parseContext.ifData;
-               parseContext.ifData = new If ( e, project, this, true );
+               If* pOldIf = pIf;
+               pIf = new If ( e, project, this, true );
                if ( pOldIf )
-                       pOldIf->data.ifs.push_back ( parseContext.ifData );
+                       pOldIf->data.ifs.push_back ( pIf );
                else
-                       non_if_data.ifs.push_back ( parseContext.ifData );
+                       non_if_data.ifs.push_back ( pIf );
                subs_invalid = false;
        }
        else if ( e.name == "compilerflag" )
        {
                CompilerFlag* pCompilerFlag = new CompilerFlag ( project, this, e );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.compilerFlags.push_back ( pCompilerFlag );
+               if ( pIf )
+                       pIf->data.compilerFlags.push_back ( pCompilerFlag );
                else
                        non_if_data.compilerFlags.push_back ( pCompilerFlag );
                subs_invalid = true;
@@ -610,7 +601,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        }
        else if ( e.name == "pch" )
        {
-               if ( parseContext.ifData )
+               if ( pIf )
                        throw InvalidBuildFileException (
                                e.location,
                                "<pch> is not a valid sub-element of <if>" );
@@ -622,23 +613,13 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                        e, *this, File ( FixSeparator ( path + cSep + e.value ), false, "", true ) );
                subs_invalid = true;
        }
-       else if ( e.name == "compilationunit" )
-       {
-               CompilationUnit* pCompilationUnit = new CompilationUnit ( project, this, e );
-               if ( parseContext.ifData )
-                       parseContext.ifData->data.compilationUnits.push_back ( pCompilationUnit );
-               else
-                       non_if_data.compilationUnits.push_back ( pCompilationUnit );
-               parseContext.compilationUnit = pCompilationUnit;
-               subs_invalid = false;
-       }
        if ( subs_invalid && e.subElements.size() > 0 )
                throw InvalidBuildFileException (
                        e.location,
                        "<%s> cannot have sub-elements",
                        e.name.c_str() );
        for ( size_t i = 0; i < e.subElements.size (); i++ )
-               ProcessXMLSubElement ( *e.subElements[i], subpath, parseContext );
+               ProcessXMLSubElement ( *e.subElements[i], subpath, pIf );
 }
 
 ModuleType