-
Notifications
You must be signed in to change notification settings - Fork 42
enable pairs/ipairs and next for ILuaUserData #207
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
base: v0.5-dev
Are you sure you want to change the base?
enable pairs/ipairs and next for ILuaUserData #207
Conversation
|
Please let me know if anything should be changed or improved. |
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.
Almost good.
However, adding ILuaEnumerable requires permission from @nuskey8 .
| namespace Lua; | ||
|
|
||
| public sealed class LuaTable : IEnumerable<KeyValuePair<LuaValue, LuaValue>> | ||
| public interface ILuaEnumerable |
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.
Separate files for this interface.
| } | ||
| else if (arg0.TryRead(out ILuaUserData userdata)) | ||
| { | ||
| metatable = userdata.Metatable; |
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.
Instead, use LuaState.TryGetMetatable.
| metatable = table.Metatable; | ||
| } | ||
| else if (arg0.TryRead(out ILuaUserData userdata)) | ||
| { |
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.
Instead, use LuaState.TryGetMetatable.
| // Copyright (C) 2021-2025 Steffen Itterheim | ||
| // Refer to included LICENSE file for terms and conditions. |
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.
This is not your repository.
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.
sorry about that, it's an automation in my IDE that adds these
|
To be honest, I don't like the addition of |
|
I think it's not bad that we can iterate key/values without preparing the original __pairs and next, but it may be debatable whether it's worth adding. |
I have a need for pairs/ipairs to work on userdata so I went ahead.
For "next" to support enumeration of userdata I had to add a
ILuaEnumerable.I'll add a test case as soon as I figured out where that went (it's stashed somewhere, I hope).
In relation to #205
#205