diff --git a/.gitignore b/.gitignore index ac54ec14..7a7c132d 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ lua53.dll main.exe main.o lua-5.3.3/ -*.pdf main.lua LuaJIT-2.1.0/ +lua-5.3.3-cxx/ +lua-5.3.3.vcxproj-cxx.filters diff --git a/docs/presentations/ThePhD - No Overhead C Abstraction - 2016.10.14.pdf b/docs/presentations/ThePhD - No Overhead C Abstraction - 2016.10.14.pdf new file mode 100644 index 00000000..51c674b9 Binary files /dev/null and b/docs/presentations/ThePhD - No Overhead C Abstraction - 2016.10.14.pdf differ diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index bd277389..faeff5de 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2016-10-11 10:53:03.759428 UTC -// This header was generated with sol v2.14.10 (revision 866a297) +// Generated 2016-10-15 21:59:41.897573 UTC +// This header was generated with sol v2.14.10 (revision f3fbd24) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -4696,6 +4696,34 @@ namespace sol { } }; + template + struct checker::value>> { + template + static bool check(lua_State* L, int index, Handler&& handler, record& tracking) { + tracking.use(1); + bool success = lua_isinteger(L, index) == 1; + if (!success) { + // expected type, actual type + handler(L, index, type::number, type_of(L, index)); + } + return success; + } + }; + + template + struct checker::value>> { + template + static bool check(lua_State* L, int index, Handler&& handler, record& tracking) { + tracking.use(1); + bool success = lua_isnumber(L, index) == 1; + if (!success) { + // expected type, actual type + handler(L, index, type::number, type_of(L, index)); + } + return success; + } + }; + template struct checker { template diff --git a/sol/stack_check.hpp b/sol/stack_check.hpp index bf9faa1e..9ac0db75 100644 --- a/sol/stack_check.hpp +++ b/sol/stack_check.hpp @@ -77,6 +77,34 @@ namespace sol { } }; + template + struct checker::value>> { + template + static bool check(lua_State* L, int index, Handler&& handler, record& tracking) { + tracking.use(1); + bool success = lua_isinteger(L, index) == 1; + if (!success) { + // expected type, actual type + handler(L, index, type::number, type_of(L, index)); + } + return success; + } + }; + + template + struct checker::value>> { + template + static bool check(lua_State* L, int index, Handler&& handler, record& tracking) { + tracking.use(1); + bool success = lua_isnumber(L, index) == 1; + if (!success) { + // expected type, actual type + handler(L, index, type::number, type_of(L, index)); + } + return success; + } + }; + template struct checker { template diff --git a/tests.cpp b/tests.cpp index 94613ca5..a236d046 100644 --- a/tests.cpp +++ b/tests.cpp @@ -678,3 +678,26 @@ TEST_CASE("compilation/const-regression", "make sure constness in tables is resp State* s = state.state_.registry()["state"]; REQUIRE(s == &state); } + +TEST_CASE("numbers/integers", "make sure integers are detectable on most platforms") { + sol::state lua; + + lua["a"] = 50; // int + lua["b"] = 50.5; // double + + sol::object a = lua["a"]; + sol::object b = lua["b"]; + + bool a_is_int = a.is(); + bool a_is_double = a.is(); + + bool b_is_int = b.is(); + bool b_is_double = b.is(); + + REQUIRE(a_is_int); + REQUIRE(a_is_double); + + // TODO: will this fail on certain lower Lua versions? + REQUIRE_FALSE(a_is_int); + REQUIRE(a_is_double); +}