From 5d5350b1e48336bc669aa972ebf316df7f9809df Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 12 May 2026 10:15:10 -0700 Subject: [PATCH] Migrate YogaLogLevel enum to Kotlin (#56794) Summary: X-link: https://github.com/facebook/yoga/pull/1943 Pull Request resolved: https://github.com/facebook/react-native/pull/56794 Migrate YogaLogLevel.java to YogaLogLevel.kt by adding LogLevel to KOTLIN_ENUM_NAMES in enums.py and regenerating. Also adds DO_NOT_STRIP support to the Kotlin codegen path to preserve the DoNotStrip annotation. Reviewed By: fabriziocucci Differential Revision: D104666343 fbshipit-source-id: 6307e0f72559d505a8db115d63669271cbd8754a --- .../java/com/facebook/yoga/YogaLogLevel.java | 45 ------------------- .../java/com/facebook/yoga/YogaLogLevel.kt | 39 ++++++++++++++++ 2 files changed, 39 insertions(+), 45 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java deleted file mode 100644 index 761f302eb29..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.java +++ /dev/null @@ -1,45 +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; - -import com.facebook.yoga.annotations.DoNotStrip; - -@DoNotStrip -public enum YogaLogLevel { - ERROR(0), - WARN(1), - INFO(2), - DEBUG(3), - VERBOSE(4), - FATAL(5); - - private final int mIntValue; - - YogaLogLevel(int intValue) { - mIntValue = intValue; - } - - public int intValue() { - return mIntValue; - } - - @DoNotStrip - public static YogaLogLevel fromInt(int value) { - switch (value) { - case 0: return ERROR; - case 1: return WARN; - case 2: return INFO; - case 3: return DEBUG; - case 4: return VERBOSE; - case 5: return FATAL; - default: throw new IllegalArgumentException("Unknown enum value: " + value); - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.kt new file mode 100644 index 00000000000..a8ff53fdd93 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaLogLevel.kt @@ -0,0 +1,39 @@ +/* + * 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 + +import com.facebook.yoga.annotations.DoNotStrip + +@DoNotStrip +public enum class YogaLogLevel(public val intValue: Int) { + ERROR(0), + WARN(1), + INFO(2), + DEBUG(3), + VERBOSE(4), + FATAL(5); + + public fun intValue(): Int = intValue + + public companion object { + @DoNotStrip + @JvmStatic + public fun fromInt(value: Int): YogaLogLevel = + when (value) { + 0 -> ERROR + 1 -> WARN + 2 -> INFO + 3 -> DEBUG + 4 -> VERBOSE + 5 -> FATAL + else -> throw IllegalArgumentException("Unknown enum value: $value") + } + } +}