my own uncrustify run

This commit is contained in:
Rudolf Polzer
2012-03-27 12:03:21 +02:00
parent 203343b01a
commit e4287c28bb
1056 changed files with 194610 additions and 205971 deletions

View File

@@ -1,23 +1,22 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "moduleregistry.h"

View File

@@ -1,25 +1,25 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(INCLUDED_MODULESYSTEM_MODULEREGISTRY_H)
#if !defined( INCLUDED_MODULESYSTEM_MODULEREGISTRY_H )
#define INCLUDED_MODULESYSTEM_MODULEREGISTRY_H
#include "generic/static.h"
@@ -28,25 +28,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class ModuleRegisterable
{
public:
virtual void selfRegister() = 0;
virtual void selfRegister() = 0;
};
class ModuleRegistryList
{
typedef std::list<ModuleRegisterable*> RegisterableModules;
RegisterableModules m_modules;
typedef std::list<ModuleRegisterable*> RegisterableModules;
RegisterableModules m_modules;
public:
void addModule(ModuleRegisterable& module)
{
m_modules.push_back(&module);
}
void registerModules() const
{
for(RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i)
{
(*i)->selfRegister();
}
}
void addModule( ModuleRegisterable& module ){
m_modules.push_back( &module );
}
void registerModules() const {
for ( RegisterableModules::const_iterator i = m_modules.begin(); i != m_modules.end(); ++i )
{
( *i )->selfRegister();
}
}
};
typedef SmartStatic<ModuleRegistryList> StaticModuleRegistryList;
@@ -55,10 +53,9 @@ typedef SmartStatic<ModuleRegistryList> StaticModuleRegistryList;
class StaticRegisterModule : public StaticModuleRegistryList
{
public:
StaticRegisterModule(ModuleRegisterable& module)
{
StaticModuleRegistryList::instance().addModule(module);
}
StaticRegisterModule( ModuleRegisterable& module ){
StaticModuleRegistryList::instance().addModule( module );
}
};

View File

@@ -1,22 +1,22 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "modulesmap.h"

View File

