move support for existing_c_struct and support int64 struct types

This commit is contained in:
Laura Klünder 2023-10-26 14:22:28 +02:00
parent cab7cd1bdc
commit 14fddccdb5

View file

@ -75,9 +75,11 @@ class SimpleFormat(BaseFormat):
"B": "uint8_t", "B": "uint8_t",
"H": "uint16_t", "H": "uint16_t",
"I": "uint32_t", "I": "uint32_t",
"Q": "uint64_t",
"b": "int8_t", "b": "int8_t",
"h": "int16_t", "h": "int16_t",
"i": "int32_t", "i": "int32_t",
"q": "uint64_t",
"s": "char", "s": "char",
} }
@ -562,6 +564,9 @@ class StructType:
@classmethod @classmethod
def get_c_parts(cls, ignore_fields=None, no_empty=False, top_level=False, union_only=False, in_union=False): def get_c_parts(cls, ignore_fields=None, no_empty=False, top_level=False, union_only=False, in_union=False):
if cls.existing_c_struct is not None:
return (cls.existing_c_struct, "")
ignore_fields = set() if not ignore_fields else set(ignore_fields) ignore_fields = set() if not ignore_fields else set(ignore_fields)
if union_only: if union_only:
@ -604,9 +609,6 @@ class StructType:
@classmethod @classmethod
def get_c_code(cls, name=None, ignore_fields=None, no_empty=False, typedef=True, union_only=False, def get_c_code(cls, name=None, ignore_fields=None, no_empty=False, typedef=True, union_only=False,
in_union=False) -> str: in_union=False) -> str:
if cls.existing_c_struct is not None:
return "%s %s;" % (cls.existing_c_struct, name)
pre, post = cls.get_c_parts(ignore_fields=ignore_fields, pre, post = cls.get_c_parts(ignore_fields=ignore_fields,
no_empty=no_empty, no_empty=no_empty,
top_level=typedef, top_level=typedef,