Fix few warnings related to lua_glib. Get rid of f32 setters/getters since floats aren't used in lua
This commit is contained in:
1 parent
23dce9f5b6
commit
74ee1fcdd8
3 files changed
+17
-22
No files matched your search
+7
-4
@@ -9272,8 +9272,7 @@ static inline int lib_getenum(lua_State *L)
|
||||
const int UV_MATHLIB = lua_upvalueindex(1);
|
||||
const int GLIB_PROXY = lua_upvalueindex(2);
|
||||
|
||||
const char *word, *p;
|
||||
fixed_t i;
|
||||
const char *word;
|
||||
boolean mathlib = lua_toboolean(L, UV_MATHLIB);
|
||||
if (lua_type(L,2) != LUA_TSTRING)
|
||||
return 0;
|
||||
@@ -9511,6 +9510,8 @@ static int lua_enumlib_power_get(lua_State *L)
|
||||
{
|
||||
return luaL_error(L, "power '%s' could not be found.\n", lua_tostring(L, 1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lua_enumlib_kartstuff_get(lua_State *L)
|
||||
@@ -9532,6 +9533,8 @@ static int lua_enumlib_kartstuff_get(lua_State *L)
|
||||
{
|
||||
return luaL_error(L, "kartstuff '%s' could not be found.\n", lua_tostring(L, 1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lua_enumlib_action_get(lua_State *L)
|
||||
@@ -9917,10 +9920,10 @@ int LUA_EnumLib(lua_State *L)
|
||||
PUSHGETTER(gametype, i16);
|
||||
PUSHGETTER(leveltime, u32);
|
||||
PUSHGETTER(curWeather, i32);
|
||||
PUSHGETTER(globalweather, i8);
|
||||
PUSHGETTER(globalweather, u8);
|
||||
PUSHGETTER(levelskynum, i32);
|
||||
PUSHGETTER(globallevelskynum, i32);
|
||||
PUSHGETTER(mapmusname, str);
|
||||
PUSHGETTER((*mapmusname), str);
|
||||
PUSHGETTER(mapmusflags, u16);
|
||||
PUSHGETTER(mapmusposition, u32);
|
||||
PUSHGETTER(gravity, fxp);
|
||||
|
||||
+9
-13
@@ -281,7 +281,7 @@ int lua_glib_new_setter(lua_State *L)
|
||||
|
||||
#define _GLIB_DECL_INT_GETTER(T, name) \
|
||||
int lua_glib_getter_##name(lua_State *L) { \
|
||||
const T* ptr = (const T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
const T* ptr = (const T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
lua_pushinteger(L, (lua_Integer)*ptr); \
|
||||
return 1; \
|
||||
}
|
||||
@@ -289,21 +289,21 @@ int lua_glib_new_setter(lua_State *L)
|
||||
#define _GLIB_DECL_INT_SETTER(T, name) \
|
||||
int lua_glib_setter_##name(lua_State *L) { \
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); \
|
||||
T* ptr = (T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
T* ptr = (T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
*ptr = (T)lua_tointeger(L, 1); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define _GLIB_DECL_BOOL_GETTER(T, name) \
|
||||
int lua_glib_getter_##name(lua_State *L) { \
|
||||
const T* ptr = (const T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
const T* ptr = (const T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
lua_pushboolean(L, *ptr != 0); \
|
||||
return 1; \
|
||||
}
|
||||
|
||||
#define _GLIB_DECL_FLOAT_GETTER(T, name) \
|
||||
int lua_glib_getter_##name(lua_State *L) { \
|
||||
const T* ptr = (const T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
const T* ptr = (const T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
lua_pushnumber(L, (lua_Number)*ptr); \
|
||||
return 1; \
|
||||
}
|
||||
@@ -311,14 +311,14 @@ int lua_glib_new_setter(lua_State *L)
|
||||
#define _GLIB_DECL_FLOAT_SETTER(T, name) \
|
||||
int lua_glib_setter_##name(lua_State *L) { \
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); \
|
||||
T* ptr = (T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
T* ptr = (T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
*ptr = (T)lua_tonumber(L, 1); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define _GLIB_DECL_BOOL_SETTER(T, name) \
|
||||
int lua_glib_setter_##name(lua_State *L) { \
|
||||
T* ptr = (T*)lua_topointer(L, lua_upvalueindex(1)); \
|
||||
T* ptr = (T*)lua_touserdata(L, lua_upvalueindex(1)); \
|
||||
*ptr = (T)lua_toboolean(L, 1); \
|
||||
return 0; \
|
||||
}
|
||||
@@ -331,8 +331,6 @@ _GLIB_DECL_INT_GETTER(uint8_t, u8);
|
||||
_GLIB_DECL_INT_GETTER(uint16_t, u16);
|
||||
_GLIB_DECL_INT_GETTER(uint32_t, u32);
|
||||
_GLIB_DECL_INT_GETTER(uint64_t, u64);
|
||||
_GLIB_DECL_FLOAT_GETTER(float, f32);
|
||||
_GLIB_DECL_FLOAT_GETTER(double, f64);
|
||||
_GLIB_DECL_BOOL_GETTER(uint8_t, b8);
|
||||
_GLIB_DECL_BOOL_GETTER(uint16_t, b16);
|
||||
_GLIB_DECL_BOOL_GETTER(uint32_t, b32);
|
||||
@@ -346,8 +344,6 @@ _GLIB_DECL_INT_SETTER(uint8_t, u8);
|
||||
_GLIB_DECL_INT_SETTER(uint16_t, u16);
|
||||
_GLIB_DECL_INT_SETTER(uint32_t, u32);
|
||||
_GLIB_DECL_INT_SETTER(uint64_t, u64);
|
||||
_GLIB_DECL_FLOAT_SETTER(float, f32);
|
||||
_GLIB_DECL_FLOAT_SETTER(double, f64);
|
||||
_GLIB_DECL_BOOL_SETTER(uint8_t, b8);
|
||||
_GLIB_DECL_BOOL_SETTER(uint16_t, b16);
|
||||
_GLIB_DECL_BOOL_SETTER(uint32_t, b32);
|
||||
@@ -355,21 +351,21 @@ _GLIB_DECL_BOOL_SETTER(uint64_t, b64);
|
||||
|
||||
int lua_glib_setter_fxp(lua_State *L)
|
||||
{
|
||||
fixed_t *fxp = (fixed_t*)lua_topointer(L, lua_upvalueindex(1));
|
||||
fixed_t *fxp = (fixed_t*)lua_touserdata(L, lua_upvalueindex(1));
|
||||
*fxp = lua_tointeger(L, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_glib_getter_fxp(lua_State *L)
|
||||
{
|
||||
const fixed_t *fxp = (const fixed_t*)lua_topointer(L, lua_upvalueindex(1));
|
||||
const fixed_t *fxp = (const fixed_t*)lua_touserdata(L, lua_upvalueindex(1));
|
||||
lua_pushfixed(L, *fxp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_glib_getter_str(lua_State *L)
|
||||
{
|
||||
const char *str = (const char*)lua_topointer(L, lua_upvalueindex(1));
|
||||
const char *str = (const char*)lua_touserdata(L, lua_upvalueindex(1));
|
||||
lua_pushstring(L, str);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
-5
@@ -125,7 +125,7 @@ int lua_glib_setter_b64(lua_State *L);
|
||||
int lua_glib_setter_fxp(lua_State *L);
|
||||
|
||||
#define _LUA_GLIB_DECL_PGETTER(T, name) \
|
||||
static inline void lua_glib_push_##name##_getter(lua_State *L, const T* ptr) { \
|
||||
static inline void lua_glib_push_##name##_getter(lua_State *L, T* ptr) { \
|
||||
lua_pushlightuserdata(L, (void*)ptr); \
|
||||
lua_pushcclosure(L, lua_glib_getter_##name, 1); \
|
||||
}
|
||||
@@ -138,8 +138,6 @@ int lua_glib_setter_fxp(lua_State *L);
|
||||
_LUA_GLIB_DECL_PGETTER(uint16_t, u16);
|
||||
_LUA_GLIB_DECL_PGETTER(uint32_t, u32);
|
||||
_LUA_GLIB_DECL_PGETTER(uint64_t, u64);
|
||||
_LUA_GLIB_DECL_PGETTER(float, f32);
|
||||
_LUA_GLIB_DECL_PGETTER(double, f64);
|
||||
_LUA_GLIB_DECL_PGETTER(char, str);
|
||||
_LUA_GLIB_DECL_PGETTER(void, ptr);
|
||||
_LUA_GLIB_DECL_PGETTER(uint8_t, b8);
|
||||
@@ -163,8 +161,6 @@ int lua_glib_setter_fxp(lua_State *L);
|
||||
_LUA_GLIB_DECL_PSETTER(uint16_t, u16);
|
||||
_LUA_GLIB_DECL_PSETTER(uint32_t, u32);
|
||||
_LUA_GLIB_DECL_PSETTER(uint64_t, u64);
|
||||
_LUA_GLIB_DECL_PSETTER(float, f32);
|
||||
_LUA_GLIB_DECL_PSETTER(double, f64);
|
||||
_LUA_GLIB_DECL_PSETTER(uint8_t, b8);
|
||||
_LUA_GLIB_DECL_PSETTER(uint16_t, b16);
|
||||
_LUA_GLIB_DECL_PSETTER(uint32_t, b32);
|
||||
|
||||
Reference in new issue
Block a user