--- a/src/lua_objs.c Sun Apr 19 04:04:42 2009 +0300
+++ b/src/lua_objs.c Sun Apr 19 04:35:29 2009 +0300
@@ -66,6 +66,39 @@
}
}
+const char *lua_arg_string (lua_State *L, int index, const char *name, const char *def)
+{
+ const char *value;
+
+ // use default?
+ if (lua_isnoneornil(L, index) && def != (const char *) LUA_ARG_REQUIRED)
+ return def;
+
+ // value given?
+ if ((value = lua_tostring(L, index)))
+ return value;
+
+ // error
+ luaL_error(L, "missing value for required string argument <%d:%s>", index, name);
+}
+
+bool lua_arg_bool (lua_State *L, int index, const char *name, int def)
+{
+ bool value;
+
+ // use default?
+ if (lua_isnoneornil(L, index) && def != LUA_ARG_REQUIRED)
+ return def;
+
+ // value given?
+ value = lua_toboolean(L, index);
+
+ return value;
+
+ // error
+ // luaL_error(L, "missing value of required boolean argument <%d:%s>", index, name);
+}
+
/**
* Wrapper for module
*/