MCPcopy Create free account
hub / github.com/OpenMW/openmw / getInteger

Function getInteger

components/lua/utf8.cpp:16–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 }
15
16 inline std::int64_t getInteger(const sol::stack_proxy arg, const size_t n, std::string_view name)
17 {
18 double integer;
19 if (!arg.is<double>())
20 throw std::runtime_error(std::format("bad argument #{} to '{}' (number expected, got {})", n, name,
21 sol::type_name(arg.lua_state(), arg.get_type())));
22
23 if (std::modf(arg, &integer) != 0)
24 throw std::runtime_error(
25 std::format("bad argument #{} to '{}' (number has no integer representation)", n, name));
26
27 return static_cast<std::int64_t>(integer);
28 }
29
30 // If the input 'pos' is negative, it is treated as counting from the end of the string,
31 // where -1 represents the last character position, -2 represents the second-to-last position,

Callers 1

initUtf8PackageFunction · 0.85

Calls 4

formatFunction · 0.85
type_nameFunction · 0.85
lua_stateMethod · 0.45
get_typeMethod · 0.45

Tested by

no test coverage detected