feat: add rust support for code gen
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
{%- for benum in payload.iter_enums() %}
|
||||
{%- if benum.get_enum_comment() is not none %}
|
||||
{{ benum.get_enum_comment() | block_comment('/// ') }}
|
||||
{%- endif %}
|
||||
{%- if not benum.get_use_flags() %}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[repr({% if benum.get_can_unsigned() -%} u32 {%- else -%} i32 {%- endif %})]
|
||||
pub enum {{ benum.get_enum_name() }} {
|
||||
{%- for entry in benum.iter_entries() %}
|
||||
{%- if entry.get_entry_comment() is not none %}
|
||||
/// {{ entry.get_entry_comment() | line_comment }}
|
||||
{%- endif %}
|
||||
{{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ utils.to_py_num_literal(entry.get_entry_value()) }} {%- endif %},
|
||||
{%- endfor %}
|
||||
}
|
||||
{%- else %}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct {{ benum.get_enum_name() }}({% if benum.get_can_unsigned() -%} u32 {%- else -%} i32 {%- endif %});
|
||||
|
||||
bitflags! {
|
||||
impl {{ benum.get_enum_name() }}: {% if benum.get_can_unsigned() -%} u32 {%- else -%} i32 {%- endif %} {
|
||||
{%- for entry in benum.iter_entries() %}
|
||||
{%- if entry.get_entry_comment() is not none %}
|
||||
/// {{ entry.get_entry_comment() | line_comment }}
|
||||
{%- endif %}
|
||||
const {{ entry.get_entry_name() }} {%- if entry.get_entry_value() is not none %} = {{ utils.to_py_num_literal(entry.get_entry_value()) }} {%- endif %};
|
||||
{%- endfor %}
|
||||
}
|
||||
}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
Reference in New Issue
Block a user