Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions yoga/YGMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
// the header is a mismatch for the Yoga ABI.
#define YG_ENUM_BEGIN(name) NS_ENUM(int, name)
#define YG_ENUM_END(name)
#elif defined(__clang__)
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) __attribute__((enum_extensibility(closed))) name
Copy link
Contributor

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

Copy link
Author

@iainsmith iainsmith Aug 26, 2024

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?

Copy link
Author

@iainsmith iainsmith Aug 26, 2024

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?

Copy link
Contributor

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!

Copy link
Author

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?

#else
#define YG_ENUM_BEGIN(name) enum name
#define YG_ENUM_END(name) name
Expand Down
Loading