mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[tools] Allow for pointer-to-integer types in .def files
The upcoming futex syscalls will be easier to use (and to auto verify) if passed a pointer instead of an address, this allows for changing a `Primitive` to a `PrimitiveRef` by adding a `*` to the end.
This commit is contained in:
@@ -35,7 +35,7 @@ name: IDENTIFIER
|
|||||||
options: "[" ( OPTION | IDENTIFIER )+ "]"
|
options: "[" ( OPTION | IDENTIFIER )+ "]"
|
||||||
description: COMMENT+
|
description: COMMENT+
|
||||||
|
|
||||||
PRIMITIVE: INT_TYPE | "size" | "string" | "buffer" | "address"
|
PRIMITIVE: INT_TYPE "*"? | "size" | "string" | "buffer" | "address"
|
||||||
INT_TYPE: /u?int(8|16|32|64)?/
|
INT_TYPE: /u?int(8|16|32|64)?/
|
||||||
NUMBER: /(0x)?[0-9a-fA-F]+/
|
NUMBER: /(0x)?[0-9a-fA-F]+/
|
||||||
UID: /[0-9a-fA-F]{16}/
|
UID: /[0-9a-fA-F]{16}/
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -42,31 +42,37 @@ class PrimitiveRef(Primitive):
|
|||||||
def cxx_names(self, options):
|
def cxx_names(self, options):
|
||||||
return self.c_names(options)
|
return self.c_names(options)
|
||||||
|
|
||||||
|
_inttypes = {
|
||||||
|
"int": "int",
|
||||||
|
"uint": "unsigned",
|
||||||
|
"size": "size_t",
|
||||||
|
"address": "uintptr_t",
|
||||||
|
|
||||||
|
"int8": "int8_t",
|
||||||
|
"uint8": "uint8_t",
|
||||||
|
"int16": "int16_t",
|
||||||
|
"uint16": "uint16_t",
|
||||||
|
"int32": "int32_t",
|
||||||
|
"uint32": "uint32_t",
|
||||||
|
"int64": "int64_t",
|
||||||
|
"uint64": "uint64_t",
|
||||||
|
}
|
||||||
|
|
||||||
_primitives = {
|
_primitives = {
|
||||||
"string": PrimitiveRef("string", "char"),
|
"string": PrimitiveRef("string", "char"),
|
||||||
"buffer": PrimitiveRef("buffer", "void", counted=True),
|
"buffer": PrimitiveRef("buffer", "void", counted=True),
|
||||||
|
|
||||||
"int": Primitive("int", "int"),
|
|
||||||
"uint": Primitive("uint", "unsigned"),
|
|
||||||
"size": Primitive("size", "size_t"),
|
|
||||||
"address": Primitive("address", "uintptr_t"),
|
|
||||||
|
|
||||||
"int8": Primitive("int8", "int8_t"),
|
|
||||||
"uint8": Primitive("uint8", "uint8_t"),
|
|
||||||
|
|
||||||
"int16": Primitive("int16", "int16_t"),
|
|
||||||
"uint16": Primitive("uint16", "uint16_t"),
|
|
||||||
|
|
||||||
"int32": Primitive("int32", "int32_t"),
|
|
||||||
"uint32": Primitive("uint32", "uint32_t"),
|
|
||||||
|
|
||||||
"int64": Primitive("int64", "int64_t"),
|
|
||||||
"uint64": Primitive("uint64", "uint64_t"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_primitive(name):
|
def get_primitive(name):
|
||||||
p = _primitives.get(name)
|
p = _primitives.get(name)
|
||||||
if not p:
|
if p: return p
|
||||||
|
|
||||||
|
it = _inttypes.get(name.replace('*', ''))
|
||||||
|
if it:
|
||||||
|
if '*' in name:
|
||||||
|
return PrimitiveRef(name, it)
|
||||||
|
else:
|
||||||
|
return Primitive(name, it)
|
||||||
|
|
||||||
from ..errors import InvalidType
|
from ..errors import InvalidType
|
||||||
raise InvalidType(name)
|
raise InvalidType(name)
|
||||||
return p
|
|
||||||
|
|||||||
Reference in New Issue
Block a user