MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / lean_ctor_get

Function lean_ctor_get

lean_py/_runtime.py:467–477  ·  view source on GitHub ↗
(self, o, i)

Source from the content-addressed store, hash-verified

465 return self.lean_ptr_other(o)
466
467 def lean_ctor_get(self, o, i):
468 ctor_cls = structs.get("lean_ctor_object")
469 ctor = ctypes.cast(o, POINTER(ctor_cls))
470 offset = ctor_cls.m_objs.offset
471 # Read the pointer value as an integer to avoid creating a ctypes
472 # pointer that aliases into the Lean ctor's m_objs memory. If the
473 # ctor is later freed (lean_dec), an aliased pointer would become
474 # stale when the Lean allocator reuses the memory.
475 elem_addr = ctypes.addressof(ctor.contents) + offset + i * ctypes.sizeof(LeanObjectPtr)
476 raw_val = c_void_p.from_address(elem_addr).value or 0
477 return ctypes.cast(c_void_p(raw_val), LeanObjectPtr)
478
479 def lean_ctor_set(self, o, i, v):
480 ctor_cls = structs.get("lean_ctor_object")

Callers 4

leanpy_ctor_getFunction · 0.85
lean_py_of_dictFunction · 0.85
lean_py_call_kwFunction · 0.85
format_lean_io_errorFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected