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

Source Code for Module lldb.formatters.attrib_fromdict

 1  """ 
 2  Objective-C runtime wrapper for use by LLDB Python formatters 
 3   
 4  part of The LLVM Compiler Infrastructure 
 5  This file is distributed under the University of Illinois Open Source 
 6  License. See LICENSE.TXT for details. 
 7  """ 
8 -class AttributesDictionary:
9 - def __init__(self, allow_reset = True):
10 self.__dict__['_dictionary'] = {} # need to do it this way to prevent endless recursion 11 self.__dict__['_allow_reset'] = allow_reset
12
13 - def __getattr__(self,name):
14 if not self._check_exists(name): 15 return None 16 value = self._dictionary[name] 17 return value
18
19 - def _set_impl(self,name,value):
20 self._dictionary[name] = value
21
22 - def _check_exists(self,name):
23 return name in self._dictionary
24
25 - def __setattr__(self,name,value):
26 if self._allow_reset: 27 self._set_impl(name,value) 28 else: 29 self.set_if_necessary(name,value)
30
31 - def set_if_necessary(self,name,value):
32 if not self._check_exists(name): 33 self._set_impl(name,value) 34 return True 35 return False
36
37 - def __len__(self):
38 return len(self._dictionary)
39