@@ -1,25 +1,25 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(INCLUDED_MODULESYSTEM_MODULESMAP_H)
#if !defined( INCLUDED_MODULESYSTEM_MODULESMAP_H )
#define INCLUDED_MODULESYSTEM_MODULESMAP_H
#include "modulesystem.h"
@@ -30,123 +30,106 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
template<typename Type>
class ModulesMap : public Modules<Type>
{
typedef std::map<CopiedString, Module*> modules_t;
modules_t m_modules;
typedef std::map<CopiedString, Module*> modules_t;
modules_t m_modules;
public:
~ModulesMap()
{
for(modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i)
{
(*i).second->release();
}
}
~ModulesMap(){
for ( modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i )
{
( *i ).second->release();
}
}
typedef modules_t::const_iterator iterator;
typedef modules_t::const_iterator iterator;
iterator begin() const
{
return m_modules.begin();
}
iterator end() const
{
return m_modules.end();
}
iterator begin() const {
return m_modules.begin();
}
iterator end() const {
return m_modules.end();
}
void insert(const char* name, Module& module)
{
module.capture();
if(globalModuleServer().getError())
{
module.release();
globalModuleServer().setError(false);
}
else
{
m_modules.insert(modules_t::value_type(name, &module));
}
}
void insert( const char* name, Module& module ){
module.capture();
if ( globalModuleServer().getError() ) {
module.release();
globalModuleServer().setError( false );
}
else
{
m_modules.insert( modules_t::value_type( name, &module ) );
}
}
Type* find(const char* name)
{
modules_t::iterator i = m_modules.find(name);
if(i != m_modules.end())
{
return static_cast<Type*>(Module_getTable(*(*i).second));
}
return 0;
}
Type* find( const char* name ){
modules_t::iterator i = m_modules.find( name );
if ( i != m_modules.end() ) {
return static_cast<Type*>( Module_getTable( *( *i ).second ) );
}
return 0;
}
Type* findModule(const char* name)
{
return find(name);
}
void foreachModule(const typename Modules<Type>::Visitor& visitor)
{
for(modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i)
{
visitor.visit((*i).first.c_str(), *static_cast<const Type*>(Module_getTable(*(*i).second)));
}
}
Type* findModule( const char* name ){
return find( name );
}
void foreachModule( const typename Modules<Type>::Visitor& visitor ){
for ( modules_t::iterator i = m_modules.begin(); i != m_modules.end(); ++i )
{
visitor.visit( ( *i ).first.c_str(), *static_cast<const Type*>( Module_getTable( *( *i ).second ) ) );
}
}
};
template<typename Type>
class InsertModules : public ModuleServer::Visitor
{
ModulesMap<Type>& m_modules;
ModulesMap<Type>& m_modules;
public:
InsertModules(ModulesMap<Type>& modules)
: m_modules(modules)
{
}
void visit(const char* name, Module& module) const
{
m_modules.insert(name, module);
}
InsertModules( ModulesMap<Type>& modules )
: m_modules( modules ){
}
void visit( const char* name, Module& module ) const {
m_modules.insert( name, module );
}
};
template<typename Type>
class ModulesRef
{
ModulesMap<Type> m_modules;
ModulesMap<Type> m_modules;
public:
ModulesRef(const char* names)
{
if(!globalModuleServer().getError())
{
if(string_equal(names, "*"))
{
InsertModules<Type> visitor(m_modules);
globalModuleServer().foreachModule(typename Type::Name(), typename Type::Version(), visitor);
}
else
{
StringTokeniser tokeniser(names);
for(;;)
{
const char* name = tokeniser.getToken();
if(string_empty(name))
{
break;
}
Module* module = globalModuleServer().findModule(typename Type::Name(), typename Type::Version(), name);
if(module == 0)
{
globalModuleServer().setError(true);
globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted(typename Type::Name()) << " version=" << makeQuoted(typename Type::Version()) << " name=" << makeQuoted(name) << " - not found\n";
break;
}
else
{
m_modules.insert(name, *module);
}
}
}
}
}
ModulesMap<Type>& get()
{
return m_modules;
}
ModulesRef( const char* names ){
if ( !globalModuleServer().getError() ) {
if ( string_equal( names, "*" ) ) {
InsertModules<Type> visitor( m_modules );
globalModuleServer().foreachModule( typename Type::Name(), typename Type::Version(), visitor );
}
else
{
StringTokeniser tokeniser( names );
for (;; )
{
const char* name = tokeniser.getToken();
if ( string_empty( name ) ) {
break;
}
Module* module = globalModuleServer().findModule( typename Type::Name(), typename Type::Version(), name );
if ( module == 0 ) {
globalModuleServer().setError( true );
globalErrorStream() << "ModulesRef::initialise: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " name=" << makeQuoted( name ) << " - not found\n";
break;
}
else
{
m_modules.insert( name, *module );
}
}
}
}
}
ModulesMap<Type>& get(){
return m_modules;
}
};
#endif

View File

