Skip to content

Commit f89fa5f

Browse files
committed
[parse.py] simplify structure
1 parent 61f43a7 commit f89fa5f

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

bindings/python/scripts/parse.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,17 @@ def generate_parsed_info(node):
100100
parsed_info["tokens"] = [x.spelling for x in cursor.get_tokens()]
101101
parsed_info["members"] = []
102102

103-
# add result of various kinds of checks available in cindex.py
104-
105-
def macro(key, object):
106-
"""
107-
A macro to make dictionaries of all checks and add them as elements to `parsed_info`.
108-
"""
109-
parsed_info[key] = {}
110-
for d in (
111-
object.check_functions,
112-
object.properties,
113-
):
114-
for k, v in d.items():
115-
parsed_info[key][k] = v
116-
117-
macro(key="CursorKind", object=CursorKindUtils(cursor_kind=cursor.kind))
118-
macro(key="Cursor", object=CursorUtils(cursor=cursor))
119-
macro(key="Type", object=TypeUtils(cursor_type=cursor.type))
120-
121-
####################################################################################################
103+
# add result of various kinds of checks available in cindex.py via clang_utils.py
104+
for key, object in (
105+
("CursorKind", CursorKindUtils(cursor_kind=cursor.kind)),
106+
("Cursor", CursorUtils(cursor=cursor)),
107+
("Type", TypeUtils(cursor_type=cursor.type)),
108+
):
109+
parsed_info[key] = {
110+
**object.check_functions_dict,
111+
**object.get_functions_dict,
112+
**object.properties_dict,
113+
}
122114

123115
# Hacky fixes
124116

@@ -133,8 +125,6 @@ def macro(key, object):
133125
# replace `TypeKind.value` with just `value`
134126
parsed_info["Type"]["kind"] = parsed_info["Type"]["kind"].name
135127

136-
####################################################################################################
137-
138128
# Get cursor's children and recursively add their info to a dictionary, as members of the parent
139129
for child_node in valid_children(node):
140130
child_parsed_info = generate_parsed_info(child_node)

0 commit comments

Comments
 (0)