From ade1eadd50de41ebb3bc9198d53e4cae45323ce0 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 15 Feb 2026 10:58:58 +0800 Subject: [PATCH] feat: finish EnumsMigration/EnumsRender --- .../EnumsAnalyzer/EnumsHelper.java | 2 +- .../EnumsMigration/EnumsRender/json_loader.py | 62 ++++++++++++++++++- README.md | 2 +- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/Assets/CodeGen/EnumsMigration/EnumsAnalyzer/EnumsHelper.java b/Assets/CodeGen/EnumsMigration/EnumsAnalyzer/EnumsHelper.java index 98bafa1..8e2b358 100644 --- a/Assets/CodeGen/EnumsMigration/EnumsAnalyzer/EnumsHelper.java +++ b/Assets/CodeGen/EnumsMigration/EnumsAnalyzer/EnumsHelper.java @@ -31,7 +31,7 @@ public class EnumsHelper { public enum BEnumEntrySignKind { /** The value of this enum entry is positive number or zero. */ Positive, - /** The value of this enum entry is negative. */ + /** The value of this enum entry is negative number. */ Negative, /** * The value of this enum entry is unknown. diff --git a/Assets/CodeGen/EnumsMigration/EnumsRender/json_loader.py b/Assets/CodeGen/EnumsMigration/EnumsRender/json_loader.py index 506ea8e..a92e274 100644 --- a/Assets/CodeGen/EnumsMigration/EnumsRender/json_loader.py +++ b/Assets/CodeGen/EnumsMigration/EnumsRender/json_loader.py @@ -1,6 +1,47 @@ import json import typing import utils +import enum + + +class BEnumEntryFlagKind(enum.StrEnum): + """ + The kind of enum entry value. + This kind indicates whether this enum entry belong to a flag enum. + """ + + NotFlag = "not-flag" + """ + This enum entry can not belong to a flag enum. + Because its value is ordinary. + """ + MayFlag = "may-flag" + """ + This enum entry may belong to a flag enum. + Because its value is in HEX format, and refering other members. + """ + MustFlag = "must-flag" + """ + This enum entry must belong to a flag enum. + Because its value use bitwise operation. + """ + + +class BEnumEntrySignKind(enum.StrEnum): + """ + The kind of enum entry value. + This kind indicates the sign of this enum entry value. + """ + + Positive = "positive" + """The value of this enum entry is positive number or zero.""" + Negative = "negative" + """he value of this enum entry is negative number.""" + Unknown = "unknown" + """ + The value of this enum entry is unknown. + This is may be caused by that it refer other memeber. + """ class BEnumEntry: @@ -10,14 +51,25 @@ class BEnumEntry: """The name of this entry.""" __entry_value: str | None """The value of this entry. None if this entry do not have explicit value.""" + __entry_flag_kind: BEnumEntryFlagKind + """The flag kind of this entry value.""" + __entry_sign_kind: BEnumEntrySignKind + """The sign kind of this entry value.""" __entry_comment: str | None """The comment of this entry. None if no comment.""" def __init__( - self, entry_name: str, entry_value: str | None, entry_comment: str | None + self, + entry_name: str, + entry_value: str | None, + entry_flag_kind: BEnumEntryFlagKind, + entry_sign_kind: BEnumEntrySignKind, + entry_comment: str | None, ): self.__entry_name = entry_name self.__entry_value = entry_value + self.__entry_flag_kind = entry_flag_kind + self.__entry_sign_kind = entry_sign_kind self.__entry_comment = entry_comment def get_entry_name(self) -> str: @@ -37,6 +89,8 @@ class BEnumEntry: return BEnumEntry( data["name"], data.get("value", None), + BEnumEntryFlagKind(data.get("flag_kind")), + BEnumEntrySignKind(data.get("sign_kind")), data.get("comment", None), ) @@ -58,10 +112,12 @@ class BHierarchyEnumEntry(BEnumEntry): self, entry_name: str, entry_value: str | None, + entry_flag_kind: BEnumEntryFlagKind, + entry_sign_kind: BEnumEntrySignKind, entry_comment: str | None, hierarchy: list[str], ): - super().__init__(entry_name, entry_value, entry_comment) + super().__init__(entry_name, entry_value, entry_flag_kind, entry_sign_kind, entry_comment) self.__hierarchy = hierarchy def iter_hierarchy(self, benum: "BEnum") -> typing.Iterator["BHierarchyEnumEntry"]: @@ -75,6 +131,8 @@ class BHierarchyEnumEntry(BEnumEntry): return BHierarchyEnumEntry( data["name"], data.get("value", None), + BEnumEntryFlagKind(data.get("flag_kind")), + BEnumEntrySignKind(data.get("sign_kind")), data.get("comment", None), data["hierarchy"], ) diff --git a/README.md b/README.md index b954cd3..300ff76 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This project is now suspended and may be still suspended eternally due to follow * The complexity of this project and legacy bugs. * The lost interest and the lack of time of mine. -In following life time of this project, only easy-to-be-resolved critical bugs will be fixed. +In the rest of life time of this project, only easy-to-be-resolved critical bugs will be fixed. ## Introduction