From 97cf21dd41c7c2c111b9839e71d2cfc54239fd39 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 12 May 2026 18:22:02 -0700 Subject: [PATCH] Migrate YogaUnit enum to Kotlin (#56784) Summary: X-link: https://github.com/facebook/yoga/pull/1944 Pull Request resolved: https://github.com/facebook/react-native/pull/56784 Migrate YogaUnit.java to YogaUnit.kt by adding Unit to KOTLIN_ENUM_NAMES in enums.py and regenerating. Reviewed By: fabriziocucci Differential Revision: D104666347 fbshipit-source-id: 99f58b2d1cbea1592a3f4d1aa2608d42ba17e095 --- .../main/java/com/facebook/yoga/YogaUnit.java | 43 ------------------- .../main/java/com/facebook/yoga/YogaUnit.kt | 37 ++++++++++++++++ 2 files changed, 37 insertions(+), 43 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java deleted file mode 100644 index 5731a040d93..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// @generated by enums.py - -package com.facebook.yoga; - -public enum YogaUnit { - UNDEFINED(0), - POINT(1), - PERCENT(2), - AUTO(3), - MAX_CONTENT(4), - FIT_CONTENT(5), - STRETCH(6); - - private final int mIntValue; - - YogaUnit(int intValue) { - mIntValue = intValue; - } - - public int intValue() { - return mIntValue; - } - - public static YogaUnit fromInt(int value) { - switch (value) { - case 0: return UNDEFINED; - case 1: return POINT; - case 2: return PERCENT; - case 3: return AUTO; - case 4: return MAX_CONTENT; - case 5: return FIT_CONTENT; - case 6: return STRETCH; - default: throw new IllegalArgumentException("Unknown enum value: " + value); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.kt new file mode 100644 index 00000000000..9bd5d69673c --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaUnit.kt @@ -0,0 +1,37 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// @generated by enums.py + +package com.facebook.yoga + +public enum class YogaUnit(public val intValue: Int) { + UNDEFINED(0), + POINT(1), + PERCENT(2), + AUTO(3), + MAX_CONTENT(4), + FIT_CONTENT(5), + STRETCH(6); + + public fun intValue(): Int = intValue + + public companion object { + @JvmStatic + public fun fromInt(value: Int): YogaUnit = + when (value) { + 0 -> UNDEFINED + 1 -> POINT + 2 -> PERCENT + 3 -> AUTO + 4 -> MAX_CONTENT + 5 -> FIT_CONTENT + 6 -> STRETCH + else -> throw IllegalArgumentException("Unknown enum value: $value") + } + } +}