From af44734bd43780612ee1531c35299c23cef80a6a Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 4 Sep 2009 16:24:14 +0200 Subject: [PATCH] luaclass: add luaA_checkudataornil Signed-off-by: Julien Danjou --- common/luaclass.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/luaclass.h b/common/luaclass.h index f41ec9a1..e8856ba0 100644 --- a/common/luaclass.h +++ b/common/luaclass.h @@ -83,6 +83,14 @@ int luaA_class_new(lua_State *, lua_class_t *); void * luaA_checkudata(lua_State *, int, lua_class_t *); void * luaA_toudata(lua_State *L, int ud, lua_class_t *); +static inline void * +luaA_checkudataornil(lua_State *L, int udx, lua_class_t *class) +{ + if(lua_isnil(L, udx)) + return NULL; + return luaA_checkudata(L, udx, class); +} + #define LUA_CLASS_FUNCS(prefix, lua_class) \ static inline int \ luaA_##prefix##_class_add_signal(lua_State *L) \