Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-06 02:55:11 UTC (rev 12845)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp 2005-01-06 03:27:24 UTC (rev 12846)
@@ -9,25 +9,29 @@
using std::string;
using std::vector;
-vector<Backend::Factory*> Backend::factories;
+vector<Backend::Factory*>* Backend::Factory::factories = NULL;
-/*static*/ void
-Backend::InitFactories()
+Backend::Factory::Factory ( const std::string& name_ )
+ : name(name_)
{
- factories.push_back ( new Factory ( "mingw", MingwBackend::Factory ) );
+ if ( !factories )
+ factories = new vector<Factory*>;
+ factories->push_back ( this );
}
/*static*/ Backend*
-Backend::Create ( const std::string& name, Project& project )
+Backend::Factory::Create ( const std::string& name, Project& project )
{
string sname ( name );
strlwr ( &sname[0] );
- if ( !factories.size() )
+ if ( !factories || !factories->size() )
throw Exception ( "internal tool error: no registered factories" );
- for ( size_t i = 0; i < factories.size(); i++ )
+ vector<Backend::Factory*>& fact = *factories;
+ for ( size_t i = 0; i < fact.size(); i++ )
{
- if ( sname == factories[i]->name )
- return (factories[i]->factory) ( project );
+ //char* p = *fact[i];
+ if ( sname == fact[i]->name )
+ return (*fact[i]) ( project );
}
throw UnknownBackendException ( sname );
return NULL;
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-06 02:55:11 UTC (rev 12845)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h 2005-01-06 03:27:24 UTC (rev 12846)
@@ -9,24 +9,24 @@
class Backend
{
+public:
class Factory
{
- public:
+ static std::vector<Factory*>* factories;
std::string name;
- BackendFactory* factory;
- Factory ( const std::string& name_, BackendFactory* factory_ )
- : name(name_), factory(factory_)
- {
- }
- };
+ protected:
- static std::vector<Factory*> factories;
+ Factory ( const std::string& name_ );
-public:
- static void InitFactories();
- static Backend* Create ( const std::string& name, Project& project );
+ virtual Backend* operator() ( Project& ) = 0;
+ public:
+ static Backend* Create ( const std::string& name, Project& project );
+
+ private:
+ };
+
protected:
Backend ( Project& project );
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-06 02:55:11 UTC (rev 12845)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-06 03:27:24 UTC (rev 12846)
@@ -6,11 +6,15 @@
using std::string;
using std::vector;
-Backend*
-MingwBackend::Factory ( Project& project )
+static class MingwFactory : public Backend::Factory
{
- return new MingwBackend ( project );
-}
+public:
+ MingwFactory() : Factory ( "mingw" ) {}
+ Backend* operator() ( Project& project )
+ {
+ return new MingwBackend ( project );
+ }
+} factory;
#ifdef WIN32
#define EXEPOSTFIX ".exe"
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-01-06 02:55:11 UTC (rev 12845)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-01-06 03:27:24 UTC (rev 12846)
@@ -20,10 +20,7 @@
class MingwBackend : public Backend
{
public:
- static Backend* Factory ( Project& project );
-protected:
MingwBackend ( Project& project );
-public:
virtual void Process ();
private:
void ProcessModule ( Module& module );
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp 2005-01-06 02:55:11 UTC (rev 12845)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp 2005-01-06 03:27:24 UTC (rev 12846)
@@ -17,7 +17,6 @@
int
main ( int argc, char** argv )
{
- Backend::InitFactories();
if ( argc != 2 )
{
printf ( "syntax: rbuild {buildtarget}\n" );
@@ -29,7 +28,7 @@
{
string projectFilename ( "ReactOS.xml" );
Project project ( projectFilename );
- Backend* backend = Backend::Create ( buildtarget, project );
+ Backend* backend = Backend::Factory::Create ( buildtarget, project );
backend->Process ();
delete backend;