Point to a new address. Args: target: New pointer or value to look at.
(
self,
target: Nullable[Union["BaseObjectPointer[T]", T]],
)
| 209 | |
| 210 | @handle |
| 211 | def assign( |
| 212 | self, |
| 213 | target: Nullable[Union["BaseObjectPointer[T]", T]], |
| 214 | ) -> None: |
| 215 | """Point to a new address. |
| 216 | |
| 217 | Args: |
| 218 | target: New pointer or value to look at. |
| 219 | """ |
| 220 | if target is NULL: |
| 221 | self._address = None |
| 222 | return |
| 223 | |
| 224 | new: BasePointer[T] = self._get_ptr(target) # type: ignore |
| 225 | |
| 226 | if not isinstance(new, BaseObjectPointer): |
| 227 | raise ValueError( |
| 228 | "can only point to object pointer", |
| 229 | ) |
| 230 | |
| 231 | with suppress(NullPointerError): |
| 232 | remove_ref(~self) |
| 233 | |
| 234 | self._address = new.address |
| 235 | add_ref(~self) |
| 236 | |
| 237 | @property |
| 238 | def address(self) -> Optional[int]: |
no test coverage detected