2023-05-09 22:21:01 -07:00
|
|
|
#!/usr/bin/env python3
|
2022-09-29 22:25:24 -07:00
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-11-15 08:42:33 -08:00
|
|
|
#
|
2018-02-16 18:24:55 -08:00
|
|
|
# This source code is licensed under the MIT license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2023-09-14 23:06:34 -07:00
|
|
|
import math
|
2016-11-15 08:42:33 -08:00
|
|
|
import os
|
|
|
|
|
|
|
|
ENUMS = {
|
2019-04-11 05:19:00 -07:00
|
|
|
"Direction": ["Inherit", "LTR", "RTL"],
|
|
|
|
"Unit": ["Undefined", "Point", "Percent", "Auto"],
|
|
|
|
"FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"],
|
|
|
|
"Justify": [
|
|
|
|
"FlexStart",
|
|
|
|
"Center",
|
|
|
|
"FlexEnd",
|
|
|
|
"SpaceBetween",
|
|
|
|
"SpaceAround",
|
|
|
|
"SpaceEvenly",
|
|
|
|
],
|
|
|
|
"Overflow": ["Visible", "Hidden", "Scroll"],
|
|
|
|
"Align": [
|
|
|
|
"Auto",
|
|
|
|
"FlexStart",
|
|
|
|
"Center",
|
|
|
|
"FlexEnd",
|
|
|
|
"Stretch",
|
|
|
|
"Baseline",
|
|
|
|
"SpaceBetween",
|
|
|
|
"SpaceAround",
|
2023-10-17 20:59:51 -07:00
|
|
|
"SpaceEvenly",
|
2019-04-11 05:19:00 -07:00
|
|
|
],
|
2022-09-29 22:25:24 -07:00
|
|
|
"PositionType": ["Static", "Relative", "Absolute"],
|
2019-04-11 05:19:00 -07:00
|
|
|
"Display": ["Flex", "None"],
|
|
|
|
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
|
|
|
|
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
|
|
|
|
"Dimension": ["Width", "Height"],
|
|
|
|
"Edge": [
|
|
|
|
"Left",
|
|
|
|
"Top",
|
|
|
|
"Right",
|
|
|
|
"Bottom",
|
|
|
|
"Start",
|
|
|
|
"End",
|
|
|
|
"Horizontal",
|
|
|
|
"Vertical",
|
|
|
|
"All",
|
|
|
|
],
|
|
|
|
"NodeType": ["Default", "Text"],
|
|
|
|
"LogLevel": ["Error", "Warn", "Info", "Debug", "Verbose", "Fatal"],
|
|
|
|
"ExperimentalFeature": [
|
2023-01-08 13:41:27 -08:00
|
|
|
# Mimic web flex-basis behavior (experiment may be broken)
|
|
|
|
"WebFlexBasis",
|
|
|
|
# Conformance fix: https://github.com/facebook/yoga/pull/1028
|
|
|
|
"AbsolutePercentageAgainstPaddingEdge",
|
2016-11-15 08:42:33 -08:00
|
|
|
],
|
2023-04-27 03:15:14 -07:00
|
|
|
"PrintOptions": [
|
|
|
|
("Layout", 1 << 0),
|
|
|
|
("Style", 1 << 1),
|
|
|
|
("Children", 1 << 2),
|
|
|
|
],
|
Add YGGutter Enum
Summary:
This adds the YGGutter enum, used to choose between row/column gap variants (row-gap, column-gap, gap).
This used later in changes from https://github.com/facebook/yoga/pull/1116, in the APIs which deal with setting gap on style on yoga node.
Note the original PR called this `YGGap`, but this ending up leading to a couple public method signatures that could appear ambiguous:
1. `SetGap(YGGap gap, float gapLength)`: Enums like `YGAlign` are the vaues for an `align` prop. `YGGap` controls the variant of the gap (like `YGEdge` does for left/right/top/bottom variants). So the enum reads as if it is the `gapValue`, and it looks like we have two of the same parameter.
2. `SetGap(YGGap gapDirection, float gap)`: This is misleading, because the direction gaps flow is the cross-axis of flex-direction.
3. `GetGap(YGGap gap)`: `gap` is the variant, but looks like an out param.
The [CSS Box Alignment](https://www.w3.org/TR/css-align-3/#column-row-gap) spec refers to these gaps as "Gutters", which removes the ambiguity.
Changelog:
[General][Added] - Add YGGutter Enum
Reviewed By: yungsters
Differential Revision: D39922412
fbshipit-source-id: 4b0baf800fecb3d03560a4267c7fb4c4330fd39e
2022-09-29 22:25:24 -07:00
|
|
|
"Gutter": ["Column", "Row", "All"],
|
2023-04-27 03:15:14 -07:00
|
|
|
# Known incorrect behavior which can be enabled for compatibility
|
|
|
|
"Errata": [
|
|
|
|
# Default: Standards conformant mode
|
|
|
|
("None", 0),
|
|
|
|
# Allows main-axis flex basis to be stretched without flexGrow being
|
|
|
|
# set (previously referred to as "UseLegacyStretchBehaviour")
|
|
|
|
("StretchFlexBasis", 1 << 0),
|
2023-10-23 18:20:24 -07:00
|
|
|
# Position: static behaves like position: relative within Yoga
|
Remove row-reverse errata (#1547)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1547
X-link: https://github.com/facebook/react-native/pull/42251
Yoga has an odd behavior, where `start`/`end` edges under row-reverse are relative to flex-direction, instead of writing direction.
While Yoga doesn't actually document what this behavior is supposed to be, it goes against CK documentation, historic RN documentation, and the behavior valid on the web. It is also applied inconsistently (e.g. sometimes only on container, sometimes on child). It really is a bug, instead of an intended behavior.
We changed the default behavior for Yoga, but left the existing one behind an errata (so existing fbsource users got old behavior). We have previously seen this behavior show up in product code, including CK when running on FlexLayout.
`row-reverse` is surprisingly uncommon though:
1. Litho has <40 usages
2. RN has ~40 usages in `RKJSModules`,~30 in `arvr/js`, ~6 in `xplat/archon`
3. CK has ~80 usages
4. NT has ~40 usages
There are few enough, mostly simple components, that we can inspect through each of them, looking for signs they will hit the issue (at the potential chance of missing some).
CK accounts for 10/14 usages that I could tell would trigger the issue, since it only exposes start/end edge, and not left/right. It might make sense to make it preserve behavior instead, to reduce risk a bit.
FlexLayout is now separately powering Bloks, which wasn't surveyed, so I didn't touch CK behavior under Bloks.
There could also be other usages in other frameworks/bespoke usages, and this has implications for OSS users. But based on our own usage, of many, many components, this seems rare.
Changelog:
[General][Breaking] - Make `start/end` in styles always refer to writing direction
Reviewed By: pentiumao, joevilches
Differential Revision: D52698130
fbshipit-source-id: 2a9ac47e177469f30dc988d916b6c0ad95d53461
2024-01-12 13:49:53 -08:00
|
|
|
("PositionStaticBehavesLikeRelative", 1 << 1),
|
2023-12-07 21:25:45 -08:00
|
|
|
# Positioning of absolute nodes will have various bugs related to
|
|
|
|
# justification, alignment, and insets
|
Remove row-reverse errata (#1547)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1547
X-link: https://github.com/facebook/react-native/pull/42251
Yoga has an odd behavior, where `start`/`end` edges under row-reverse are relative to flex-direction, instead of writing direction.
While Yoga doesn't actually document what this behavior is supposed to be, it goes against CK documentation, historic RN documentation, and the behavior valid on the web. It is also applied inconsistently (e.g. sometimes only on container, sometimes on child). It really is a bug, instead of an intended behavior.
We changed the default behavior for Yoga, but left the existing one behind an errata (so existing fbsource users got old behavior). We have previously seen this behavior show up in product code, including CK when running on FlexLayout.
`row-reverse` is surprisingly uncommon though:
1. Litho has <40 usages
2. RN has ~40 usages in `RKJSModules`,~30 in `arvr/js`, ~6 in `xplat/archon`
3. CK has ~80 usages
4. NT has ~40 usages
There are few enough, mostly simple components, that we can inspect through each of them, looking for signs they will hit the issue (at the potential chance of missing some).
CK accounts for 10/14 usages that I could tell would trigger the issue, since it only exposes start/end edge, and not left/right. It might make sense to make it preserve behavior instead, to reduce risk a bit.
FlexLayout is now separately powering Bloks, which wasn't surveyed, so I didn't touch CK behavior under Bloks.
There could also be other usages in other frameworks/bespoke usages, and this has implications for OSS users. But based on our own usage, of many, many components, this seems rare.
Changelog:
[General][Breaking] - Make `start/end` in styles always refer to writing direction
Reviewed By: pentiumao, joevilches
Differential Revision: D52698130
fbshipit-source-id: 2a9ac47e177469f30dc988d916b6c0ad95d53461
2024-01-12 13:49:53 -08:00
|
|
|
("AbsolutePositioning", 1 << 2),
|
2023-04-27 03:15:14 -07:00
|
|
|
# Enable all incorrect behavior (preserve compatibility)
|
|
|
|
("All", 0x7FFFFFFF),
|
|
|
|
# Enable all errata except for "StretchFlexBasis" (Defaults behavior
|
|
|
|
# before Yoga 2.0)
|
|
|
|
("Classic", 0x7FFFFFFF & (~(1 << 0))),
|
|
|
|
],
|
2016-11-15 08:42:33 -08:00
|
|
|
}
|
|
|
|
|
2022-09-29 22:25:24 -07:00
|
|
|
DO_NOT_STRIP = ["LogLevel"]
|
|
|
|
|
2023-04-27 03:15:14 -07:00
|
|
|
BITSET_ENUMS = ["PrintOptions", "Errata"]
|
2023-04-27 03:15:14 -07:00
|
|
|
|
2022-09-29 22:25:24 -07:00
|
|
|
|
|
|
|
def get_license(ext):
|
2023-05-09 22:21:01 -07:00
|
|
|
return f"""{"/**" if ext == "js" else "/*"}
|
2022-09-29 22:25:24 -07:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
2016-11-15 08:42:33 -08:00
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-11-15 08:42:33 -08:00
|
|
|
*/
|
|
|
|
|
2023-05-09 22:21:01 -07:00
|
|
|
// @{"generated"} by enums.py
|
2023-09-14 23:06:34 -07:00
|
|
|
{"// clang-format off" if ext == "cpp" else ""}
|
2023-05-09 22:21:01 -07:00
|
|
|
"""
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2019-04-11 05:19:00 -07:00
|
|
|
|
2023-05-09 22:21:01 -07:00
|
|
|
def _format_name(symbol, delimiter=None, transform=None):
|
2016-11-15 08:42:33 -08:00
|
|
|
symbol = str(symbol)
|
2019-04-11 05:19:00 -07:00
|
|
|
out = ""
|
2016-11-15 08:42:33 -08:00
|
|
|
for i in range(0, len(symbol)):
|
|
|
|
c = symbol[i]
|
2023-05-09 22:21:01 -07:00
|
|
|
if str.istitle(c) and i != 0 and not str.istitle(symbol[i - 1]):
|
|
|
|
out += delimiter or ""
|
|
|
|
if transform is None:
|
|
|
|
out += c
|
|
|
|
else:
|
|
|
|
out += getattr(c, transform)()
|
2016-11-15 08:42:33 -08:00
|
|
|
return out
|
|
|
|
|
2019-04-11 05:19:00 -07:00
|
|
|
|
2023-05-09 22:21:01 -07:00
|
|
|
def to_java_upper(symbol):
|
|
|
|
return _format_name(symbol, "_", "upper")
|
|
|
|
|
|
|
|
|
|
|
|
def to_hyphenated_lower(symbol):
|
|
|
|
return _format_name(symbol, "-", "lower")
|
2017-04-03 09:34:42 -07:00
|
|
|
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2016-12-22 02:57:19 -08:00
|
|
|
root = os.path.dirname(os.path.abspath(__file__))
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2017-01-08 11:42:43 -08:00
|
|
|
# write out C & Objective-C headers
|
2019-04-11 05:19:00 -07:00
|
|
|
with open(root + "/yoga/YGEnums.h", "w") as f:
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(get_license("cpp"))
|
|
|
|
f.write("#pragma once\n")
|
2023-05-04 00:41:12 -07:00
|
|
|
f.write("#include <yoga/YGMacros.h>\n\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
|
2022-10-17 23:35:01 -07:00
|
|
|
f.write("YG_EXTERN_C_BEGIN\n\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
items = sorted(ENUMS.items())
|
|
|
|
for name, values in items:
|
2023-11-27 21:20:20 -08:00
|
|
|
f.write("YG_ENUM_DECL(\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
|
|
|
|
f.write(" YG%s,\n" % name)
|
2016-11-15 08:42:33 -08:00
|
|
|
for value in values:
|
|
|
|
if isinstance(value, tuple):
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(" YG%s%s = %d" % (name, value[0], value[1]))
|
2016-11-15 08:42:33 -08:00
|
|
|
else:
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(" YG%s%s" % (name, value))
|
|
|
|
if value == values[-1]:
|
|
|
|
f.write(")\n")
|
|
|
|
else:
|
|
|
|
f.write(",\n")
|
2023-04-27 03:15:14 -07:00
|
|
|
if name in BITSET_ENUMS:
|
|
|
|
f.write("YG_DEFINE_ENUM_FLAG_OPERATORS(YG%s)\n" % name)
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write("\n")
|
|
|
|
f.write("YG_EXTERN_C_END\n")
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2023-09-14 23:06:34 -07:00
|
|
|
# Write out C++ scoped enums
|
|
|
|
for name, values in sorted(ENUMS.items()):
|
|
|
|
with open(f"{root}/yoga/enums/{name}.h", "w") as f:
|
|
|
|
f.write(get_license("cpp"))
|
|
|
|
f.write("#pragma once\n\n")
|
|
|
|
|
|
|
|
f.write("#include <cstdint>\n")
|
|
|
|
f.write("#include <yoga/YGEnums.h>\n")
|
|
|
|
f.write("#include <yoga/enums/YogaEnums.h>\n\n")
|
|
|
|
|
|
|
|
f.write("namespace facebook::yoga {\n\n")
|
|
|
|
|
|
|
|
width = "uint32_t" if name in BITSET_ENUMS else "uint8_t"
|
|
|
|
f.write(f"enum class {name} : {width} {{\n")
|
|
|
|
for value in values:
|
|
|
|
ordinal = value[0] if isinstance(value, tuple) else value
|
|
|
|
f.write(f" {ordinal} = YG{name}{ordinal},\n")
|
|
|
|
f.write("};\n\n")
|
2023-11-22 11:06:31 -08:00
|
|
|
|
|
|
|
if name in BITSET_ENUMS:
|
|
|
|
f.write(f"YG_DEFINE_ENUM_FLAG_OPERATORS({name})\n\n")
|
|
|
|
else:
|
|
|
|
f.write("template <>\n")
|
2023-12-12 08:52:11 -08:00
|
|
|
f.write(f"constexpr int32_t ordinalCount<{name}>() {{\n")
|
2023-11-22 11:06:31 -08:00
|
|
|
f.write(f" return {len(values)};\n")
|
2023-12-12 08:52:11 -08:00
|
|
|
f.write("}\n\n")
|
2023-11-22 11:06:31 -08:00
|
|
|
|
2023-12-12 08:52:11 -08:00
|
|
|
f.write(f"constexpr {name} scopedEnum(YG{name} unscoped) {{\n")
|
2023-09-14 23:06:34 -07:00
|
|
|
f.write(f" return static_cast<{name}>(unscoped);\n")
|
|
|
|
f.write("}\n\n")
|
|
|
|
|
2023-12-12 08:52:11 -08:00
|
|
|
f.write(f"constexpr YG{name} unscopedEnum({name} scoped) {{\n")
|
2023-09-14 23:06:34 -07:00
|
|
|
f.write(f" return static_cast<YG{name}>(scoped);\n")
|
|
|
|
f.write("}\n\n")
|
|
|
|
|
|
|
|
f.write(f"inline const char* toString({name} e) {{\n")
|
|
|
|
f.write(f" return YG{name}ToString(unscopedEnum(e));\n")
|
|
|
|
f.write("}\n\n")
|
|
|
|
|
|
|
|
f.write("} // namespace facebook::yoga\n")
|
|
|
|
|
2017-04-03 09:34:42 -07:00
|
|
|
# write out C body for printing
|
2019-04-11 05:19:00 -07:00
|
|
|
with open(root + "/yoga/YGEnums.cpp", "w") as f:
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(get_license("cpp"))
|
2023-05-04 00:41:12 -07:00
|
|
|
f.write("#include <yoga/YGEnums.h>\n\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
items = sorted(ENUMS.items())
|
|
|
|
for name, values in items:
|
|
|
|
f.write("const char* YG%sToString(const YG%s value) {\n" % (name, name))
|
|
|
|
f.write(" switch (value) {\n")
|
2017-04-03 09:34:42 -07:00
|
|
|
for value in values:
|
|
|
|
if isinstance(value, tuple):
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" case YG%s%s:\n" % (name, value[0]))
|
2023-05-09 22:21:01 -07:00
|
|
|
f.write(' return "%s";\n' % to_hyphenated_lower(value[0]))
|
2017-04-03 09:34:42 -07:00
|
|
|
else:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" case YG%s%s:\n" % (name, value))
|
2023-05-09 22:21:01 -07:00
|
|
|
f.write(' return "%s";\n' % to_hyphenated_lower(value))
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" }\n")
|
2017-04-03 09:34:42 -07:00
|
|
|
f.write(' return "unknown";\n')
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write("}\n")
|
|
|
|
if name != items[-1][0]:
|
|
|
|
f.write("\n")
|
2017-04-03 09:34:42 -07:00
|
|
|
|
2016-11-15 08:42:33 -08:00
|
|
|
# write out java files
|
2017-02-03 04:21:50 -08:00
|
|
|
for name, values in sorted(ENUMS.items()):
|
2019-04-11 05:19:00 -07:00
|
|
|
with open(root + "/java/com/facebook/yoga/Yoga%s.java" % name, "w") as f:
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(get_license("java"))
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write("package com.facebook.yoga;\n\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
if name in DO_NOT_STRIP:
|
2023-01-16 11:25:59 -08:00
|
|
|
f.write("import com.facebook.yoga.annotations.DoNotStrip;\n\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write("@DoNotStrip\n")
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write("public enum Yoga%s {\n" % name)
|
2016-11-15 08:42:33 -08:00
|
|
|
if len(values) > 0:
|
|
|
|
for value in values:
|
|
|
|
if isinstance(value, tuple):
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" %s(%d)" % (to_java_upper(value[0]), value[1]))
|
2016-11-15 08:42:33 -08:00
|
|
|
else:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" %s(%d)" % (to_java_upper(value), values.index(value)))
|
2016-11-15 08:42:33 -08:00
|
|
|
if values.index(value) is len(values) - 1:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(";\n")
|
2016-11-15 08:42:33 -08:00
|
|
|
else:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(",\n")
|
2016-11-15 08:42:33 -08:00
|
|
|
else:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write("__EMPTY(-1);")
|
|
|
|
f.write("\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(" private final int mIntValue;\n")
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write("\n")
|
|
|
|
f.write(" Yoga%s(int intValue) {\n" % name)
|
|
|
|
f.write(" mIntValue = intValue;\n")
|
|
|
|
f.write(" }\n")
|
|
|
|
f.write("\n")
|
|
|
|
f.write(" public int intValue() {\n")
|
|
|
|
f.write(" return mIntValue;\n")
|
|
|
|
f.write(" }\n")
|
|
|
|
f.write("\n")
|
2022-09-29 22:25:24 -07:00
|
|
|
if name in DO_NOT_STRIP:
|
|
|
|
f.write(" @DoNotStrip\n")
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(" public static Yoga%s fromInt(int value) {\n" % name)
|
|
|
|
f.write(" switch (value) {\n")
|
2016-11-15 08:42:33 -08:00
|
|
|
for value in values:
|
|
|
|
if isinstance(value, tuple):
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(
|
|
|
|
" case %d: return %s;\n" % (value[1], to_java_upper(value[0]))
|
|
|
|
)
|
2016-11-15 08:42:33 -08:00
|
|
|
else:
|
2019-04-11 05:19:00 -07:00
|
|
|
f.write(
|
|
|
|
" case %d: return %s;\n"
|
|
|
|
% (values.index(value), to_java_upper(value))
|
|
|
|
)
|
|
|
|
f.write(
|
|
|
|
' default: throw new IllegalArgumentException("Unknown enum value: " + value);\n'
|
|
|
|
)
|
|
|
|
f.write(" }\n")
|
|
|
|
f.write(" }\n")
|
|
|
|
f.write("}\n")
|
2016-11-15 08:42:33 -08:00
|
|
|
|
2023-05-09 22:21:01 -07:00
|
|
|
# write out TypeScript file
|
|
|
|
with open(root + "/javascript/src/generated/YGEnums.ts", "w") as f:
|
2022-09-29 22:25:24 -07:00
|
|
|
f.write(get_license("js"))
|
2023-05-09 22:21:01 -07:00
|
|
|
enums = sorted(ENUMS.items())
|
|
|
|
for enum_name, ordinals in enums:
|
|
|
|
f.write(f"export enum {enum_name} {{\n")
|
|
|
|
for ordinal_index, ordinal in enumerate(ordinals):
|
|
|
|
ordinal_name = ordinal[0] if isinstance(ordinal, tuple) else ordinal
|
|
|
|
ordinal_value = ordinal[1] if isinstance(ordinal, tuple) else ordinal_index
|
|
|
|
f.write(f" {ordinal_name} = {ordinal_value},\n")
|
|
|
|
|
|
|
|
f.write("}\n\n")
|
|
|
|
|
|
|
|
f.write("const constants = {\n")
|
|
|
|
for enum_name, ordinals in enums:
|
|
|
|
for ordinal in ordinals:
|
|
|
|
ordinal_name = ordinal[0] if isinstance(ordinal, tuple) else ordinal
|
|
|
|
ordinal_value = ordinal[1] if isinstance(ordinal, tuple) else ordinal_index
|
2022-12-28 01:27:12 -08:00
|
|
|
f.write(
|
2023-05-09 22:21:01 -07:00
|
|
|
f" {to_java_upper(enum_name)}_{to_java_upper(ordinal_name)}: {enum_name}.{ordinal_name},\n"
|
2022-12-28 01:27:12 -08:00
|
|
|
)
|
2022-09-29 22:25:24 -07:00
|
|
|
|
2023-05-09 22:21:01 -07:00
|
|
|
f.write("}\n")
|
|
|
|
f.write("export default constants")
|