Skip to content

Conversation

@CodeSmile-0000011110110111

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

@CodeSmile-0000011110110111
Copy link
Author

Please let me know if anything should be changed or improved.

Copy link
Collaborator

@Akeit0 Akeit0 left a 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
Copy link
Collaborator

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;
Copy link
Collaborator

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))
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead, use LuaState.TryGetMetatable.

Comment on lines +1 to +2
// Copyright (C) 2021-2025 Steffen Itterheim
// Refer to included LICENSE file for terms and conditions.
Copy link
Collaborator

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.

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

@nuskey8
Copy link
Owner

nuskey8 commented Aug 23, 2025

To be honest, I don't like the addition of ILuaEnumerable. Why introduce a new interface?

@Akeit0
Copy link
Collaborator

Akeit0 commented Aug 24, 2025

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.

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.

3 participants