MINOR: lua: add utility function for check boolean argument
Strangely, the Lua API doesn't provides a function like luaL_checkboolean(). This little function add this one.
This commit is contained in:
parent
e365815007
commit
7f3aa8b62f
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _PROTO_HLUA_FCN_H
|
#ifndef _PROTO_HLUA_FCN_H
|
||||||
#define _PROTO_HLUA_FCN_H
|
#define _PROTO_HLUA_FCN_H
|
||||||
|
|
||||||
|
int hlua_checkboolean(lua_State *L, int index);
|
||||||
|
|
||||||
void hlua_class_const_int(lua_State *L, const char *name, int value);
|
void hlua_class_const_int(lua_State *L, const char *name, int value);
|
||||||
void hlua_class_const_str(lua_State *L, const char *name, const char *value);
|
void hlua_class_const_str(lua_State *L, const char *name, const char *value);
|
||||||
void hlua_class_function(lua_State *L, const char *name, int (*function)(lua_State *L));
|
void hlua_class_function(lua_State *L, const char *name, int (*function)(lua_State *L));
|
||||||
|
|
|
@ -41,6 +41,13 @@ static int class_listener_ref;
|
||||||
|
|
||||||
static struct field stats[STATS_LEN];
|
static struct field stats[STATS_LEN];
|
||||||
|
|
||||||
|
int hlua_checkboolean(lua_State *L, int index)
|
||||||
|
{
|
||||||
|
if (!lua_isboolean(L, index))
|
||||||
|
luaL_argerror(L, index, "boolean expected");
|
||||||
|
return lua_toboolean(L, index);
|
||||||
|
}
|
||||||
|
|
||||||
/* This function gets a struct field and convert it in Lua
|
/* This function gets a struct field and convert it in Lua
|
||||||
* variable. The variable is pushed at the top of the stak.
|
* variable. The variable is pushed at the top of the stak.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue