MCPcopy Create free account
hub / github.com/ZeroIntensity/pointers.py / array

Function array

src/pointers/c_pointer.py:280–299  ·  view source on GitHub ↗
(*seq: T)

Source from the content-addressed store, hash-verified

278
279@handle
280def 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
302def to_func_ptr(fn: Callable[P, T]) -> FunctionPointer[P, T]:

Callers

nothing calls this directly

Calls 3

get_mappedFunction · 0.85
add_refFunction · 0.85
CArrayPointerClass · 0.85

Tested by

no test coverage detected