[Orxonox-commit 3738] r8418 - in code/trunk/src: . libraries/core libraries/core/command libraries/network
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun May 8 18:53:39 CEST 2011
Author: rgrieder
Date: 2011-05-08 18:53:39 +0200 (Sun, 08 May 2011)
New Revision: 8418
Modified:
code/trunk/src/OrxonoxConfig.h.in
code/trunk/src/libraries/core/Game.h
code/trunk/src/libraries/core/ToluaInterface.h
code/trunk/src/libraries/core/command/ConsoleCommand.h
code/trunk/src/libraries/network/NetworkFunction.h
Log:
Added preprocessor macro __UNIQUE_NUMBER__ which will return a new integer number every time is invoked if such a mechanism is available.
On GCC < 4.3, it will be defined as __LINE__. Newer GCC and MSVC support __COUNTER__, which is then used.
Also replaced uses of __LINE__ with __UNIQUE_NUMBER__ if appropriate.
Modified: code/trunk/src/OrxonoxConfig.h.in
===================================================================
--- code/trunk/src/OrxonoxConfig.h.in 2011-05-08 16:33:26 UTC (rev 8417)
+++ code/trunk/src/OrxonoxConfig.h.in 2011-05-08 16:53:39 UTC (rev 8418)
@@ -108,6 +108,15 @@
# endif
#endif
+#ifndef __UNIQUE_NUMBER__
+# if defined(ORXONOX_COMPILER_GCC) && ORXONOX_COMP_VER >= 430
+# define __UNIQUE_NUMBER__ __COUNTER__
+# elif defined(ORXONOX_COMPILER_MSVC)
+# define __UNIQUE_NUMBER__ __COUNTER__
+# else
+# define __UNIQUE_NUMBER__ __LINE__
+# endif
+#endif
/*---------------------------------
* Version information
Modified: code/trunk/src/libraries/core/Game.h
===================================================================
--- code/trunk/src/libraries/core/Game.h 2011-05-08 16:33:26 UTC (rev 8417)
+++ code/trunk/src/libraries/core/Game.h 2011-05-08 16:53:39 UTC (rev 8418)
@@ -58,7 +58,7 @@
and every following paramter is a constructor argument (which is usually non existent)
*/
#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
- static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
+ static bool BOOST_PP_CAT(bGameStateDummy_##className, __UNIQUE_NUMBER__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
// tolua_begin
namespace orxonox
{
Modified: code/trunk/src/libraries/core/ToluaInterface.h
===================================================================
--- code/trunk/src/libraries/core/ToluaInterface.h 2011-05-08 16:33:26 UTC (rev 8417)
+++ code/trunk/src/libraries/core/ToluaInterface.h 2011-05-08 16:53:39 UTC (rev 8418)
@@ -41,7 +41,7 @@
// Macro for declaring a tolua interface of a library/module
#define DeclareToluaInterface(libraryName) \
- static bool BOOST_PP_CAT(bDummy##libraryName, __LINE__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
- static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __LINE__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
+ static bool BOOST_PP_CAT(bDummy##libraryName, __UNIQUE_NUMBER__) = orxonox::LuaState::addToluaInterface(&tolua_##libraryName##_open, #libraryName); \
+ static Loki::ScopeGuardImpl1<bool (*)(const std::string&), std::string> BOOST_PP_CAT(dummy##libraryName, __UNIQUE_NUMBER__)(&orxonox::LuaState::removeToluaInterface, #libraryName)
#endif /* _ToluaInterface_H__ */
Modified: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h 2011-05-08 16:33:26 UTC (rev 8417)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h 2011-05-08 16:53:39 UTC (rev 8418)
@@ -268,7 +268,7 @@
/// Internal macro
#define SetConsoleCommandGeneric(group, name, functor) \
- static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
+ static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
/**
@@ -303,7 +303,7 @@
/// Internal macro
#define DeclareConsoleCommandGeneric(group, name, functor) \
- static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __LINE__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
+ static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
namespace orxonox
Modified: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h 2011-05-08 16:33:26 UTC (rev 8417)
+++ code/trunk/src/libraries/network/NetworkFunction.h 2011-05-08 16:53:39 UTC (rev 8418)
@@ -254,9 +254,9 @@
}
#define registerStaticNetworkFunction( functionPointer ) \
- static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __LINE__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
+ static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
#define registerMemberNetworkFunction( class, function ) \
- static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __LINE__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
+ static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
// call it with functionPointer, clientID, args
#define callStaticNetworkFunction( functionPointer, ...) \
{ \
More information about the Orxonox-commit
mailing list