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

Method dereference

src/pointers/c_pointer.py:175–190  ·  view source on GitHub ↗

Dereference the pointer.

(self)

Source from the content-addressed store, hash-verified

173
174 @handle
175 def dereference(self) -> T:
176 """Dereference the pointer."""
177 ctype = get_mapped(self.type)
178
179 if (ctype is ctypes.c_char_p) and (self.alt):
180 res = ctypes.c_char_p(self.ensure()).value
181 return res # type: ignore
182
183 ptr = (
184 ctype.from_address(self.ensure())
185 if not self._void_p
186 else ctypes.cast(
187 ctypes.c_void_p(self.address), ctypes.POINTER(ctype)
188 ) # fmt: off
189 )
190 return ptr.value if not self._void_p else ptr.contents.value # type: ignore # noqa
191
192 def __iter__(self) -> Iterator[T]:
193 """Dereference the pointer."""

Callers 1

__iter__Method · 0.95

Calls 2

get_mappedFunction · 0.85
ensureMethod · 0.45

Tested by

no test coverage detected