1
0

fix: finish enums migration

This commit is contained in:
2026-01-27 16:38:29 +08:00
parent 9cb4d50f22
commit 0419dc3939
15 changed files with 165 additions and 919 deletions

View File

@@ -1,6 +1,6 @@
{%- set benum = first(payload.iter_enums()) %}
{%- set benum = payload.iter_enums() | first %}
const CkErrorReflectionArray CKERROR {
{%- for entry in benum.iter_entries() %}
{ LibCmo::CK2::CKERROR::{{ entry.get_entry_name() }}, { u8"{{ entry.get_entry_name() }}", u8"{{- entry.get_entry_comment() }}" } },
{ LibCmo::CK2::CKERROR::{{ entry.get_entry_name() }}, { u8"{{ entry.get_entry_name() }}", u8"{{- entry.get_entry_comment() | some_or_blank | escape_string }}" } },
{%- endfor %}
};

View File

@@ -1,6 +1,6 @@
{%- set benum = first(payload.iter_enums()) %}
{%- set benum = payload.iter_enums() | first %}
const CkClassidReflectionArray CK_CLASSID {
{%- for entry in benum.iter_entries() %}
{ LibCmo::CK2::CK_CLASSID::{{ entry.get_entry_name() }}, { { {% for item in entry.iter_hierarchy(benum) %} u8"{{ item.get_enum_name() }}" {%- if not loop.last -%}, {%- endif %} {%- endfor %} } } },
{ LibCmo::CK2::CK_CLASSID::{{ entry.get_entry_name() }}, { { {%- for item in entry.iter_hierarchy(benum) %} u8"{{ item.get_entry_name() }}" {%- if not loop.last -%}, {%- endif %} {%- endfor %} } } },
{%- endfor %}
};

View File

@@ -1,13 +1,11 @@
{%- for benum in payload.iter_enums() %}
{%- if benum.get_enum_comment() is not none %}
/**
{{ benum.get_enum_comment() }}
*/
{{ benum.get_enum_comment() | block_comment('/// ') }}
{%- endif %}
{% if benum.get_use_flags() %}[Flags]{%- endif %}
public enum {{ benum.get_enum_name() }} : {% if benum.get_can_unsigned() -%} uint {%- else -%} int {%- endif %} {
{%- for entry in benum.iter_entries() %}
{{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ entry.get_entry_value() }} {%- endif %}, {%- if entry.get_entry_comment() is not none %} /**< {{ entry.get_entry_comment() }} */ {%- endif %}
{{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ entry.get_entry_value() }} {%- endif %}, {%- if entry.get_entry_comment() is not none %} /// {{ entry.get_entry_comment() | line_comment }} {%- endif %}
{%- endfor %}
};
{%- endfor %}

View File

@@ -1,5 +1,7 @@
{%- for benum in payload.iter_enums() %}
public static readonly System.Collections.Generic.Dictionary<{{ benum.get_enum_name() }}, string> {{ benum.get_enum_name() }} = new System.Collections.Generic.Dictionary<{{ benum.get_enum_name() }}, string>() {
using System.Collections.Generic;
{% for benum in payload.iter_enums() %}
public static readonly Dictionary<{{ benum.get_enum_name() }}, string> {{ benum.get_enum_name() }} = new Dictionary<{{ benum.get_enum_name() }}, string>() {
{%- for entry in benum.iter_entries() %}
{ {{ benum.get_enum_name() }}.{{ entry.get_entry_name() }}, "{{ entry.get_entry_name() }}" },
{%- endfor %}

View File

@@ -0,0 +1,16 @@
from dataclasses import dataclass
@dataclass(frozen=True)
class EnumDocstring():
display_name: str
"""The name of this enum entry."""
description: str
"""The description of this enum entry."""
{% for benum in payload.iter_enums() %}
DOCSTRING_{{ benum.get_enum_name() }}: dict[{{ benum.get_enum_name() }}, EnumDocstring] = {
{%- for entry in benum.iter_entries() %}
{{ benum.get_enum_name() }}.{{ entry.get_entry_name() }}: EnumDocstring("{{ utils.extract_human_readable_entry_name(entry.get_entry_name()) }}", "{{ entry.get_entry_comment() | some_or_blank | escape_string }}"),
{%- endfor %}
}
{%- endfor %}

View File

@@ -1,12 +1,12 @@
{%- for benum in payload.iter_enums() %}
{%- if benum.get_enum_comment() is not none %}
/**
{{ benum.get_enum_comment() }}
{{ benum.get_enum_comment() | block_comment(' * ') }}
*/
{%- endif %}
enum class {{ benum.get_enum_name() }} : {% if benum.get_can_unsigned() -%} CKDWORD {%- else -%} CKINT {%- endif %} {
{%- for entry in benum.iter_entries() %}
{{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ entry.get_entry_value() }} {%- endif %}, {%- if entry.get_entry_comment() is not none %} /**< {{ entry.get_entry_comment() }} */ {%- endif %}
{{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ entry.get_entry_value() }} {%- endif %}, {%- if entry.get_entry_comment() is not none %} /**< {{ entry.get_entry_comment() | line_comment }} */ {%- endif %}
{%- endfor %}
};
{%- endfor %}

View File

@@ -1,14 +1,14 @@
import enum
{% for benum in payload.iter_enums() %}
{%- if benum.get_enum_comment() is not none %}
/**
{{ benum.get_enum_comment() }}
*/
{%- endif %}
class {{ benum.get_enum_name() }}(enum.IntEnum):
{%- if benum.get_enum_comment() is not none %}
"""
{{ benum.get_enum_comment() | block_comment('') }}
"""
{%- endif %}
{%- for entry in benum.iter_entries() %}
{{ entry.get_entry_name() }} = {% if entry.get_entry_value() is none -%} auto() {%- else -%} {{ entry.get_entry_value() }} {%- endif %} {%- if entry.get_entry_comment() is not none %}
"""{{ entry.get_entry_comment() }}""" {%- endif %}
{{ entry.get_entry_name() }} = {% if entry.get_entry_value() is none -%} auto() {%- else -%} {{ utils.convert_to_python_number(entry.get_entry_value()) }} {%- endif %} {%- if entry.get_entry_comment() is not none %}
"""{{ entry.get_entry_comment() | line_comment }}""" {%- endif %}
{%- endfor %}
{%- endfor %}