| 173 | |
| 174 | template<class T> |
| 175 | static bool get_int_field(lua_State *L, T *pf, int idx, const char *name, int defval) |
| 176 | { |
| 177 | lua_getfield(L, idx, name); |
| 178 | bool nil = lua_isnil(L, -1); |
| 179 | if (nil) *pf = T(defval); |
| 180 | else if (lua_isnumber(L, -1)) *pf = T(lua_tointeger(L, -1)); |
| 181 | else luaL_error(L, "Field %s is not a number.", name); |
| 182 | lua_pop(L, 1); |
| 183 | return !nil; |
| 184 | } |
| 185 | |
| 186 | template<class T> |
| 187 | static bool get_int_or_closure_field(lua_State *L, T *pf, int idx, const char *name, int defval) |
no test coverage detected