MCPcopy Index your code
hub / github.com/ZeroIntensity/pointers.py / to_c_ptr

Function to_c_ptr

src/pointers/c_pointer.py:261–269  ·  view source on GitHub ↗

Convert a python type to a pointer to a C type.

(data: T)

Source from the content-addressed store, hash-verified

259
260
261def to_c_ptr(data: T) -> TypedCPointer[T]:
262 """Convert a python type to a pointer to a C type."""
263 ct = map_type(data)
264
265 add_ref(ct)
266 address = ctypes.addressof(ct)
267 typ = type(data)
268
269 return TypedCPointer(address, typ, ctypes.sizeof(ct), False)
270
271
272def to_struct_ptr(struct: A) -> "StructPointer[A]":

Callers 2

_Function · 0.90
_Function · 0.90

Calls 3

add_refFunction · 0.85
TypedCPointerClass · 0.85
map_typeFunction · 0.70

Tested by 2

_Function · 0.72
_Function · 0.72