Skip to content

Conversation

@iThorgrim
Copy link

@iThorgrim iThorgrim commented Nov 21, 2025

This PR need : azerothcore/azerothcore-wotlk#23838

Nothing has changed except for the includes; everything still works as before. This does not break anything and does not directly affect ALE. This is only the first part of the API modernization; this PR can be accepted without fear of breaking ALE.

Compilation tested:

  • Lua51-54: Static On/Off
  • LuaJIT: Static On/Off

Tested with the following script on all versions of Lua: https://github.com/iThorgrim/lua-paragon-anniversary

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Lua integration by replacing direct Lua C API usage with Sol2, a modern C++ binding library for Lua. The change maintains backward compatibility with Lua 5.1-5.4 and LuaJIT while providing a cleaner, more type-safe interface.

Key changes:

  • Introduced sol/config.hpp to configure Sol2 with Lua version detection, safety settings, and performance optimizations
  • Replaced all extern "C" Lua includes with #include <sol/sol.hpp> across the codebase
  • Removed the ALECompat compatibility layer (.h and .cpp files) as Sol2 provides built-in compatibility
  • Updated lua_dump calls to include the strip parameter (4th argument set to 0) for Lua 5.3+ compatibility
  • Modified CMake files to correct include paths and add conditional linking for static vs non-static Lua builds

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/sol/config.hpp New configuration file that sets up Sol2 with Lua version detection, safety features, performance optimizations, and compatibility settings for Lua 5.1-5.4 and LuaJIT
src/lualib/luajit/CMakeLists.txt Changed LuaJIT include directory from source folder to build folder for proper header location
src/lualib/lua/CMakeLists.txt Added conditional build logic to distinguish between static and non-static Lua library builds for lua_interpreter and lua_compiler executables
src/LuaEngine/lmarshal.h Replaced direct Lua C includes with Sol2 header
src/LuaEngine/lmarshal.cpp Updated include and fixed lua_dump call to include strip parameter
src/LuaEngine/LuaFunctions.cpp Removed Lua C includes (now provided by Sol2 via other headers)
src/LuaEngine/LuaEngine.h Replaced Lua C includes with Sol2 header
src/LuaEngine/LuaEngine.cpp Removed Lua C includes and ALECompat.h, updated lua_dump calls with strip parameter
src/LuaEngine/HttpManager.cpp Replaced Lua C includes with Sol2 header
src/LuaEngine/BindingMap.h Replaced Lua C includes with Sol2 header
src/LuaEngine/ALETemplate.h Replaced Lua C includes with Sol2 header and removed ALECompat.h dependency
src/LuaEngine/ALEIncludes.h Added Sol2 header include
src/LuaEngine/ALEEventMgr.cpp Replaced Lua C includes with Sol2 header
src/LuaEngine/ALECompat.h Removed file - compatibility functions no longer needed with Sol2
src/LuaEngine/ALECompat.cpp Removed file - compatibility implementations no longer needed with Sol2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Foereaper
Copy link

You should probably reconsider this approach. Direct C is much more performant than using an abstraction layer in most cases. The only real benefit of using a binding abstraction is for ease of maintenance, but these things rarely change and you can just write your own abstraction code if absolutely necessary (which is mostly already done).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants