Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10)
cmake_policy (SET CMP0169 OLD)

include(FetchContent)

Expand Down
2 changes: 2 additions & 0 deletions Benchmarks/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
matplotlib
numpy
7 changes: 5 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
## Master

## Version 3.0

* Moved to C++17 as minimum supported standard C++ version.
Expand All @@ -17,6 +15,11 @@
* Allow specifying a non virtual base class method when declaring class members (functions or variables) not exposed in the inherited class.
* Allow using capturing lambdas in `Namespace::addFunction`, `Namespace::addProperty`, `Class<T>::addFunction`, `Class<T>::addStaticFunction`, `Class<T>::addProperty` and `Class<T>::addStaticProperty`.
* Added multiple inheritance support: `deriveClass` now accepts more than one registered base class (e.g. `deriveClass<D, A, B>`).
* Added C++20 coroutine integration: `CppCoroutine<R>` type that can be registered via `Namespace::addCoroutine()` to expose C++ generators to Lua using `co_yield` and `co_return`.
* Added `LuaCoroutine` awaitable to resume a child Lua thread synchronously from inside a `CppCoroutine` body using `co_await`.
* Added `lua_resume_x` and `lua_isyieldable_x` portable helpers in `LuaBridge/detail/LuaHelpers.h`.
* Added `LUABRIDGE_HAS_CXX20_COROUTINES` feature-detection macro; opt out with `LUABRIDGE_DISABLE_CXX20_COROUTINES`.
* Added `ErrorCode::CoroutineYieldFromNonCoroutine` and `ErrorCode::CoroutineAlreadyDone` error codes.
* Added `Namespace::addVariable` to allow adding a modifiable value by copy into the namespace without incurring in function calls or metatables generation.
* Added `luabridge::callWithHandler` free function and `LuaRef::callWithHandler` member to provide a custom Lua message handler during `lua_pcall`.
* Added `luabridge::newFunction` free function and `LuaRef::newFunction` static method to wrap any C++ callable into a Lua function exposed as a `LuaRef`.
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project (LuaBridge)

include (CMakeDependentOption)

set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)

Expand Down
Binary file modified Images/benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
262 changes: 256 additions & 6 deletions Manual.md

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
[LuaBridge3](https://github.com/kunitoki/LuaBridge3) is a lightweight and dependency-free library for mapping data,
functions, and classes back and forth between C++ and [Lua](http://wwww.lua.org) (a powerful,
fast, lightweight, embeddable scripting language). LuaBridge has been tested
and works with Lua 5.1.5, 5.2.4, 5.3.6, 5.4.8 and 5.5.0 as well as [LuaJit](https://luajit.org/) 2.1 onwards
and for the first time also with [Luau](https://luau-lang.org/) 0.713 onwards and [Ravi](https://github.com/dibyendumajumdar/ravi) 1.0-beta11.
and works with:
* [PUC-Lua](https://lua.org) 5.1.5, 5.2.4, 5.3.6, 5.4.8 and 5.5.0
* [LuaJit](https://luajit.org/) 2.1
* [Luau](https://luau-lang.org/) 0.713
* [Ravi](https://github.com/dibyendumajumdar/ravi) 1.0-beta11

## Features

Expand Down Expand Up @@ -87,6 +90,7 @@ LuaBridge3 offers a set of improvements compared to vanilla LuaBridge:
* Consistent numeric handling and conversions (signed, unsigned and floats) across all lua versions.
* NaN and Inf values pass through floating-point stack conversions without error.
* Simplified registration of enum types via the `luabridge::Enum` stack wrapper.
* C++20 coroutine integration via `addCoroutine()` and `CppCoroutine<R>`; await Lua threads from C++ with `LuaCoroutine`.
* Opt-out handling of safe stack space checks (automatically avoids exhausting lua stack space when pushing values!).
* Optional strict stack conversions via `LUABRIDGE_STRICT_STACK_CONVERSIONS` (e.g. `bool` requires an actual boolean, not any truthy value).
* Error handler support in Lua calls via `LuaRef::callWithHandler` and `luabridge::callWithHandler`.
Expand Down
1 change: 1 addition & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set (LUABRIDGE_DETAIL_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/CFunctions.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/ClassInfo.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Config.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Coroutine.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Enum.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Errors.h
${CMAKE_CURRENT_SOURCE_DIR}/LuaBridge/detail/Expected.h
Expand Down
1 change: 1 addition & 0 deletions Source/LuaBridge/LuaBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "detail/CFunctions.h"
#include "detail/ClassInfo.h"
#include "detail/Coroutine.h"
#include "detail/Enum.h"
#include "detail/Errors.h"
#include "detail/Expected.h"
Expand Down
38 changes: 26 additions & 12 deletions Source/LuaBridge/detail/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@
#error LuaBridge 3 requires a compliant C++17 compiler, or C++17 has not been enabled !
#endif

#if defined(LUAU_FASTMATH_BEGIN)
#define LUABRIDGE_ON_LUAU 1
#elif defined(LUAJIT_VERSION)
#define LUABRIDGE_ON_LUAJIT 1
#elif defined(RAVI_OPTION_STRING2)
#define LUABRIDGE_ON_RAVI 1
#elif defined(LUA_VERSION_NUM)
#define LUABRIDGE_ON_LUA 1
#else
#error "Lua headers must be included prior to LuaBridge ones"
#endif

/**
* @brief Enable C++20 coroutine integration with Lua coroutines.
*
* Requires C++20 and Lua 5.2+ (lua_yieldk). Not supported on Lua 5.1, LuaJIT, or Luau.
* Define LUABRIDGE_DISABLE_CXX20_COROUTINES to force-disable even when C++20 is available.
*/
#if !defined(LUABRIDGE_HAS_CXX20_COROUTINES)
#if !defined(LUABRIDGE_DISABLE_CXX20_COROUTINES) && (__cplusplus >= 202002L || (defined(_MSC_VER) && _HAS_CXX20)) && !(LUABRIDGE_ON_LUAU || LUABRIDGE_ON_LUAJIT || LUABRIDGE_ON_RAVI || LUA_VERSION_NUM < 502)
#define LUABRIDGE_HAS_CXX20_COROUTINES 1
#else
#define LUABRIDGE_HAS_CXX20_COROUTINES 0
#endif
#endif

#if !defined(LUABRIDGE_HAS_EXCEPTIONS)
#if defined(_MSC_VER)
#if _CPPUNWIND || _HAS_EXCEPTIONS
Expand Down Expand Up @@ -48,18 +74,6 @@
#define LUABRIDGE_NO_SANITIZE(x)
#endif

#if defined(LUAU_FASTMATH_BEGIN)
#define LUABRIDGE_ON_LUAU 1
#elif defined(LUAJIT_VERSION)
#define LUABRIDGE_ON_LUAJIT 1
#elif defined(RAVI_OPTION_STRING2)
#define LUABRIDGE_ON_RAVI 1
#elif defined(LUA_VERSION_NUM)
#define LUABRIDGE_ON_LUA 1
#else
#error "Lua headers must be included prior to LuaBridge ones"
#endif

#if defined(__OBJC__)
#define LUABRIDGE_ON_OBJECTIVE_C 1
#endif
Expand Down
Loading
Loading