Skip to content

Commit cf50bc9

Browse files
mateoguzmanafacebook-github-bot
authored andcommitted
Migrate YogaMeasureOutput to Kotlin (#1842)
Summary: Migrate com.facebook.yoga.YogaMeasureOutput to Kotlin. Pull Request resolved: #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
1 parent d103722 commit cf50bc9

2 files changed

Lines changed: 29 additions & 32 deletions

File tree

java/com/facebook/yoga/YogaMeasureOutput.java

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.yoga
9+
10+
/** Helpers for building measure output value. */
11+
public object YogaMeasureOutput {
12+
@JvmStatic
13+
public fun make(width: Float, height: Float): Long {
14+
val wBits = java.lang.Float.floatToRawIntBits(width)
15+
val hBits = java.lang.Float.floatToRawIntBits(height)
16+
return (wBits.toLong()) shl 32 or (hBits.toLong())
17+
}
18+
19+
@JvmStatic
20+
public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat())
21+
22+
@JvmStatic
23+
public fun getWidth(measureOutput: Long): Float =
24+
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt())
25+
26+
@JvmStatic
27+
public fun getHeight(measureOutput: Long): Float =
28+
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt())
29+
}

0 commit comments

Comments
 (0)