xref: /llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-python-synth/ftsp.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1import lldb
2
3counter = 0
4
5
6class ftsp:
7    def __init__(self, valobj, dict):
8        self.valobj = valobj
9
10    def num_children(self):
11        if self.char.IsValid():
12            return 5
13        return 0
14
15    def get_child_index(self, name):
16        return 0
17
18    def get_child_at_index(self, index):
19        if index == 0:
20            return self.x.Cast(self.char)
21        if index == 4:
22            return self.valobj.CreateValueFromExpression(
23                str(index), "(char)(" + str(self.count) + ")"
24            )
25        return self.x.CreateChildAtOffset(str(index), index, self.char)
26
27    def update(self):
28        self.x = self.valobj.GetChildMemberWithName("x")
29        self.char = self.valobj.GetType().GetBasicType(lldb.eBasicTypeChar)
30        global counter
31        self.count = counter
32        counter = counter + 1
33        return True  # important: if we return False here, or fail to return, the test will fail
34
35
36def __lldb_init_module(debugger, dict):
37    global counter
38    counter = 0
39