fix(util/lua_named_param): compilation warning
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
ff9004dae2
commit
0eaf1bb2cf
1 changed files with 5 additions and 4 deletions
|
@ -7,6 +7,7 @@ Author: Leonardo de Moura
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "util/lua_named_param.h"
|
#include "util/lua_named_param.h"
|
||||||
#include "util/sstream.h"
|
#include "util/sstream.h"
|
||||||
|
#include "util/int64.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
bool get_bool_named_param(lua_State * L, int idx, char const * opt_name, bool def_value) {
|
bool get_bool_named_param(lua_State * L, int idx, char const * opt_name, bool def_value) {
|
||||||
|
@ -60,9 +61,9 @@ unsigned get_uint_named_param(lua_State * L, int idx, char const * opt_name, uns
|
||||||
push_string(L, opt_name);
|
push_string(L, opt_name);
|
||||||
lua_gettable(L, idx);
|
lua_gettable(L, idx);
|
||||||
if (lua_isnumber(L, -1)) {
|
if (lua_isnumber(L, -1)) {
|
||||||
long result = lua_tointeger(L, -1);
|
int64 result = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (result < 0 || result > std::numeric_limits<unsigned>::max())
|
if (result < 0 || result > static_cast<int64>(std::numeric_limits<unsigned>::max()))
|
||||||
throw exception(sstream() << "field '" << opt_name << "' must be a unsigned integer in table at arg #" << idx);
|
throw exception(sstream() << "field '" << opt_name << "' must be a unsigned integer in table at arg #" << idx);
|
||||||
return static_cast<unsigned>(result);
|
return static_cast<unsigned>(result);
|
||||||
} else if (lua_isnil(L, -1)) {
|
} else if (lua_isnil(L, -1)) {
|
||||||
|
@ -84,9 +85,9 @@ optional<unsigned> get_opt_uint_named_param(lua_State * L, int idx, char const *
|
||||||
push_string(L, opt_name);
|
push_string(L, opt_name);
|
||||||
lua_gettable(L, idx);
|
lua_gettable(L, idx);
|
||||||
if (lua_isnumber(L, -1)) {
|
if (lua_isnumber(L, -1)) {
|
||||||
long result = lua_tointeger(L, -1);
|
int64 result = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (result < 0 || result > std::numeric_limits<unsigned>::max())
|
if (result < 0 || result > static_cast<int64>(std::numeric_limits<unsigned>::max()))
|
||||||
throw exception(sstream() << "field '" << opt_name << "' must be a unsigned integer in table at arg #" << idx);
|
throw exception(sstream() << "field '" << opt_name << "' must be a unsigned integer in table at arg #" << idx);
|
||||||
return optional<unsigned>(static_cast<unsigned>(result));
|
return optional<unsigned>(static_cast<unsigned>(result));
|
||||||
} else if (lua_isnil(L, -1)) {
|
} else if (lua_isnil(L, -1)) {
|
||||||
|
|
Loading…
Reference in a new issue