Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request makes several improvements and refactorings to the LuaBridge library and its benchmarks, focusing on safer and more convenient Lua-C++ interop, enhanced API usability, and improved code correctness. The main changes include introducing new helper functions for safer field access, enhancing move semantics and API annotations for
LuaRef, and updating member function binding to improve type safety. Additionally, some benchmark code is simplified to use the new helpers.LuaBridge API Improvements and Refactoring:
tryGetGlobalFieldandtryGetFieldhelper functions for safer, optional field access from Lua tables and globals, reducing boilerplate and potential errors when a field or table is missing. (Distribution/LuaBridge/LuaBridge.h[1] [2]LuaRef::TableItemwith move constructors, assignment operators, and aswapmethod, improving efficiency and safety in resource management. (Distribution/LuaBridge/LuaBridge.h[1] [2]LuaRef::operator[]to support move semantics and more flexible table item access. (Distribution/LuaBridge/LuaBridge.hDistribution/LuaBridge/LuaBridge.hR10474-R10514)[[nodiscard]]to encourage correct usage and prevent accidental discarding of important return values (e.g.,getField,rawgetField,setField,rawsetField,length,append,rawget). (Distribution/LuaBridge/LuaBridge.h[1] [2] [3] [4] [5] [6]Member Function Binding and Userdata Handling:
get_member_objectandUserdata::getExactPointerhelpers for more robust and type-safe object retrieval from Lua. (Distribution/LuaBridge/LuaBridge.h[1] [2] [3] [4] [5] [6] [7]Hashing, Comparison, and Miscellaneous Fixes:
LuaRef::hash()to use the Lua value on the stack and type-specific hashing, improving correctness and consistency. (Distribution/LuaBridge/LuaBridge.hDistribution/LuaBridge/LuaBridge.hL10493-R10677)LuaRefand other types to ensure proper logic. (Distribution/LuaBridge/LuaBridge.hDistribution/LuaBridge/LuaBridge.hL10559-R10732)LuaRefBase::getClassNameconst, and cleaned up tuple type usage inbind_back. (Distribution/LuaBridge/LuaBridge.h[1] [2]Benchmark Code Simplification:
tryGetGlobalFieldhelper, reducing manual table checks and field access logic. (Benchmarks/benchmark_luabridge3.cpp[1] [2] [3]Array and Vector Lua Table Conversion:
lua_rawsetifor more efficient and idiomatic Lua table population. (Distribution/LuaBridge/LuaBridge.h[1] [2]