From 1b421ff5052474a4ef5d3bd44fda2c078abd2db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateo=20Guzm=C3=A1n?= Date: Thu, 7 Aug 2025 06:13:08 -0700 Subject: [PATCH] Initial Kotlin setup and migrate `YogaConstants` Summary: # Changelog: [Internal] - As part of the ongoing effort to migrate the React Native codebase to Kotlin, this PR introduces the initial setup required for Kotlin support in Yoga. - Added initial basic Kotlin configuration to the project. - Migrated `YogaConstants` as an initial file to try out the first migration steps. X-link: https://github.com/facebook/yoga/pull/1829 Reviewed By: cortinico Differential Revision: D79545992 Pulled By: rshest --- .../java/com/facebook/yoga/YogaConstants.java | 25 ------------------- .../java/com/facebook/yoga/YogaConstants.kt | 18 +++++++++++++ 2 files changed, 18 insertions(+), 25 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.kt diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.java deleted file mode 100644 index f8205fc60c6..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.java +++ /dev/null @@ -1,25 +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. - */ - -package com.facebook.yoga; - -public class YogaConstants { - - public static final float UNDEFINED = Float.NaN; - - public static boolean isUndefined(float value) { - return Float.compare(value, UNDEFINED) == 0; - } - - public static boolean isUndefined(YogaValue value) { - return value.unit == YogaUnit.UNDEFINED; - } - - public static float getUndefined() { - return UNDEFINED; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.kt new file mode 100644 index 00000000000..eb768841bce --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/yoga/YogaConstants.kt @@ -0,0 +1,18 @@ +/* + * 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. + */ + +package com.facebook.yoga + +public object YogaConstants { + @JvmField public val UNDEFINED: Float = Float.NaN + + @JvmStatic public fun isUndefined(value: Float): Boolean = value.compareTo(UNDEFINED) == 0 + + @JvmStatic public fun isUndefined(value: YogaValue): Boolean = value.unit == YogaUnit.UNDEFINED + + @JvmStatic public fun getUndefined(): Float = UNDEFINED +}