class CType(metaclass=CTypeMeta):
@_abc.abstractmethod
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield from ()
class Array(CType, tuple, metaclass=ArrayMeta, type=CType, size=...):
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{{"
for (index, item) in enumerate(self):
yield from indent(item.c_value(prefix=f"[{index}] = ", suffix=","))
yield from indent(item.c_value(suffix=","))
yield f"}};"
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{self.c_name}{suffix}"
value = f"0x{item.value:08x}U"
yield f"#define {key} {value}"
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{self.__class__.c_tag.upper()}_{self.name.upper()}{suffix}"
@_dataclasses.dataclass(eq=True, frozen=True)
class Struct(CType, metaclass=StructMeta):
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{{"
for field in _dataclasses.fields(self):
name = field.name
class Integer(CType, str):
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{self}{suffix}"
escaped = self.replace("\"", "\\\"")
return f"\"{escaped}\""
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{self!r}{suffix}"
@classmethod
class Fields(metaclass=FieldsMeta):
- def c_value(self, prefix="", suffix=""):
+ def c_value(self, *, prefix="", suffix="", **kwargs):
yield f"{prefix}{{"
for (key, value) in self.__class__:
yield from indent(value.c_value(prefix=f"[{key.c_name}] = ", suffix=","))