1
0

feat: finish EnumsMigration/EnumsRender

This commit is contained in:
2026-02-15 10:58:58 +08:00
parent 4619cb5d1a
commit ade1eadd50
3 changed files with 62 additions and 4 deletions

View File

@@ -31,7 +31,7 @@ public class EnumsHelper {
public enum BEnumEntrySignKind { public enum BEnumEntrySignKind {
/** The value of this enum entry is positive number or zero. */ /** The value of this enum entry is positive number or zero. */
Positive, Positive,
/** The value of this enum entry is negative. */ /** The value of this enum entry is negative number. */
Negative, Negative,
/** /**
* The value of this enum entry is unknown. * The value of this enum entry is unknown.

View File

@@ -1,6 +1,47 @@
import json import json
import typing import typing
import utils 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: class BEnumEntry:
@@ -10,14 +51,25 @@ class BEnumEntry:
"""The name of this entry.""" """The name of this entry."""
__entry_value: str | None __entry_value: str | None
"""The value of this entry. None if this entry do not have explicit value.""" """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 __entry_comment: str | None
"""The comment of this entry. None if no comment.""" """The comment of this entry. None if no comment."""
def __init__( 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_name = entry_name
self.__entry_value = entry_value self.__entry_value = entry_value
self.__entry_flag_kind = entry_flag_kind
self.__entry_sign_kind = entry_sign_kind
self.__entry_comment = entry_comment self.__entry_comment = entry_comment
def get_entry_name(self) -> str: def get_entry_name(self) -> str:
@@ -37,6 +89,8 @@ class BEnumEntry:
return BEnumEntry( return BEnumEntry(
data["name"], data["name"],
data.get("value", None), data.get("value", None),
BEnumEntryFlagKind(data.get("flag_kind")),
BEnumEntrySignKind(data.get("sign_kind")),
data.get("comment", None), data.get("comment", None),
) )
@@ -58,10 +112,12 @@ class BHierarchyEnumEntry(BEnumEntry):
self, self,
entry_name: str, entry_name: str,
entry_value: str | None, entry_value: str | None,
entry_flag_kind: BEnumEntryFlagKind,
entry_sign_kind: BEnumEntrySignKind,
entry_comment: str | None, entry_comment: str | None,
hierarchy: list[str], 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 self.__hierarchy = hierarchy
def iter_hierarchy(self, benum: "BEnum") -> typing.Iterator["BHierarchyEnumEntry"]: def iter_hierarchy(self, benum: "BEnum") -> typing.Iterator["BHierarchyEnumEntry"]:
@@ -75,6 +131,8 @@ class BHierarchyEnumEntry(BEnumEntry):
return BHierarchyEnumEntry( return BHierarchyEnumEntry(
data["name"], data["name"],
data.get("value", None), data.get("value", None),
BEnumEntryFlagKind(data.get("flag_kind")),
BEnumEntrySignKind(data.get("sign_kind")),
data.get("comment", None), data.get("comment", None),
data["hierarchy"], data["hierarchy"],
) )

View File

@@ -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 complexity of this project and legacy bugs.
* The lost interest and the lack of time of mine. * 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 ## Introduction