Code to implement HTTP requests done. Also, rewrote str_to_int64, str_to_double
This commit is contained in:
@@ -52,6 +52,22 @@ lua_State *LuaStack::newstate (lua_Alloc allocf) {
|
||||
return L;
|
||||
}
|
||||
|
||||
bool LuaStack::isinteger(LuaSlot s) const {
|
||||
if (lua_type(L_, s) == LUA_TNUMBER) {
|
||||
lua_Number result = lua_tonumber(L_, s);
|
||||
if (lua_Integer(result) == result) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LuaStack::isint(LuaSlot s) const {
|
||||
if (lua_type(L_, s) == LUA_TNUMBER) {
|
||||
lua_Number result = lua_tonumber(L_, s);
|
||||
if (int(result) == result) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LuaStack::ckboolean(LuaSlot s) const {
|
||||
luaL_checktype(L_, s, LUA_TBOOLEAN);
|
||||
return lua_toboolean(L_, s) ? true:false;
|
||||
@@ -59,12 +75,24 @@ bool LuaStack::ckboolean(LuaSlot s) const {
|
||||
|
||||
lua_Integer LuaStack::ckinteger(LuaSlot s) const {
|
||||
luaL_checktype(L_, s, LUA_TNUMBER);
|
||||
return lua_tointeger(L_, s);
|
||||
lua_Number result = lua_tonumber(L_, s);
|
||||
lua_Integer iresult(result);
|
||||
if (iresult != result) {
|
||||
luaL_error(L_, "not a valid integer");
|
||||
return 0;
|
||||
}
|
||||
return iresult;
|
||||
}
|
||||
|
||||
int LuaStack::ckint(LuaSlot s) const {
|
||||
luaL_checktype(L_, s, LUA_TNUMBER);
|
||||
return (int)lua_tointeger(L_, s);
|
||||
lua_Number result = lua_tonumber(L_, s);
|
||||
int iresult(result);
|
||||
if (iresult != result) {
|
||||
luaL_error(L_, "not a valid int");
|
||||
return 0;
|
||||
}
|
||||
return iresult;
|
||||
}
|
||||
|
||||
lua_Number LuaStack::cknumber(LuaSlot s) const {
|
||||
|
||||
Reference in New Issue
Block a user