//
// module
//
void
GeneratorVC7::doModule(IR__::ModuleDef_ptr module)
{
    // contained modules
    handleModule(module);

    // contained compositions
    handleComposition(repository_);
}
bool ModuleListInstance::replaceProjectFileContents(const QString& file)
{
    clearWrittenFlags();

    QStringList doc;
    QFile srcFile(file);
    int stage = 0;

    if(srcFile.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        while(!srcFile.atEnd())
        {
            QString text = srcFile.readLine();
            QString strippedText = text.simplified();

            if(!strippedText.startsWith("//"))
            {
                if(text.contains("Torque3D::beginConfig(", Qt::CaseInsensitive))
                {
                    // We need to have written all move classes and module paths by now
                    writeUnhandledMoveClasses(doc);
                    writeUnhandledModulePaths(doc);

                    // Now write out the beginConfig() line
                    doc << text;

                    // Next stage
                    stage = 1;
                }
                else if(text.contains("Torque3D::endConfig(", Qt::CaseInsensitive))
                {
                    // We need to have written all modules by now
                    writeUnhandledModules(doc);
                    writeUnhandledProjectDefines(doc);

                    // Now write out the endConfig() line
                    doc << text;

                    // Next stage
                    stage = 2;
                }
                else if(stage == 0 && strippedText.startsWith("$"))
                {
                    // Prior to the beginConfig() stage.  Here we may find move classes and module paths.
                    bool handled = false;

                    // Start by checking for a move class
                    handled = handleMoveClass(text);

                    // Should we try to handle a module path?
                    if(!handled)
                    {
                        handled = handleModulePath(text);
                    }

                    doc << text;
                }
                else if(stage == 1 && text.contains("includeModule("))
                {
                    // Deal with the module
                    handleModule(doc, text);
                }
                else if(stage == 1 && text.contains("addProjectDefine("))
                {
                    // Deal with the project define
                    handleProjectDefine(doc, text);
                }
                else
                {
                    // Just write out the line
                    doc << text;
                }
            }
            else
            {
                doc << text;
            }
        }

        srcFile.close();
    }
    else
    {
        return false;
    }

    // Write out the new file
    if(srcFile.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        for(int i=0; i<doc.count(); ++i)
        {
            srcFile.write(doc.at(i).toLocal8Bit());
        }

        srcFile.close();
    }
    else
    {
        return false;
    }

    return true;
}