199451b44SJordan Rupprechtimport lldb 299451b44SJordan Rupprecht 399451b44SJordan Rupprecht 499451b44SJordan Rupprechtclass fooSynthProvider: 5*763b96c8SPavel Labath # For testing purposes, we'll keep track of the maximum value of 6*763b96c8SPavel Labath # max_num_children we've been called with. 7*763b96c8SPavel Labath MAX_NUM_CHILDREN_MAX = 0 8*763b96c8SPavel Labath 9*763b96c8SPavel Labath @classmethod 10*763b96c8SPavel Labath def reset_max_num_children_max(cls): 11*763b96c8SPavel Labath old_value = fooSynthProvider.MAX_NUM_CHILDREN_MAX 12*763b96c8SPavel Labath fooSynthProvider.MAX_NUM_CHILDREN_MAX = 0 13*763b96c8SPavel Labath return old_value 14*763b96c8SPavel Labath 1599451b44SJordan Rupprecht def __init__(self, valobj, dict): 1699451b44SJordan Rupprecht self.valobj = valobj 1799451b44SJordan Rupprecht self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt) 1899451b44SJordan Rupprecht 19*763b96c8SPavel Labath def num_children(self, max_num_children): 20*763b96c8SPavel Labath fooSynthProvider.MAX_NUM_CHILDREN_MAX = max( 21*763b96c8SPavel Labath fooSynthProvider.MAX_NUM_CHILDREN_MAX, max_num_children 22*763b96c8SPavel Labath ) 2399451b44SJordan Rupprecht return 3 2499451b44SJordan Rupprecht 2599451b44SJordan Rupprecht def get_child_at_index(self, index): 2699451b44SJordan Rupprecht if index == 0: 272238dcc3SJonas Devlieghere child = self.valobj.GetChildMemberWithName("a") 2899451b44SJordan Rupprecht if index == 1: 292238dcc3SJonas Devlieghere child = self.valobj.CreateChildAtOffset("fake_a", 1, self.int_type) 3099451b44SJordan Rupprecht if index == 2: 312238dcc3SJonas Devlieghere child = self.valobj.GetChildMemberWithName("r") 3299451b44SJordan Rupprecht return child 3399451b44SJordan Rupprecht 3499451b44SJordan Rupprecht def get_child_index(self, name): 352238dcc3SJonas Devlieghere if name == "a": 3699451b44SJordan Rupprecht return 0 372238dcc3SJonas Devlieghere if name == "fake_a": 3899451b44SJordan Rupprecht return 1 3999451b44SJordan Rupprecht return 2 40