Skip to content

Commit f24bb19

Browse files
committed
More stack tests and cleanups
1 parent ed3a2a8 commit f24bb19

File tree

7 files changed

+988
-130
lines changed

7 files changed

+988
-130
lines changed

Diff for: CHANGES.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Added support for `std::byte` as stack value type.
2727
* Added support for `std::string_view` as stack value type.
2828
* Added support for `std::tuple` as stack value type.
29-
* Added support for `std::optional` as stack value type by using `LuaBridge/Optional.h`.
29+
* Added support for `std::optional` as stack value type.
3030
* Added support for `std::set` as stack value type by using `LuaBridge/Set.h`.
3131
* Added single header amalgamated distribution file, to simplify including in projects.
3232
* Added more asserts for functions and property names.
@@ -39,6 +39,7 @@
3939
* Changed all generic functions in `LuaRef` and `TableItem` to accept arguments by const reference instead of by copy.
4040
* Fixed issue when `LuaRef::cast<>` fails with exceptions enabled, popping from the now empty stack could trigger the panic handler twice.
4141
* Fixed unaligned access in user allocated member pointers in 64bit machines reported by ASAN.
42+
* Included testing against Luau VM
4243
* Bumped lua 5.2.x in unit tests from lua 5.2.0 to 5.2.4.
4344
* Bumped lua 5.4.x in unit tests from lua 5.4.1 to 5.4.3.
4445
* Run against lua 5.3.6 and 5.4.3 in unit tests.

Diff for: Source/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ set (LUABRIDGE_HEADERS
55
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/List.h
66
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/LuaBridge.h
77
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Map.h
8-
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Optional.h
98
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/RefCountedObject.h
109
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/Set.h
1110
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/UnorderedMap.h

Diff for: Source/LuaBridge/Optional.h

-49
This file was deleted.

Diff for: Source/LuaBridge/detail/LuaHelpers.h

+32
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,38 @@ void* lua_newuserdata_aligned(lua_State* L, Args&&... args)
324324
return pointer;
325325
}
326326

327+
/**
328+
* @brief Checks if the value on the stack is a number type and can fit into the corresponding c++ numerical type..
329+
*/
330+
template <class T>
331+
inline bool is_integral_instance(lua_State* L, int index)
332+
{
333+
if (lua_type(L, index) == LUA_TNUMBER)
334+
{
335+
const auto value = luaL_checkinteger(L, index);
336+
return value >= std::numeric_limits<T>::min()
337+
&& value <= std::numeric_limits<T>::max();
338+
}
339+
340+
return false;
341+
}
342+
343+
/**
344+
* @brief Checks if the value on the stack is a number type and can fit into the corresponding c++ numerical type..
345+
*/
346+
template <class T>
347+
inline bool is_floating_point_instance(lua_State* L, int index)
348+
{
349+
if (lua_type(L, index) == LUA_TNUMBER)
350+
{
351+
const auto value = luaL_checknumber(L, index);
352+
return value >= std::numeric_limits<T>::min()
353+
&& value <= std::numeric_limits<T>::max();
354+
}
355+
356+
return false;
357+
}
358+
327359
/**
328360
* @brief Helper to write a lua string error.
329361
*/

0 commit comments

Comments
 (0)