diff -r 4fd19a188509 -r 5770be2d5f3f util.c --- a/util.c Mon Feb 09 13:39:36 2009 +0200 +++ b/util.c Sat Feb 14 16:40:09 2009 +0200 @@ -25,6 +25,9 @@ return NULL; } +/// argument enum field +/// String that will be converted to number or just plain number, that will be passed as is. +/// Note, that if enum name is not recognized no error will be raised and default vale will be used. enum_value_t luaL_checkenum (lua_State *L, int index, const string2enum_t *set) { if (lua_type (L, index) == LUA_TNUMBER) @@ -33,6 +36,8 @@ return string2enum (luaL_checkstring (L, index), set); } +/// return enum field +/// String. If no string found, plain number will be returned. void luaL_pushenum (lua_State *L, enum_value_t value, const string2enum_t *set) { const char *string = enum2string (value, set); @@ -42,6 +47,12 @@ lua_pushinteger (L, value); } +/// argument flags field +/// Can be just plain number, then it is passed as is. +/// Can be a string, then it is recognized as a single enabled flag. +/// Or can be a table of the following format: +/// * integer keys should have string values, that will be used as enabled flag names or numerical values, that will be just ORed; +/// * string keys should be flag names, that will be enabled, if corresponding value contains true value. enum_value_t luaL_checkenum_multi (lua_State *L, int index, const string2enum_t *set) { int type = lua_type (L, index); @@ -74,6 +85,10 @@ return 0; // never happens } +/// returned flags field +/// Is always a table with present flag names as keys with true values. +/// Not present flags are not present in table either. +/// Not recognized values, if present, will be stored as a number in a first sequential table member (table[1]). void luaL_pushenum_multi (lua_State *L, enum_value_t value, const string2enum_t *set) { enum_value_t matched = 0;