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

Class StructPointer

src/pointers/structure.py:181–211  ·  view source on GitHub ↗

Class representing a pointer to a struct.

Source from the content-addressed store, hash-verified

179
180
181class StructPointer(Pointer[T]):
182 """Class representing a pointer to a struct."""
183
184 def __init__(
185 self,
186 address: int,
187 existing: Optional["Struct"] = None,
188 ):
189 self._existing = existing
190 super().__init__(address, True)
191
192 @property # type: ignore
193 @handle
194 def _as_parameter_(
195 self,
196 ) -> Union[int, "ctypes._PointerLike"]:
197 existing = self._existing
198
199 if existing:
200 return ctypes.pointer(existing.struct)
201
202 return self.ensure()
203
204 def __repr__(self) -> str:
205 return f"StructPointer(address={self.address}, existing={self._existing!r})" # noqa
206
207 def __rich__(self) -> str:
208 return f"<[bold blue]pointer[/] to struct at {str(self)}>"
209
210 def get_existing_address(self) -> int:
211 return (~self).get_existing_address()

Callers 2

to_struct_ptrFunction · 0.85
_decode_typeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected