| 169 | |
| 170 | |
| 171 | static int luaB_tointeger(lua_State *L) |
| 172 | { |
| 173 | int res = luaB_tonumber(L); |
| 174 | if (res > 0 && lua_isinteger(L, -1)) |
| 175 | { |
| 176 | lua_Integer int_result = luaL_checkinteger(L, -1); |
| 177 | lua_pop(L, 1); |
| 178 | lua_pushinteger(L, int_result); |
| 179 | return 1; |
| 180 | } |
| 181 | else if(res > 0 && lua_isnumber(L, -1)) |
| 182 | { |
| 183 | lua_Number number_result = luaL_checknumber(L, -1); |
| 184 | auto int_result = (lua_Integer)number_result; |
| 185 | lua_pop(L, 1); |
| 186 | lua_pushinteger(L, int_result); |
| 187 | return 1; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | lua_pop(L, res); |
| 192 | lua_set_run_error(L, "need pass number or integer value to func tointeger"); |
| 193 | return luaL_error(L, "need pass number or integer value to func tointeger"); |
| 194 | // return res; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | |
| 199 | static int luaB_error(lua_State *L) { |
nothing calls this directly
no test coverage detected