Package lldb :: Package formatters :: Module synth |
[hide private]
[frames] | no frames]

# Source Code for Module lldb.formatters.synth

     1  import lldb
     2
     3
     4 -class PythonObjectSyntheticChildProvider(object):
     5
     6 -    def __init__(self, value, internal_dict):
     7          self.value = value
     8          self.values = self.make_children()
     9          self.built_values = {}
    10          self.bo = self.value.target.byte_order
    11          self.ps = self.value.target.addr_size
    12
    13 -    def make_children(self):
    14          pass
    15
    16 -    def num_children(self):
    17          return len(self.values)
    18
    19 -    def get_child_index(self, name):
    20          i = 0
    21          for N, value in self.values:
    22              if N == name:
    23                  return i
    24              i += 1
    25          return None
    26
    27 -    def update(self):
    28          pass
    29
    30 -    def has_children(self):
    31          return len(self.values) > 0
    32
    33 -    def gen_child(self, name, value):
    34          data = None
    35          type = None
    36          if isinstance(value, int):
    37              data = lldb.SBData.CreateDataFromUInt32Array(
    38                  self.bo, self.ps, [value])
    39              type = self.value.target.GetBasicType(lldb.eBasicTypeInt)
    40          elif isinstance(value, long):
    41              data = lldb.SBData.CreateDataFromUInt64Array(
    42                  self.bo, self.ps, [value])
    43              type = self.value.target.GetBasicType(lldb.eBasicTypeLong)
    44          elif isinstance(value, float):
    45              data = lldb.SBData.CreateDataFromDoubleArray(
    46                  self.bo, self.ps, [value])
    47              type = self.value.target.GetBasicType(lldb.eBasicTypeDouble)
    48          elif isinstance(value, str):
    49              data = lldb.SBData.CreateDataFromCString(self.bo, self.ps, value)
    50              type = self.value.target.GetBasicType(
    51                  lldb.eBasicTypeChar).GetArrayType(
    52                  len(value))
    53          if (data is not None) and (type is not None):
    54              return self.value.CreateValueFromData(name, data, type)
    55          return None
    56
    57 -    def get_child_at_index(self, index):
    58          if index in self.built_values:
    59              return self.built_values[index]
    60
    61          bv = None
    62
    63          name, value = self.values[index]
    64          bv = self.gen_child(name, value)
    65          self.built_values[index] = bv
    66          return bv
    67