@@ -1,23 +1,23 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "singletonmodule.h"
#include "generic/constant.h"
@@ -25,24 +25,22 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
class NullType
{
public:
INTEGER_CONSTANT(Version, 1);
STRING_CONSTANT(Name, "");
INTEGER_CONSTANT( Version, 1 );
STRING_CONSTANT( Name, "" );
};
class NullModule
{
public:
typedef NullType Type;
STRING_CONSTANT(Name, "");
void* getTable()
{
return NULL;
}
typedef NullType Type;
STRING_CONSTANT( Name, "" );
void* getTable(){
return NULL;
}
};
void TEST_SINGLETONMODULE()
{
SingletonModule<NullModule> null;
null.capture();
null.release();
void TEST_SINGLETONMODULE(){
SingletonModule<NullModule> null;
null.capture();
null.release();
}

View File

@@ -1,25 +1,25 @@
/*
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
Copyright (C) 2001-2006, William Joseph.
All Rights Reserved.
This file is part of GtkRadiant.
This file is part of GtkRadiant.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GtkRadiant is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
You should have received a copy of the GNU General Public License
along with GtkRadiant; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(INCLUDED_MODULESYSTEM_SINGLETONMODULE_H)
#if !defined( INCLUDED_MODULESYSTEM_SINGLETONMODULE_H )
#define INCLUDED_MODULESYSTEM_SINGLETONMODULE_H
#include "modulesystem.h"
@@ -32,38 +32,32 @@ template<typename API, typename Dependencies>
class DefaultAPIConstructor
{
public:
const char* getName()
{
return typename API::Name();
}
const char* getName(){
return typename API::Name();
}
API* constructAPI(Dependencies& dependencies)
{
return new API;
}
void destroyAPI(API* api)
{
delete api;
}
API* constructAPI( Dependencies& dependencies ){
return new API;
}
void destroyAPI( API* api ){
delete api;
}
};
template<typename API, typename Dependencies>
class DependenciesAPIConstructor
{
public:
const char* getName()
{
return typename API::Name();
}
const char* getName(){
return typename API::Name();
}
API* constructAPI(Dependencies& dependencies)
{
return new API(dependencies);
}
void destroyAPI(API* api)
{
delete api;
}
API* constructAPI( Dependencies& dependencies ){
return new API( dependencies );
}
void destroyAPI( API* api ){
delete api;
}
};
class NullDependencies
@@ -74,76 +68,63 @@ class NullDependencies
template<typename API, typename Dependencies = NullDependencies, typename APIConstructor = DefaultAPIConstructor<API, Dependencies> >
class SingletonModule : public APIConstructor, public Module, public ModuleRegisterable
{
Dependencies* m_dependencies;
API* m_api;
std::size_t m_refcount;
bool m_dependencyCheck;
bool m_cycleCheck;
Dependencies* m_dependencies;
API* m_api;
std::size_t m_refcount;
bool m_dependencyCheck;
bool m_cycleCheck;
public:
typedef typename API::Type Type;
typedef typename API::Type Type;
SingletonModule()
: m_dependencies(0), m_api(0), m_refcount(0), m_dependencyCheck(false), m_cycleCheck(false)
{
}
explicit SingletonModule(const APIConstructor& constructor)
: APIConstructor(constructor), m_dependencies(0), m_api(0), m_refcount(0), m_dependencyCheck(false), m_cycleCheck(false)
{
}
~SingletonModule()
{
ASSERT_MESSAGE(m_refcount == 0, "module still referenced at shutdown");
}
SingletonModule()
: m_dependencies( 0 ), m_api( 0 ), m_refcount( 0 ), m_dependencyCheck( false ), m_cycleCheck( false ){
}
explicit SingletonModule( const APIConstructor& constructor )
: APIConstructor( constructor ), m_dependencies( 0 ), m_api( 0 ), m_refcount( 0 ), m_dependencyCheck( false ), m_cycleCheck( false ){
}
~SingletonModule(){
ASSERT_MESSAGE( m_refcount == 0, "module still referenced at shutdown" );
}
void selfRegister()
{
globalModuleServer().registerModule(typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this);
}
Dependencies& getDependencies()
{
return *m_dependencies;
}
void* getTable()
{
if(m_api != 0)
{
return m_api->getTable();
}
return 0;
}
void capture()
{
if(++m_refcount == 1)
{
globalOutputStream() << "Module Initialising: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
m_dependencies = new Dependencies();
m_dependencyCheck = !globalModuleServer().getError();
if(m_dependencyCheck)
{
m_api = APIConstructor::constructAPI(*m_dependencies);
globalOutputStream() << "Module Ready: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
}
else
{
globalOutputStream() << "Module Dependencies Failed: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
}
m_cycleCheck = true;
}
void selfRegister(){
globalModuleServer().registerModule( typename Type::Name(), typename Type::Version(), APIConstructor::getName(), *this );
}
ASSERT_MESSAGE(m_cycleCheck, "cyclic dependency detected");
}
void release()
{
if(--m_refcount == 0)
{
if(m_dependencyCheck)
{
APIConstructor::destroyAPI(m_api);
}
delete m_dependencies;
}
}
Dependencies& getDependencies(){
return *m_dependencies;
}
void* getTable(){
if ( m_api != 0 ) {
return m_api->getTable();
}
return 0;
}
void capture(){
if ( ++m_refcount == 1 ) {
globalOutputStream() << "Module Initialising: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
m_dependencies = new Dependencies();
m_dependencyCheck = !globalModuleServer().getError();
if ( m_dependencyCheck ) {
m_api = APIConstructor::constructAPI( *m_dependencies );
globalOutputStream() << "Module Ready: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
}
else
{
globalOutputStream() << "Module Dependencies Failed: '" << typename Type::Name() << "' '" << APIConstructor::getName() << "'\n";
}
m_cycleCheck = true;
}
ASSERT_MESSAGE( m_cycleCheck, "cyclic dependency detected" );
}
void release(){
if ( --m_refcount == 0 ) {
if ( m_dependencyCheck ) {
APIConstructor::destroyAPI( m_api );
}
delete m_dependencies;
}
}
};