New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to preserve metatable when exchanging data with the async env #14369
Conversation
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested and works
(if the CI fails now that would be embarassing)
Discussed in the meeting. https://irc.minetest.net/minetest-dev/2024-03-03#i_6156924 Contains more ideas for possible optimizations (not for this PR). |
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: sfan5 <sfan5@live.de>
* Complement documentation * Allow registering the same mt multiple times (+ test case)
Co-authored-by: sfan5 <sfan5@live.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
The code looks correct. Unit tests pass. I took the liberty to extend the async metatable registration test with a table with a custom, registered metatable.
My comments are nitpicks; do what you want with them.
I rebased because otherwise it wouldn't compile.
With #14451 it will become relevant to extend this mechanism to the mapgen env too. |
Add compact, short information about your PR for easier understanding:
This PR is similar to #14360 in terms of the goal (trying to preserve metatable information), but this one is implemented differently (and in a simpler way, as certain cases in
minetest.serialize
are irrelevant here). The two PRs are otherwise not related to each other.Preserve metatable information when passing data to/from the async environment
It keeps a mapping between certain metatables and a name, the latter of which is kept with the data when transferred to a different environment and then used to set the metatable on the reconstructed data.
Note that, unlike Try to preserve metatable information in minetest.serialize #14360, this PR only handles tables. It does not handle
userdata
objects as these are handled by C++ code directly.Fixes Vector metatable doesn't carry over to async environment #13644.
2. Bugfix; the issue linked above is labeled as a bug.
To do
This PR is Ready for Review.
How to test
The base test case for vectors should be covered by the unittests in the Devtest.
To test the modding API, use the following mod:
The above mod should print a line to the console: