Py type context
py_type_context
TypeMap
Bases: NamedTuple
Map a Python type to a C type and optional call-boundary conversions.
Missing converters pass values through unchanged.
Source code in xdsl/jit/py_type_context.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
python_type: type[Any]
instance-attribute
Python type on the wrapped-function boundary.
c_type: str
instance-attribute
C type used by the native function.
to_c: Callable[[Any], Any] | None = None
class-attribute
instance-attribute
Convert a Python argument before the native call.
from_c: Callable[[Any], Any] | None = None
class-attribute
instance-attribute
Convert the native result back to a Python value.
FuncTypeMap
Bases: NamedTuple
Per-argument and result :class:TypeMap entries for a function signature.
Source code in xdsl/jit/py_type_context.py
30 31 32 33 34 35 36 37 38 39 40 41 | |
arg_maps: tuple[TypeMap, ...]
instance-attribute
res_map: TypeMap
instance-attribute
c_func_type() -> CFuncSignature
Return the C function signature.
Source code in xdsl/jit/py_type_context.py
36 37 38 39 40 41 | |
PyTypeContext
Registry of Python types to :class:TypeMap entries.
Configures native call signatures and optional value conversions when wrapping
a :class:RawJITFunc. Registrations must agree with the frontend type mapping and
with
:class:~xdsl.jit.c_type_context.CTypeContext for the same logical types.
Source code in xdsl/jit/py_type_context.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
__init__()
Source code in xdsl/jit/py_type_context.py
56 57 | |
register_type_map(type_map: TypeMap)
Register a :class:TypeMap for its python_type.
Source code in xdsl/jit/py_type_context.py
59 60 61 | |
type_map(python_type: type[Any]) -> TypeMap
Return the :class:TypeMap for python_type.
Source code in xdsl/jit/py_type_context.py
63 64 65 66 67 68 | |
func_type_map(signature: TypeForm[Callable[..., Any]]) -> FuncTypeMap
Build a :class:FuncTypeMap from a Callable signature.
Source code in xdsl/jit/py_type_context.py
70 71 72 73 74 75 76 77 78 79 | |