-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 using Yoga from swift on non Darwin platforms. #1690
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @iainsmith! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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 breaks the build on non-Clang platforms.
@@ -49,7 +49,7 @@ | |||
#define YG_ENUM_END(name) | |||
#else | |||
#define YG_ENUM_BEGIN(name) enum name | |||
#define YG_ENUM_END(name) name | |||
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name |
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.
A couple of these are flag enums, which would also need to be declared I think
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.
@NickGerleman Are the only bitmask flags YGErrata & YGExperimentalFeature
or are there others?
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.
Just realised that enums.py specifies that only Errata
is a bitset enum.
How do you feel about us adding a YG_ENUM_FLAG_DECL
macro, and then updating enums.py to check BITSET_ENUMS
to decide on which macro to use?
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.
That sounds good to me!
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.
@NickGerleman , I took a quick stab at this on this branch, but I've run into a compiler error I'm not sure how to approach.
~/Developer/personal/yoga/yoga/../yoga/YGEnums.h:61:5:
error: enumeration value 'YGErrataClassic' is out of range of flags in enumeration type 'YGErrata' [-Werror,-Wflag-enum]
61 | YGErrataClassic = 2147483646,
| ^
~/Developer/personal/yoga/yoga/../yoga/YGEnums.h:62:5:
error: enumeration value 'YGErrataAll' is out of range of flags in enumeration type 'YGErrata' [-Werror,-Wflag-enum]
62 | YGErrataAll = 2147483647)
Do you have thoughts on the best way to handle that?
Makes sense. I'll push a change to wrap this in a clang check. Should be fixed now. Quickly tested with note to self. /usr/bin/gcc on mac is a wrapper around clang. |
Specify that enums are closed for correct swift export on non darwin platforms.
Related Yoga Issue
Swift exports plain c enums as constants. On Darwin the yoga macros hit the NS_ENUM case which generates a swift enum, however on linux NS_ENUM is not defined.
See [This post] for a some more background. https://belkadan.com/blog/2021/10/Swift-Regret-Unannotated-C-Enums/
Tested on a couple of CI builds:
Which results in a compiler error for the missing switch cases.