Migrate YogaMeasureOutput
to Kotlin (#1842)
Summary: Migrate com.facebook.yoga.YogaMeasureOutput to Kotlin. Pull Request resolved: https://github.com/facebook/yoga/pull/1842 Test Plan: RN ```sh yarn android yarn test-android ``` Yoga ```sh ./gradlew :yoga:assembleDebug ``` Reviewed By: rshest Differential Revision: D79897681 Pulled By: cortinico fbshipit-source-id: 63280b6aed9bbeeb1e71458a1793c9647dcf0726
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d1037226c0
commit
cf50bc9adf
@@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
29
java/com/facebook/yoga/YogaMeasureOutput.kt
Normal file
29
java/com/facebook/yoga/YogaMeasureOutput.kt
Normal file
@@ -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())
|
||||||
|
}
|
Reference in New Issue
Block a user