Skip to content

Commit

Permalink
Deprecate YGConfigSetUseLegacyStretchBehaviour (facebook#37117)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#37117

X-link: facebook/yoga#1265

This deprecates `YGConfigSetUseLegacyStretchBehaviour` and `YGConfigGetUseLegacyStretchBehaviour`and points users to errata APIs instead. Using the C API will fire deprecation warnings, which should create errors in builds with `-Werror`, though they can be ignored if truly needed (like we do with the language bindings which need to expose their own deprecated interface).

Reviewed By: rshest

Differential Revision: D45337198

fbshipit-source-id: 8df4f73ee8bb0b7a58874f0e6b706d2e80220ba8
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Apr 29, 2023
1 parent 3a28ab3 commit 955e6a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ static void jni_YGConfigSetUseLegacyStretchBehaviourJNI(
jlong nativePointer,
jboolean useLegacyStretchBehaviour) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
YGConfigSetUseLegacyStretchBehaviour(config, useLegacyStretchBehaviour);
#pragma clang diagnostic pop
}

static void jni_YGConfigSetErrataJNI(
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native/ReactCommon/yoga/yoga/YGMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
#define YG_EXTERN_C_END
#endif

#if defined(__cplusplus)
#define YG_DEPRECATED(message) [[deprecated(message)]]
#elif defined(_MSC_VER)
#define YG_DEPRECATED(message) __declspec(depreacted(message))
#else
#define YG_DEPRECATED(message) __attribute__((deprecated(message)))
#endif

#ifdef _WINDLL
#define WIN_EXPORT __declspec(dllexport)
#else
Expand Down
15 changes: 13 additions & 2 deletions packages/react-native/ReactCommon/yoga/yoga/Yoga.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,19 @@ WIN_EXPORT void YGConfigSetPointScaleFactor(
// resulted in implicit behaviour similar to align-self: stretch; Because this
// was such a long-standing bug we must allow legacy users to switch back to
// this behaviour.
WIN_EXPORT bool YGConfigGetUseLegacyStretchBehaviour(YGConfigRef config);
WIN_EXPORT void YGConfigSetUseLegacyStretchBehaviour(
WIN_EXPORT YG_DEPRECATED(
"Please use "
"\"YGConfigGetErrata()\"") bool YGConfigGetUseLegacyStretchBehaviour(YGConfigRef
config);
WIN_EXPORT
YG_DEPRECATED(
"\"YGConfigSetUseLegacyStretchBehaviour\" will be removed in the next "
"release. Usage should be replaced with \"YGConfigSetErrata(YGErrataAll)\" "
"to opt out of all future breaking conformance fixes, or "
"\"YGConfigSetErrata(YGErrataStretchFlexBasis)\" to opt out of the "
"specific conformance fix previously disabled by "
"\"UseLegacyStretchBehaviour\".")
void YGConfigSetUseLegacyStretchBehaviour(
YGConfigRef config,
bool useLegacyStretchBehaviour);

Expand Down

0 comments on commit 955e6a8

Please sign in to comment.