Try to locate the appropriate derived class dynamically, and cast the pointer accordingly.
(cls, gdbval)
| 384 | |
| 385 | @classmethod |
| 386 | def from_pyobject_ptr(cls, gdbval): |
| 387 | ''' |
| 388 | Try to locate the appropriate derived class dynamically, and cast |
| 389 | the pointer accordingly. |
| 390 | ''' |
| 391 | try: |
| 392 | p = PyObjectPtr(gdbval) |
| 393 | cls = cls.subclass_from_type(p.type()) |
| 394 | return cls(gdbval, cast_to=cls.get_gdb_type()) |
| 395 | except RuntimeError: |
| 396 | # Handle any kind of error e.g. NULL ptrs by simply using the base |
| 397 | # class |
| 398 | pass |
| 399 | return cls(gdbval) |
| 400 | |
| 401 | @classmethod |
| 402 | def get_gdb_type(cls): |
no test coverage detected