llvm-project
d289ff76 - [lldb] Reland: Add Pythonic API to SBStructuredData extension (#156771)

Commit
99 days ago
[lldb] Reland: Add Pythonic API to SBStructuredData extension (#156771) * Adds `dynamic` property to automatically convert `SBStructuredData` instances to the associated Python type (`str`, `int`, `float`, `bool`, `NoneType`, etc) * Implements `__getitem__` for Pythonic array and dictionary subscripting * Subscripting return the result of the `dynamic` property * Updates `__iter__` to support dictionary instances (supporting `for` loops) * Adds `__str__`, `__int__`, and `__float__` With these changes, these two expressions are equal: ```py data["name"] == data.GetValueForKey("name").GetStringValue(1024) ``` **Note**: Unlike the original commit (#155061), this re-commit removes the `__bool__` implementation, which broke crashlog. Somewhere in the crashlog execution, it depends on `__bool__` meaning only `IsValid()`. Additionally did some cleanup in TestStructuredDataAPI.py.
Author
Parents
Loading