From 1e2079b18b9ce89c0e30a03b787f6adac5f65b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Thu, 19 Feb 2026 14:56:30 -0800 Subject: [PATCH] Generate Kotlin files with enums.py Summary: This PR extends enums.py to also write Kotlin files. To introduce this in the least breaking manner, we can gradually do one by one and at the end clean up the Java script. Migrate YogaDirection to Kotlin. Changelog: [Internal] X-link: https://github.com/facebook/yoga/pull/1845 Reviewed By: cortinico Differential Revision: D93555645 Pulled By: NickGerleman --- .../java/com/facebook/yoga/YogaDirection.java | 35 ------------------- .../java/com/facebook/yoga/YogaDirection.kt | 29 +++++++++++++++ 2 files changed, 29 insertions(+), 35 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java deleted file mode 100644 index 7cedba3a05e6..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.java +++ /dev/null @@ -1,35 +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 YogaDirection { - INHERIT(0), - LTR(1), - RTL(2); - - private final int mIntValue; - - YogaDirection(int intValue) { - mIntValue = intValue; - } - - public int intValue() { - return mIntValue; - } - - public static YogaDirection fromInt(int value) { - switch (value) { - case 0: return INHERIT; - case 1: return LTR; - case 2: return RTL; - default: throw new IllegalArgumentException("Unknown enum value: " + value); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.kt new file mode 100644 index 000000000000..6b0248d83a0d --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaDirection.kt @@ -0,0 +1,29 @@ +/* + * 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 YogaDirection(public val intValue: Int) { + INHERIT(0), + LTR(1), + RTL(2); + + public fun intValue(): Int = intValue + + public companion object { + @JvmStatic + public fun fromInt(value: Int): YogaDirection = + when (value) { + 0 -> INHERIT + 1 -> LTR + 2 -> RTL + else -> throw IllegalArgumentException("Unknown enum value: $value") + } + } +}