Update datatypes
This commit is contained in:
parent
8d0c731b72
commit
6f2cdd8d62
@ -105,7 +105,7 @@ class CStruct:
|
||||
|
||||
|
||||
CUserType = Union[CStruct, CEnum]
|
||||
CDataType = Union[CType, CUserType]
|
||||
CDataType = Union[CType, CUserType, str]
|
||||
|
||||
|
||||
@dataclass
|
||||
@ -118,7 +118,7 @@ class CArg:
|
||||
|
||||
def __str__(self) -> str:
|
||||
qualifier = str(self.qualifier)
|
||||
_type = _get_arg_type_string(self._type)
|
||||
_type = get_datatype_string(self._type) + " "
|
||||
pointer = str(self.pointer)
|
||||
array = "[]" if self.array else ""
|
||||
|
||||
@ -136,10 +136,12 @@ class CFunc:
|
||||
|
||||
def __str__(self) -> str:
|
||||
qualifiers = ""
|
||||
for qualifier in qualifiers:
|
||||
for qualifier in self.qualifiers:
|
||||
if qualifier == CQualifier.NONE:
|
||||
continue
|
||||
qualifiers += f"{str(qualifier)} "
|
||||
if len(qualifiers) > 0:
|
||||
qualifiers += " "
|
||||
qualifiers += f"{str(qualifier)}"
|
||||
|
||||
args = ""
|
||||
for i, arg in enumerate(self.args):
|
||||
@ -147,7 +149,7 @@ class CFunc:
|
||||
if i + 1 < len(self.args):
|
||||
args += ", "
|
||||
|
||||
return qualifiers + _get_arg_type_string(self.ret_type) + str(self.pointer) + self.name + f"({args})"
|
||||
return qualifiers + get_datatype_string(self.ret_type) + " " + str(self.pointer) + self.name + f"({args})"
|
||||
|
||||
def declare(self) -> str:
|
||||
return f"{str(self)};\n"
|
||||
@ -235,6 +237,9 @@ class CSource(CFile):
|
||||
internal_funcs_decl += func.declare()
|
||||
internal_funcs_def += func.define()
|
||||
|
||||
if len(internal_funcs_decl) > 0:
|
||||
internal_funcs_decl += "\n"
|
||||
|
||||
funcs = ""
|
||||
for func in self.funcs:
|
||||
funcs += func.define()
|
||||
@ -242,11 +247,13 @@ class CSource(CFile):
|
||||
return includes + types + internal_funcs_decl + funcs + internal_funcs_def
|
||||
|
||||
|
||||
def _get_arg_type_string(_type: CDataType) -> str:
|
||||
def get_datatype_string(_type: CDataType) -> str:
|
||||
if isinstance(_type, CType):
|
||||
return str(_type) + " "
|
||||
return str(_type)
|
||||
elif isinstance(_type, CStruct) or isinstance(_type, CEnum):
|
||||
return _type.name + " "
|
||||
return _type.name
|
||||
elif isinstance(_type, str):
|
||||
return _type
|
||||
|
||||
|
||||
def _get_includes_string(includes: list[CInclude]) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user