Skip to content

Commit 90811f9

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Migrate YogaLogLevel enum to Kotlin
Summary: Migrate YogaLogLevel.java to YogaLogLevel.kt by adding LogLevel to KOTLIN_ENUM_NAMES in enums.py and regenerating. Also adds DO_NOT_STRIP support to the Kotlin codegen path to preserve the DoNotStrip annotation. Differential Revision: D104666343
1 parent e45ec80 commit 90811f9

3 files changed

Lines changed: 45 additions & 45 deletions

File tree

enums.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"GridTrackType",
109109
"Gutter",
110110
"Justify",
111+
"LogLevel",
111112
}
112113

113114
ENUMS_KOTLIN = {name: ENUMS[name] for name in KOTLIN_ENUM_NAMES}
@@ -307,6 +308,9 @@ def to_hyphenated_lower(symbol):
307308
with open(root + "/java/com/facebook/yoga/Yoga%s.kt" % name, "w") as f:
308309
f.write(get_license("kotlin"))
309310
f.write("package com.facebook.yoga\n\n")
311+
if name in DO_NOT_STRIP:
312+
f.write("import com.facebook.yoga.annotations.DoNotStrip\n\n")
313+
f.write("@DoNotStrip\n")
310314
f.write("public enum class Yoga%s(public val intValue: Int) {\n" % name)
311315
if len(values) > 0:
312316
for value in values:
@@ -324,6 +328,8 @@ def to_hyphenated_lower(symbol):
324328
f.write(" public fun intValue(): Int = intValue\n")
325329
f.write("\n")
326330
f.write(" public companion object {\n")
331+
if name in DO_NOT_STRIP:
332+
f.write(" @DoNotStrip\n")
327333
f.write(" @JvmStatic\n")
328334
f.write(" public fun fromInt(value: Int): Yoga%s =\n" % name)
329335
f.write(" when (value) {\n")

java/com/facebook/yoga/YogaLogLevel.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
// @generated by enums.py
9+
10+
package com.facebook.yoga
11+
12+
import com.facebook.yoga.annotations.DoNotStrip
13+
14+
@DoNotStrip
15+
public enum class YogaLogLevel(public val intValue: Int) {
16+
ERROR(0),
17+
WARN(1),
18+
INFO(2),
19+
DEBUG(3),
20+
VERBOSE(4),
21+
FATAL(5);
22+
23+
public fun intValue(): Int = intValue
24+
25+
public companion object {
26+
@DoNotStrip
27+
@JvmStatic
28+
public fun fromInt(value: Int): YogaLogLevel =
29+
when (value) {
30+
0 -> ERROR
31+
1 -> WARN
32+
2 -> INFO
33+
3 -> DEBUG
34+
4 -> VERBOSE
35+
5 -> FATAL
36+
else -> throw IllegalArgumentException("Unknown enum value: $value")
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)