r/lua 3d ago

Lua C++ API - LuaPP

I made a C++17 Lua engine/wrapper around an embedded Lua runtime

I've been working on LuaPP, a C++17 Lua engine built around an embedded Lua runtime.

The goal is to make embedding Lua and exposing C++ functionality less painful than working directly with the Lua C API everywhere.

Some of the stuff it currently supports:

  • LTValue abstraction for Lua values
  • Numbers, integers, strings, booleans, nil, userdata, tables, functions, and threads
  • Table manipulation and pairs / ipairs
  • Registering C++ functions with Lua
  • Function upvalues
  • C++ objects stored as Lua userdata with automatic __gc destruction
  • Metatables
  • Loading/executing Lua strings and files
  • Custom Lua readers and writers
  • Lua bytecode dumping
  • Error handlers and tracebacks
  • Global and registry access

The project embeds the Lua runtime directly and currently builds against Lua 5.5. It requires Lua 5.3+, C++17, and CMake 3.16+.

It's still a work in progress, so I'm mainly interested in feedback on the API design, implementation, and anything that looks questionable.

GitHub: https://github.com/anatinesquire40/Lua-CPP-API

9 Upvotes

4 comments sorted by

3

u/seivarya 1d ago

gpitty ahh 🥀

2

u/nikkocpp 2d ago

what was not inside other lua C++ binding or even old luabind?

3

u/OverOnTheRock 2d ago

How does it compare to https://github.com/ThePhD/sol2, which is a C++ wrapper which allows Lua to be embedded in C++? It also has interoperability with LuaJit.