Try working around some msvc problems.

develop
Alexander Gavrilov 2012-04-16 10:59:55 +04:00
parent a1756a864c
commit 48e4717dd2
3 changed files with 10 additions and 4 deletions

@ -981,7 +981,7 @@ void DFHack::Lua::InvokeEvent(color_ostream &out, lua_State *state, void *key, i
set_dfhack_output(state, cur_out); set_dfhack_output(state, cur_out);
} }
void DFHack::Lua::CreateEvent(lua_State *state, void *key) void DFHack::Lua::MakeEvent(lua_State *state, void *key)
{ {
lua_rawgetp(state, LUA_REGISTRYINDEX, key); lua_rawgetp(state, LUA_REGISTRYINDEX, key);
@ -1009,7 +1009,7 @@ void DFHack::Lua::Notification::bind(lua_State *state, void *key)
void DFHack::Lua::Notification::bind(lua_State *state, const char *name) void DFHack::Lua::Notification::bind(lua_State *state, const char *name)
{ {
CreateEvent(state, this); MakeEvent(state, this);
if (handler) if (handler)
{ {

@ -537,7 +537,7 @@ void Plugin::open_lua(lua_State *state, int table)
{ {
for (auto it = lua_events.begin(); it != lua_events.end(); ++it) for (auto it = lua_events.begin(); it != lua_events.end(); ++it)
{ {
Lua::CreateEvent(state, it->second); Lua::MakeEvent(state, it->second);
push_function(state, &it->second->handler); push_function(state, &it->second->handler);
lua_rawsetp(state, -2, NULL); lua_rawsetp(state, -2, NULL);

@ -175,6 +175,7 @@ namespace DFHack {namespace Lua {
/** /**
* Push utility functions * Push utility functions
*/ */
#if 0
#define NUMBER_PUSH(type) inline void Push(lua_State *state, type value) { lua_pushnumber(state, value); } #define NUMBER_PUSH(type) inline void Push(lua_State *state, type value) { lua_pushnumber(state, value); }
NUMBER_PUSH(char) NUMBER_PUSH(char)
NUMBER_PUSH(int8_t) NUMBER_PUSH(uint8_t) NUMBER_PUSH(int8_t) NUMBER_PUSH(uint8_t)
@ -183,6 +184,11 @@ namespace DFHack {namespace Lua {
NUMBER_PUSH(int64_t) NUMBER_PUSH(uint64_t) NUMBER_PUSH(int64_t) NUMBER_PUSH(uint64_t)
NUMBER_PUSH(float) NUMBER_PUSH(double) NUMBER_PUSH(float) NUMBER_PUSH(double)
#undef NUMBER_PUSH #undef NUMBER_PUSH
#else
template<class T> inline void Push(lua_State *state, T value) {
lua_pushnumber(state, lua_Number(value));
}
#endif
inline void Push(lua_State *state, bool value) { inline void Push(lua_State *state, bool value) {
lua_pushboolean(state, value); lua_pushboolean(state, value);
} }
@ -212,7 +218,7 @@ namespace DFHack {namespace Lua {
DFHACK_EXPORT bool IsCoreContext(lua_State *state); DFHACK_EXPORT bool IsCoreContext(lua_State *state);
DFHACK_EXPORT int NewEvent(lua_State *state); DFHACK_EXPORT int NewEvent(lua_State *state);
DFHACK_EXPORT void CreateEvent(lua_State *state, void *key); DFHACK_EXPORT void MakeEvent(lua_State *state, void *key);
DFHACK_EXPORT void InvokeEvent(color_ostream &out, lua_State *state, void *key, int num_args); DFHACK_EXPORT void InvokeEvent(color_ostream &out, lua_State *state, void *key, int num_args);
/** /**