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