Define a c function call op that replaces a method call. This will be automatically generated by matching against the AST. Args: name: short name of the method (for example, 'append') arg_types: argument types; the receiver is always the first argument return_type:
(
name: str,
arg_types: list[RType],
return_type: RType,
c_function_name: str,
error_kind: int,
var_arg_type: RType | None = None,
truncated_type: RType | None = None,
ordering: list[int] | None = None,
extra_int_constants: list[tuple[int, RType]] | None = None,
steals: StealsDescription = False,
is_borrowed: bool = False,
priority: int = 1,
is_pure: bool = False,
experimental: bool = False,
dependencies: list[Dependency] | None = None,
)
| 93 | |
| 94 | |
| 95 | def method_op( |
| 96 | name: str, |
| 97 | arg_types: list[RType], |
| 98 | return_type: RType, |
| 99 | c_function_name: str, |
| 100 | error_kind: int, |
| 101 | var_arg_type: RType | None = None, |
| 102 | truncated_type: RType | None = None, |
| 103 | ordering: list[int] | None = None, |
| 104 | extra_int_constants: list[tuple[int, RType]] | None = None, |
| 105 | steals: StealsDescription = False, |
| 106 | is_borrowed: bool = False, |
| 107 | priority: int = 1, |
| 108 | is_pure: bool = False, |
| 109 | experimental: bool = False, |
| 110 | dependencies: list[Dependency] | None = None, |
| 111 | ) -> PrimitiveDescription: |
| 112 | """Define a c function call op that replaces a method call. |
| 113 | |
| 114 | This will be automatically generated by matching against the AST. |
| 115 | |
| 116 | Args: |
| 117 | name: short name of the method (for example, 'append') |
| 118 | arg_types: argument types; the receiver is always the first argument |
| 119 | return_type: type of the return value. Use void_rtype to represent void. |
| 120 | c_function_name: name of the C function to call |
| 121 | error_kind: how errors are represented in the result (one of ERR_*) |
| 122 | var_arg_type: type of all variable arguments |
| 123 | truncated_type: type to truncated to(See Truncate for info) |
| 124 | if it's defined both return_type and it should be non-referenced |
| 125 | integer types or bool type |
| 126 | ordering: optional ordering of the arguments, if defined, |
| 127 | reorders the arguments accordingly. |
| 128 | should never be used together with var_arg_type. |
| 129 | all the other arguments(such as arg_types) are in the order |
| 130 | accepted by the python syntax(before reordering) |
| 131 | extra_int_constants: optional extra integer constants as the last arguments to a C call |
| 132 | steals: description of arguments that this steals (ref count wise) |
| 133 | is_borrowed: if True, returned value is borrowed (no need to decrease refcount) |
| 134 | priority: if multiple ops match, the one with the highest priority is picked |
| 135 | is_pure: if True, declare that the C function has no side effects, takes immutable |
| 136 | arguments, and never raises an exception |
| 137 | """ |
| 138 | if extra_int_constants is None: |
| 139 | extra_int_constants = [] |
| 140 | ops = method_call_ops.setdefault(name, []) |
| 141 | desc = PrimitiveDescription( |
| 142 | name, |
| 143 | arg_types, |
| 144 | return_type, |
| 145 | var_arg_type, |
| 146 | truncated_type, |
| 147 | c_function_name, |
| 148 | error_kind, |
| 149 | steals, |
| 150 | is_borrowed, |
| 151 | ordering, |
| 152 | extra_int_constants, |
no test coverage detected
searching dependent graphs…