(*seq: T)
| 278 | |
| 279 | @handle |
| 280 | def array(*seq: T) -> CArrayPointer[T]: |
| 281 | f_type = type(seq[0]) |
| 282 | |
| 283 | for i in seq: |
| 284 | if type(i) is not f_type: # dont use isinstance here |
| 285 | raise ValueError( |
| 286 | "all values in the array must be the same type", |
| 287 | ) |
| 288 | |
| 289 | length = len(seq) |
| 290 | ctype = get_mapped(f_type) |
| 291 | arr = (ctype * length)(*seq) # type: ignore |
| 292 | add_ref(arr) |
| 293 | |
| 294 | return CArrayPointer( |
| 295 | ctypes.addressof(arr), |
| 296 | ctypes.sizeof(arr), |
| 297 | length, |
| 298 | f_type, # type: ignore |
| 299 | ) |
| 300 | |
| 301 | |
| 302 | def to_func_ptr(fn: Callable[P, T]) -> FunctionPointer[P, T]: |
nothing calls this directly
no test coverage detected