use enum instead of string in more places
authorRoyce Mitchell III <royce3@ev1.net>
Sun, 9 Jan 2005 03:43:26 +0000 (03:43 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Sun, 9 Jan 2005 03:43:26 +0000 (03:43 +0000)
svn path=/branches/xmlbuildsystem/; revision=12902

reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/exception.cpp
reactos/tools/rbuild/exception.h
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h

index 423c4f6..1edd292 100644 (file)
@@ -92,7 +92,7 @@ MingwBackend::ProcessModule ( Module& module )
 {\r
        MingwModuleHandler* h = MingwModuleHandler::LookupHandler (\r
                module.node.location,\r
-               module.stype );\r
+               module.type );\r
        h->Process ( module );\r
 }\r
 \r
index bf89db3..e337417 100644 (file)
@@ -10,18 +10,16 @@ using std::string;
 using std::vector;\r
 using std::map;\r
 \r
-map<string,MingwModuleHandler*>*\r
+map<ModuleType,MingwModuleHandler*>*\r
 MingwModuleHandler::handler_map = NULL;\r
 \r
 FILE*\r
 MingwModuleHandler::fMakefile = NULL;\r
 \r
-MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ )\r
+MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )\r
 {\r
-       string moduletype ( moduletype_ );\r
-       strlwr ( &moduletype[0] );\r
        if ( !handler_map )\r
-               handler_map = new map<string,MingwModuleHandler*>;\r
+               handler_map = new map<ModuleType,MingwModuleHandler*>;\r
        (*handler_map)[moduletype] = this;\r
 }\r
 \r
@@ -33,10 +31,8 @@ MingwModuleHandler::SetMakefile ( FILE* f )
 \r
 /*static*/ MingwModuleHandler*\r
 MingwModuleHandler::LookupHandler ( const string& location,\r
-                                    const string& moduletype_ )\r
+                                    ModuleType moduletype )\r
 {\r
-       string moduletype ( moduletype_ );\r
-       strlwr ( &moduletype[0] );\r
        if ( !handler_map )\r
                throw Exception ( "internal tool error: no registered module handlers" );\r
        MingwModuleHandler* h = (*handler_map)[moduletype];\r
@@ -386,7 +382,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const
        {\r
                const Invoke& invoke = *module.invocations[i];\r
 \r
-               if ( invoke.invokeModule->etype != BuildTool )\r
+               if ( invoke.invokeModule->type != BuildTool )\r
                        throw InvalidBuildFileException ( module.node.location,\r
                                                      "Only modules of type buildtool can be invoked." );\r
 \r
@@ -446,7 +442,7 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
 static MingwBuildToolModuleHandler buildtool_handler;\r
 \r
 MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()\r
-       : MingwModuleHandler ( "buildtool" )\r
+       : MingwModuleHandler ( BuildTool )\r
 {\r
 }\r
 \r
@@ -477,7 +473,7 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
 static MingwKernelModuleHandler kernelmodule_handler;\r
 \r
 MingwKernelModuleHandler::MingwKernelModuleHandler ()\r
-       : MingwModuleHandler ( "kernelmodedll" )\r
+       : MingwModuleHandler ( KernelModeDLL )\r
 {\r
 }\r
 \r
@@ -539,7 +535,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
 static MingwStaticLibraryModuleHandler staticlibrary_handler;\r
 \r
 MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()\r
-       : MingwModuleHandler ( "staticlibrary" )\r
+       : MingwModuleHandler ( StaticLibrary )\r
 {\r
 }\r
 \r
index bd48398..36f5a55 100644 (file)
@@ -6,14 +6,14 @@
 class MingwModuleHandler\r
 {\r
 public:\r
-       static std::map<std::string,MingwModuleHandler*>* handler_map;\r
+       static std::map<ModuleType,MingwModuleHandler*>* handler_map;\r
 \r
-       MingwModuleHandler ( const char* moduletype_ );\r
+       MingwModuleHandler ( ModuleType moduletype );\r
        virtual ~MingwModuleHandler() {}\r
 \r
        static void SetMakefile ( FILE* f );\r
        static MingwModuleHandler* LookupHandler ( const std::string& location,\r
-                                                  const std::string& moduletype_ );\r
+                                                  ModuleType moduletype_ );\r
        virtual void Process ( const Module& module ) = 0;\r
 \r
 protected:\r
index b897fdf..99df90e 100644 (file)
@@ -130,9 +130,9 @@ UnknownBackendException::UnknownBackendException ( const string& name )
 }\r
 \r
 UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,\r
-                                                         const string& moduletype )\r
+                                                         int moduletype )\r
        : InvalidBuildFileException ( location,\r
-                                     "module type requested: '%s'",\r
-                                     moduletype.c_str() )\r
+                                     "module type requested: %i",\r
+                                     moduletype )\r
 {\r
 }\r
index 8c434a7..465d300 100644 (file)
@@ -98,7 +98,7 @@ class UnknownModuleTypeException : public InvalidBuildFileException
 {\r
 public:\r
        UnknownModuleTypeException ( const std::string& location,\r
-                                    const std::string& moduletype );\r
+                                    int moduletype );\r
 };\r
 \r
 #endif /* __EXCEPTION_H */\r
index e8ea879..a569cdc 100644 (file)
@@ -38,9 +38,7 @@ Module::Module ( const Project& project,
 \r
        att = moduleNode.GetAttribute ( "type", true );\r
        assert(att);\r
-       stype = att->value;\r
-       strlwr ( &stype[0] );\r
-       etype = GetModuleType ( node.location, *att );\r
+       type = GetModuleType ( node.location, *att );\r
 \r
        att = moduleNode.GetAttribute ( "extension", false );\r
        if (att != NULL)\r
@@ -154,7 +152,7 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
 string\r
 Module::GetDefaultModuleExtension () const\r
 {\r
-       switch (etype)\r
+       switch (type)\r
        {\r
                case BuildTool:\r
                        return EXEPOSTFIX;\r
index 7124552..1407a84 100644 (file)
@@ -71,8 +71,7 @@ public:
        std::string name;\r
        std::string extension;\r
        std::string path;\r
-       ModuleType etype;\r
-       std::string stype;\r
+       ModuleType type;\r
        std::vector<File*> files;\r
        std::vector<Library*> libraries;\r
        std::vector<Include*> includes;\r