Skip to content

Custom converters#237

Merged
kunitoki merged 7 commits intomasterfrom
dev/custom_converters
May 9, 2026
Merged

Custom converters#237
kunitoki merged 7 commits intomasterfrom
dev/custom_converters

Conversation

@kunitoki
Copy link
Copy Markdown
Owner

@kunitoki kunitoki commented May 8, 2026

No description provided.

@kunitoki kunitoki self-assigned this May 8, 2026
@kunitoki kunitoki added enhancement New feature or request wip labels May 8, 2026
kunitoki added 4 commits May 8, 2026 19:40
Removed mention of C++20 coroutine interop from benchmark suite description.
Copy link
Copy Markdown

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 introduces opt-in custom converters that allow LuaBridge3 to convert a registered userdata source type (From) into a C++ target value type (To) while extracting function arguments from the Lua stack (a “Phase 3” fallback after exact match and inheritance).

Changes:

  • Adds converter infrastructure (StackConversion, StackConverter, converter registry storage) and a new .addConverter<To>() registration API.
  • Updates stack extraction to support Phase-3 conversion for converter-enabled target types (including const T& call sites).
  • Adds comprehensive tests, documentation, and benchmark cases (plus benchmark plotting improvements with stddev/error bars).

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Tests/Source/ConverterTests.cpp New unit tests validating converter registration, Phase-3 extraction, multi-source conversion, and inheritance/multiple-inheritance scenarios.
Tests/CMakeLists.txt Adds the new converter test source file to the test target.
Source/LuaBridge/LuaBridge.h Adds a top-level include for the new converter header.
Source/LuaBridge/detail/Stack.h Adjusts Stack specializations to route converter-enabled const T& through the new converter-aware implementation.
Source/LuaBridge/detail/Namespace.h Adds .addConverter<To>() API on Class<T> to register converters into a per-class registry.
Source/LuaBridge/detail/Converter.h New converter system header: opt-in traits, registry, dispatch, and Stack specializations for converter-enabled targets.
Source/LuaBridge/detail/ClassInfo.h Adds a dedicated Lua metatable key for storing the converter registry userdata.
README.md Expands benchmark methodology/coverage description to mention custom type converters.
Manual.md Documents “Custom Type Converters”, adds API reference entries, and updates table of contents links.
justfile Adds convenience build/test recipes.
Distribution/LuaBridge/LuaBridge.h Updates the amalgamated header to include converter support and related includes.
Benchmarks/plot_benchmarks.py Adds stddev support and error bars, improves ordering/styling, switches to pathlib.
Benchmarks/benchmark_sol3.cpp Renames a benchmark function for consistent naming.
Benchmarks/benchmark_luabridge3.cpp Adds converter benchmarks and converter trait specializations for benchmark types.
Benchmarks/benchmark_luabridge.cpp Renames a benchmark function for consistent naming.
Benchmarks/benchmark_common.hpp Adds benchmark types/functions used by the new converter benchmarks.

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

Comment thread Source/LuaBridge/LuaBridge.h
Comment thread Source/LuaBridge/detail/Namespace.h Outdated
Comment thread Source/LuaBridge/detail/Converter.h
Comment thread Source/LuaBridge/detail/Converter.h Outdated
Comment thread Benchmarks/plot_benchmarks.py
Comment thread Source/LuaBridge/detail/Converter.h Outdated
@kunitoki kunitoki merged commit b892ce0 into master May 9, 2026
45 checks passed
@kunitoki kunitoki deleted the dev/custom_converters branch May 9, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request wip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants