diff --git a/java/com/facebook/yoga/YogaMeasureOutput.java b/java/com/facebook/yoga/YogaMeasureOutput.java deleted file mode 100644 index c7a77aba..00000000 --- a/java/com/facebook/yoga/YogaMeasureOutput.java +++ /dev/null @@ -1,32 +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; - -/** - * Helpers for building measure output value. - */ -public class YogaMeasureOutput { - - public static long make(float width, float height) { - final int wBits = Float.floatToRawIntBits(width); - final int hBits = Float.floatToRawIntBits(height); - return ((long) wBits) << 32 | ((long) hBits); - } - - public static long make(int width, int height) { - return make((float) width, (float) height); - } - - public static float getWidth(long measureOutput) { - return Float.intBitsToFloat((int) (0xFFFFFFFF & (measureOutput >> 32))); - } - - public static float getHeight(long measureOutput) { - return Float.intBitsToFloat((int) (0xFFFFFFFF & measureOutput)); - } -} diff --git a/java/com/facebook/yoga/YogaMeasureOutput.kt b/java/com/facebook/yoga/YogaMeasureOutput.kt new file mode 100644 index 00000000..9185ef46 --- /dev/null +++ b/java/com/facebook/yoga/YogaMeasureOutput.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. + */ + +package com.facebook.yoga + +/** Helpers for building measure output value. */ +public object YogaMeasureOutput { + @JvmStatic + public fun make(width: Float, height: Float): Long { + val wBits = java.lang.Float.floatToRawIntBits(width) + val hBits = java.lang.Float.floatToRawIntBits(height) + return (wBits.toLong()) shl 32 or (hBits.toLong()) + } + + @JvmStatic + public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat()) + + @JvmStatic + public fun getWidth(measureOutput: Long): Float = + java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt()) + + @JvmStatic + public fun getHeight(measureOutput: Long): Float = + java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt()) +}