[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue through new member property (PR #118814)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 6 15:49:06 PST 2024
================
@@ -29,6 +29,19 @@ STRING_EXTENSION_OUTSIDE(SBValue)
'''An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.'''
return self.children_access (self)
+ def get_member_access_object(self):
+ '''An accessor function that returns an interface which provides subscript based lookup of child members.'''
+ class member_access:
+ def __init__(self, valobj):
+ self.valobj = valobj
+
+ def __getitem__(self, key):
+ if isinstance(key, str):
+ return self.valobj.GetChildMemberWithName(key)
+ raise TypeError("invalid subscript key")
----------------
clayborg wrote:
Do we want to be more clear here and say something other than `"invalid subscript key"`? Do we want to say `"member key values must be string values that specify the name of a member variable to access"`?
https://github.com/llvm/llvm-project/pull/118814
More information about the lldb-commits
mailing list