use enum instead of string in more places

svn path=/branches/xmlbuildsystem/; revision=12902
This commit is contained in:
Royce Mitchell III 2005-01-09 03:43:26 +00:00
parent 03e6c98e63
commit d16f78506a
7 changed files with 19 additions and 26 deletions

View file

@ -92,7 +92,7 @@ MingwBackend::ProcessModule ( Module& module )
{ {
MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( MingwModuleHandler* h = MingwModuleHandler::LookupHandler (
module.node.location, module.node.location,
module.stype ); module.type );
h->Process ( module ); h->Process ( module );
} }

View file

@ -10,18 +10,16 @@ using std::string;
using std::vector; using std::vector;
using std::map; using std::map;
map<string,MingwModuleHandler*>* map<ModuleType,MingwModuleHandler*>*
MingwModuleHandler::handler_map = NULL; MingwModuleHandler::handler_map = NULL;
FILE* FILE*
MingwModuleHandler::fMakefile = NULL; MingwModuleHandler::fMakefile = NULL;
MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ ) MingwModuleHandler::MingwModuleHandler ( ModuleType moduletype )
{ {
string moduletype ( moduletype_ );
strlwr ( &moduletype[0] );
if ( !handler_map ) if ( !handler_map )
handler_map = new map<string,MingwModuleHandler*>; handler_map = new map<ModuleType,MingwModuleHandler*>;
(*handler_map)[moduletype] = this; (*handler_map)[moduletype] = this;
} }
@ -33,10 +31,8 @@ MingwModuleHandler::SetMakefile ( FILE* f )
/*static*/ MingwModuleHandler* /*static*/ MingwModuleHandler*
MingwModuleHandler::LookupHandler ( const string& location, MingwModuleHandler::LookupHandler ( const string& location,
const string& moduletype_ ) ModuleType moduletype )
{ {
string moduletype ( moduletype_ );
strlwr ( &moduletype[0] );
if ( !handler_map ) if ( !handler_map )
throw Exception ( "internal tool error: no registered module handlers" ); throw Exception ( "internal tool error: no registered module handlers" );
MingwModuleHandler* h = (*handler_map)[moduletype]; MingwModuleHandler* h = (*handler_map)[moduletype];
@ -386,7 +382,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const
{ {
const Invoke& invoke = *module.invocations[i]; const Invoke& invoke = *module.invocations[i];
if ( invoke.invokeModule->etype != BuildTool ) if ( invoke.invokeModule->type != BuildTool )
throw InvalidBuildFileException ( module.node.location, throw InvalidBuildFileException ( module.node.location,
"Only modules of type buildtool can be invoked." ); "Only modules of type buildtool can be invoked." );
@ -446,7 +442,7 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
static MingwBuildToolModuleHandler buildtool_handler; static MingwBuildToolModuleHandler buildtool_handler;
MingwBuildToolModuleHandler::MingwBuildToolModuleHandler() MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
: MingwModuleHandler ( "buildtool" ) : MingwModuleHandler ( BuildTool )
{ {
} }
@ -477,7 +473,7 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
static MingwKernelModuleHandler kernelmodule_handler; static MingwKernelModuleHandler kernelmodule_handler;
MingwKernelModuleHandler::MingwKernelModuleHandler () MingwKernelModuleHandler::MingwKernelModuleHandler ()
: MingwModuleHandler ( "kernelmodedll" ) : MingwModuleHandler ( KernelModeDLL )
{ {
} }
@ -539,7 +535,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
static MingwStaticLibraryModuleHandler staticlibrary_handler; static MingwStaticLibraryModuleHandler staticlibrary_handler;
MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler () MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
: MingwModuleHandler ( "staticlibrary" ) : MingwModuleHandler ( StaticLibrary )
{ {
} }

View file

@ -6,14 +6,14 @@
class MingwModuleHandler class MingwModuleHandler
{ {
public: public:
static std::map<std::string,MingwModuleHandler*>* handler_map; static std::map<ModuleType,MingwModuleHandler*>* handler_map;
MingwModuleHandler ( const char* moduletype_ ); MingwModuleHandler ( ModuleType moduletype );
virtual ~MingwModuleHandler() {} virtual ~MingwModuleHandler() {}
static void SetMakefile ( FILE* f ); static void SetMakefile ( FILE* f );
static MingwModuleHandler* LookupHandler ( const std::string& location, static MingwModuleHandler* LookupHandler ( const std::string& location,
const std::string& moduletype_ ); ModuleType moduletype_ );
virtual void Process ( const Module& module ) = 0; virtual void Process ( const Module& module ) = 0;
protected: protected:

View file

@ -130,9 +130,9 @@ UnknownBackendException::UnknownBackendException ( const string& name )
} }
UnknownModuleTypeException::UnknownModuleTypeException ( const string& location, UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
const string& moduletype ) int moduletype )
: InvalidBuildFileException ( location, : InvalidBuildFileException ( location,
"module type requested: '%s'", "module type requested: %i",
moduletype.c_str() ) moduletype )
{ {
} }

View file

@ -98,7 +98,7 @@ class UnknownModuleTypeException : public InvalidBuildFileException
{ {
public: public:
UnknownModuleTypeException ( const std::string& location, UnknownModuleTypeException ( const std::string& location,
const std::string& moduletype ); int moduletype );
}; };
#endif /* __EXCEPTION_H */ #endif /* __EXCEPTION_H */

View file

@ -38,9 +38,7 @@ Module::Module ( const Project& project,
att = moduleNode.GetAttribute ( "type", true ); att = moduleNode.GetAttribute ( "type", true );
assert(att); assert(att);
stype = att->value; type = GetModuleType ( node.location, *att );
strlwr ( &stype[0] );
etype = GetModuleType ( node.location, *att );
att = moduleNode.GetAttribute ( "extension", false ); att = moduleNode.GetAttribute ( "extension", false );
if (att != NULL) if (att != NULL)
@ -154,7 +152,7 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
string string
Module::GetDefaultModuleExtension () const Module::GetDefaultModuleExtension () const
{ {
switch (etype) switch (type)
{ {
case BuildTool: case BuildTool:
return EXEPOSTFIX; return EXEPOSTFIX;

View file

@ -71,8 +71,7 @@ public:
std::string name; std::string name;
std::string extension; std::string extension;
std::string path; std::string path;
ModuleType etype; ModuleType type;
std::string stype;
std::vector<File*> files; std::vector<File*> files;
std::vector<Library*> libraries; std::vector<Library*> libraries;
std::vector<Include*> includes; std::vector<Include*> includes;