From 804734d0137ffabdcec918480e3c5ab8743da27f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 14 Aug 2014 19:39:17 +0200 Subject: [PATCH] MSVC: disable level 4 warning C4100 for tolua-generated code (unused variable) make a single object from all generated binding code. this setup is unusual, but easier to maintain. --- src/CMakeLists.txt | 8 +------- src/bind_tolua.c | 19 +++++++++++++++++++ src/bind_tolua.h | 5 +++++ src/bindings.c | 10 +++------- src/config.pkg | 2 ++ src/config.pkg.c | 2 ++ src/eressea.pkg | 2 ++ src/eressea.pkg.c | 3 +++ src/game.pkg | 2 ++ src/game.pkg.c | 2 ++ src/locale.pkg | 2 ++ src/locale.pkg.c | 3 +++ src/log.pkg | 2 ++ src/log.pkg.c | 2 ++ src/process.pkg | 2 ++ src/process.pkg.c | 2 ++ src/settings.pkg | 2 ++ src/settings.pkg.c | 2 ++ 18 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 src/bind_tolua.c create mode 100644 src/bind_tolua.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e663c3b4..f90c82258 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -93,13 +93,7 @@ set(SERVER_SRC building_action.c console.c helpers.c - config.pkg.c - eressea.pkg.c - game.pkg.c - locale.pkg.c - log.pkg.c - process.pkg.c - settings.pkg.c + bind_tolua.c bind_building.c bind_config.c bind_locale.c diff --git a/src/bind_tolua.c b/src/bind_tolua.c new file mode 100644 index 000000000..26e536f9c --- /dev/null +++ b/src/bind_tolua.c @@ -0,0 +1,19 @@ +#pragma warning(push) +#pragma warning(disable: 4100) +#include "config.pkg.c" +#include "eressea.pkg.c" +#include "game.pkg.c" +#include "locale.pkg.c" +#include "log.pkg.c" +#include "process.pkg.c" +#include "settings.pkg.c" + +void tolua_bind_open(lua_State * L) { + tolua_eressea_open(L); + tolua_process_open(L); + tolua_settings_open(L); + tolua_game_open(L); + tolua_config_open(L); + tolua_locale_open(L); + tolua_log_open(L); +} diff --git a/src/bind_tolua.h b/src/bind_tolua.h new file mode 100644 index 000000000..e6478c02e --- /dev/null +++ b/src/bind_tolua.h @@ -0,0 +1,5 @@ +#ifndef BIND_TOLUA_H +#define BIND_TOLUA_H +struct lua_State; +void tolua_bind_open(struct lua_State * L); +#endif diff --git a/src/bindings.c b/src/bindings.c index 71604ac8d..791c1e26a 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1062,17 +1062,13 @@ static void parse_inifile(lua_State * L, dictionary * d, const char *section) } } +void tolua_bind_open(lua_State * L); + int tolua_bindings_open(lua_State * L) { tolua_open(L); - tolua_eressea_open(L); - tolua_process_open(L); - tolua_settings_open(L); - tolua_game_open(L); - tolua_config_open(L); - tolua_locale_open(L); - tolua_log_open(L); + tolua_bind_open(L); /* register user types */ tolua_usertype(L, TOLUA_CAST "spell"); diff --git a/src/config.pkg b/src/config.pkg index 5c9e1ff33..33f94bed8 100644 --- a/src/config.pkg +++ b/src/config.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_config $#include "bind_config.h" module eressea { diff --git a/src/config.pkg.c b/src/config.pkg.c index e9ebccd10..c4225ff7b 100644 --- a/src/config.pkg.c +++ b/src/config.pkg.c @@ -18,6 +18,8 @@ TOLUA_API int tolua_config_open (lua_State* tolua_S); LUALIB_API int luaopen_config (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_config #include "bind_config.h" /* function to register type */ diff --git a/src/eressea.pkg b/src/eressea.pkg index 43132108c..2cb66e7df 100755 --- a/src/eressea.pkg +++ b/src/eressea.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_eressea $#include "bind_eressea.h" module eressea { diff --git a/src/eressea.pkg.c b/src/eressea.pkg.c index 86691bb7f..289fc323a 100644 --- a/src/eressea.pkg.c +++ b/src/eressea.pkg.c @@ -18,6 +18,9 @@ TOLUA_API int tolua_eressea_open (lua_State* tolua_S); LUALIB_API int luaopen_eressea (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_eressea +#include "bind_tolua.h" #include "bind_eressea.h" /* function to register type */ diff --git a/src/game.pkg b/src/game.pkg index e29fdf856..88b3bda9a 100644 --- a/src/game.pkg +++ b/src/game.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_game $#include "config.h" $#include "bind_eressea.h" diff --git a/src/game.pkg.c b/src/game.pkg.c index 329f22028..abd7832ca 100644 --- a/src/game.pkg.c +++ b/src/game.pkg.c @@ -18,6 +18,8 @@ TOLUA_API int tolua_game_open (lua_State* tolua_S); LUALIB_API int luaopen_game (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_game #include "config.h" #include "bind_eressea.h" diff --git a/src/locale.pkg b/src/locale.pkg index 1f4c12241..9a2c420de 100644 --- a/src/locale.pkg +++ b/src/locale.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_locale $#include "bind_locale.h" module eressea { diff --git a/src/locale.pkg.c b/src/locale.pkg.c index 85021e654..34517584f 100644 --- a/src/locale.pkg.c +++ b/src/locale.pkg.c @@ -18,6 +18,9 @@ TOLUA_API int tolua_locale_open (lua_State* tolua_S); LUALIB_API int luaopen_locale (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_locale +#include "bind_tolua.h" #include "bind_locale.h" /* function to register type */ diff --git a/src/log.pkg b/src/log.pkg index 447de4fca..ae42b8b64 100644 --- a/src/log.pkg +++ b/src/log.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_log $#include module eressea { diff --git a/src/log.pkg.c b/src/log.pkg.c index c1620f8cd..4303a5c2d 100644 --- a/src/log.pkg.c +++ b/src/log.pkg.c @@ -18,6 +18,8 @@ TOLUA_API int tolua_log_open (lua_State* tolua_S); LUALIB_API int luaopen_log (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_log #include /* function to register type */ diff --git a/src/process.pkg b/src/process.pkg index 88c7808a9..5db5c7344 100755 --- a/src/process.pkg +++ b/src/process.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_process $#include "bind_process.h" module eressea { diff --git a/src/process.pkg.c b/src/process.pkg.c index 5adc1d8b5..787258a96 100644 --- a/src/process.pkg.c +++ b/src/process.pkg.c @@ -18,6 +18,8 @@ TOLUA_API int tolua_process_open (lua_State* tolua_S); LUALIB_API int luaopen_process (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_process #include "bind_process.h" /* function to register type */ diff --git a/src/settings.pkg b/src/settings.pkg index 39c392608..e216bf8b6 100755 --- a/src/settings.pkg +++ b/src/settings.pkg @@ -1,3 +1,5 @@ +$#undef tolua_reg_types +$#define tolua_reg_types tolua_reg_types_config $#include "bind_settings.h" module eressea { diff --git a/src/settings.pkg.c b/src/settings.pkg.c index 5620e8c63..0dcd3df61 100644 --- a/src/settings.pkg.c +++ b/src/settings.pkg.c @@ -18,6 +18,8 @@ TOLUA_API int tolua_settings_open (lua_State* tolua_S); LUALIB_API int luaopen_settings (lua_State* tolua_S); +#undef tolua_reg_types +#define tolua_reg_types tolua_reg_types_settings #include "bind_settings.h" /* function to register type */