mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[tools] Allow struct types in definitions
Allow struct type names in definitions, which result in struct buffer pointers in generated code.
This commit is contained in:
@@ -24,3 +24,4 @@ from .function import Function, Method, Param
|
||||
from .type import Type
|
||||
from .primitive import get_primitive
|
||||
from .objref import ObjectRef
|
||||
from .struct import Struct
|
||||
|
||||
17
scripts/definitions/types/struct.py
Normal file
17
scripts/definitions/types/struct.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from .type import Type
|
||||
|
||||
class Struct(Type):
|
||||
def __repr__(self):
|
||||
return f'Struct({self.name})'
|
||||
|
||||
def c_names(self, options):
|
||||
one = f"struct j6_{self.name} *"
|
||||
two = "size_t"
|
||||
|
||||
out = bool({"out", "inout"}.intersection(options))
|
||||
if out:
|
||||
two += " *"
|
||||
return ((one, ""), (two, "_size"))
|
||||
|
||||
def cxx_names(self, options):
|
||||
return self.c_names(options)
|
||||
Reference in New Issue
Block a user