2 Objective-C runtime wrapper for use by LLDB Python formatters
4 Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 See https://llvm.org/LICENSE.txt for license information.
6 SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 class AttributesDictionary
:
11 def __init__(self
, allow_reset
=True):
12 # need to do it this way to prevent endless recursion
13 self
.__dict
__["_dictionary"] = {}
14 self
.__dict
__["_allow_reset"] = allow_reset
16 def __getattr__(self
, name
):
17 if not self
._check
_exists
(name
):
19 value
= self
._dictionary
[name
]
22 def _set_impl(self
, name
, value
):
23 self
._dictionary
[name
] = value
25 def _check_exists(self
, name
):
26 return name
in self
._dictionary
28 def __setattr__(self
, name
, value
):
30 self
._set
_impl
(name
, value
)
32 self
.set_if_necessary(name
, value
)
34 def set_if_necessary(self
, name
, value
):
35 if not self
._check
_exists
(name
):
36 self
._set
_impl
(name
, value
)
41 return len(self
._dictionary
)