xref: /llvm-project/lldb/test/API/python_api/sbvalue_synthetic/formatter.py (revision 3068d277fd5ad0590a11dcb23af170ab31d7bda0)
1*3068d277SPavel Labathimport lldb
2*3068d277SPavel Labath
3*3068d277SPavel Labath
4*3068d277SPavel Labathclass FooSyntheticProvider:
5*3068d277SPavel Labath    def __init__(self, valobj, dict):
6*3068d277SPavel Labath        target = valobj.GetTarget()
7*3068d277SPavel Labath        data = lldb.SBData.CreateDataFromCString(lldb.eByteOrderLittle, 8, "S")
8*3068d277SPavel Labath        self._child = valobj.CreateValueFromData(
9*3068d277SPavel Labath            "synth_child", data, target.GetBasicType(lldb.eBasicTypeChar)
10*3068d277SPavel Labath        )
11*3068d277SPavel Labath
12*3068d277SPavel Labath    def num_children(self):
13*3068d277SPavel Labath        return 1
14*3068d277SPavel Labath
15*3068d277SPavel Labath    def get_child_at_index(self, index):
16*3068d277SPavel Labath        if index != 0:
17*3068d277SPavel Labath            return None
18*3068d277SPavel Labath        return self._child
19*3068d277SPavel Labath
20*3068d277SPavel Labath    def get_child_index(self, name):
21*3068d277SPavel Labath        if name == "synth_child":
22*3068d277SPavel Labath            return 0
23*3068d277SPavel Labath        return None
24