Fix few warnings regarding udatalib #47
No files matched your search
@@ -516,7 +516,9 @@ static int player_get(lua_State *L)
|
||||
}
|
||||
lua_getfield(L, -1, field);
|
||||
if (lua_isnil(L, -1)) // no value for this field
|
||||
{
|
||||
CONS_Debug(DBG_LUA, M_GetText("'%s' has no field named '%s'; returning nil.\n"), "player_t", field);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ int udatalib_setter_boolean_nocheck(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(boolean, lua_toboolean)
|
||||
|
||||
int udatalib_setter_spritenum(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(spritenum_t, (spritenum_t)luaL_checkinteger)
|
||||
UDATALIB_SIMPLE_SETTER(spritenum_t, luaL_checkinteger)
|
||||
|
||||
int udatalib_setter_tic(lua_State *L)
|
||||
UDATALIB_SIMPLE_SETTER(tic_t, (tic_t)luaL_checkinteger)
|
||||
|
||||
+3
-5
@@ -1,8 +1,6 @@
|
||||
#ifndef __LUA_UDATALIB_H__
|
||||
#define __LUA_UDATALIB_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
|
||||
#include "doomdef.h"
|
||||
@@ -16,7 +14,7 @@
|
||||
|
||||
typedef struct udata_field_s {
|
||||
const char *name;
|
||||
intptr_t offset;
|
||||
size_t offset;
|
||||
lua_CFunction getter;
|
||||
lua_CFunction setter;
|
||||
} udata_field_t;
|
||||
@@ -82,8 +80,8 @@ void udatalib_addfields(lua_State *L, int mt, const udata_field_t fields[]);
|
||||
// Get pointer to field value within getter or setter
|
||||
#define UDATALIB_GETFIELD(type, field) \
|
||||
{ \
|
||||
intptr_t offset = lua_tointeger(L, lua_upvalueindex(1)); \
|
||||
field = (type*)((intptr_t)lua_touserdata(L, 1) + offset); \
|
||||
size_t offset = lua_tointeger(L, lua_upvalueindex(1)); \
|
||||
field = (type*)((uint8_t*)lua_touserdata(L, 1) + offset); \
|
||||
}
|
||||
|
||||
// Creates implementation for simple getter and setter. Super lazy, yes.
|
||||
|
||||
Reference in new issue
Block a user