-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add support for typed and scoped enums #3
Conversation
Make sure that this doesn't lose any of our current API. Compile Cuberite without these changes, run it and issue the |
I tested this changes by comparing the generated Bindings.cpp. The only difference is the line with the time stamp. Is that enough as check? |
Yes, that's a good enough check. |
I'm not too sure about the types with names. What is that for? And does the ToLua runtime lib support it? |
@madmaxoft |
Sorry, I meant types with spaces. |
Oh that's simple enough, it just means you can write
|
Oh, so it's only parser-side, not in the runtime. |
-- This code is free software; you can redistribute it and/or modify it. | ||
-- The software provided hereunder is on an "as is" basis, and | ||
-- the author has no obligation to provide maintenance, support, updates, | ||
-- enhancements, or modifications. |
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.
I think it's safe to say that this copyright is not what you meant, unless you are secretly Waldemar :)
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.
Well it was all just copied from enumerate.lua
with some minor tweaks. I haven't looked at the license though.
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.
Is the way it is now OK? If not I might need a bit of help for what to put.
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.
Good enough for me.
Is there anything stopping this from getting merged? |
Ah should have done a squash merge... |
Is there any reason why the ScopedEnum is created anew, instead of putting it inside the regular Enum? I'm trying to fix in-class enum handling and now there's duplicate code. |
The main differences are the extra namespace qualifier to access the enum, and in Though I don't think it's related to where the enum is declared; could you explain the issue with in-class enums? |
I guess I'll rewrite it like that. The problem with in-class enums is when two classes each have an enum with the same name: class cClassA
{
enum eType { ... };
};
class cClassB
{
enum eType { ... };
}, The parser doesn't use fully-qualified type names for some parts and ends up generating invalid code or mixing up the values. |
@peterbell10 If you look into the generated |
Say I have in the c++ side:
This will be usable in lua as
EffectID.SFX_MOB_GHAST_WARN
.