Skip to content

Commit 8ae1795

Browse files
committed
Migrate YogaMeasureOutput to Kotlin
1 parent 8bf7a34 commit 8ae1795

2 files changed

Lines changed: 25 additions & 32 deletions

File tree

java/com/facebook/yoga/YogaMeasureOutput.java

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
public fun make(width: Float, height: Float): Long {
13+
val wBits = java.lang.Float.floatToRawIntBits(width)
14+
val hBits = java.lang.Float.floatToRawIntBits(height)
15+
return (wBits.toLong()) shl 32 or (hBits.toLong())
16+
}
17+
18+
public fun make(width: Int, height: Int): Long = make(width.toFloat(), height.toFloat())
19+
20+
public fun getWidth(measureOutput: Long): Float =
21+
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and (measureOutput shr 32)).toInt())
22+
23+
public fun getHeight(measureOutput: Long): Float =
24+
java.lang.Float.intBitsToFloat((0xFFFFFFFFL and measureOutput).toInt())
25+
}

0 commit comments

Comments
 (0)