Skip to content

Commit 61f43a7

Browse files
committed
[clang_utils.py] minor refactor
1 parent 8030259 commit 61f43a7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

bindings/python/scripts/clang_utils.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,33 @@ def getmembers_static(object, predicate=None):
5454
return results
5555

5656

57-
####################################################################################################
58-
5957
# A list to ignore the functions/properties that causes segmentation errors.
6058
ignore_list = ["mangled_name", "get_address_space", "get_typedef_name", "tls_kind"]
6159

6260

6361
def macro(instance, object):
64-
instance.check_functions = {}
65-
instance.get_functions = {}
66-
instance.properties = {}
62+
instance.check_functions_dict = {}
63+
instance.get_functions_dict = {}
64+
instance.properties_dict = {}
6765

6866
for entry in getmembers_static(object, predicate=inspect.isfunction):
6967
if entry[0] not in ignore_list:
7068
try:
7169
if entry[0].startswith("is_"):
72-
instance.check_functions[entry[0]] = entry[1](object)
70+
instance.check_functions_dict[entry[0]] = entry[1](object)
7371
except:
7472
continue
7573
try:
7674
if entry[0].startswith("get_"):
77-
instance.get_functions[entry[0]] = entry[1](object)
75+
instance.get_functions_dict[entry[0]] = entry[1](object)
7876
except:
7977
continue
8078

8179
for entry in getmembers_static(object):
8280
if entry[0] not in ignore_list:
8381
try:
8482
if isinstance(entry[1], property):
85-
instance.properties[entry[0]] = getattr(object, entry[0])
83+
instance.properties_dict[entry[0]] = getattr(object, entry[0])
8684
except:
8785
continue
8886

@@ -106,13 +104,13 @@ def __init__(self, cursor_type: clang.Type):
106104
class_docstring = """
107105
{class_name} class utilities
108106
109-
`check_functions`:
107+
`check_functions_dict`:
110108
- Functions that begin with "is_" i.e., checking functions
111109
- A list of two-tuples: (function_name: str, function_value: function)
112-
`get_functions`:
110+
`get_functions_dict`:
113111
- Functions that begin with "get_" i.e., getter functions
114112
- A list of two-tuples: (function_name: str, function_value: function)
115-
`properties`:
113+
`properties_dict`:
116114
- @property functions
117115
- A list of two-tuples: (property_name: str, property_value: property)
118116
"""

0 commit comments

Comments
 (0)