From de5557448b5740083c3db4b2442a4a7d143e6891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 14 Dec 2021 18:31:34 +0100 Subject: [PATCH] lsteamclient: Use dicts to lookup structs in gen_wrapper.py. --- lsteamclient/gen_wrapper.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index 10eab0bb..429bb933 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -609,23 +609,17 @@ path_conversions = [ def strip_const(typename): return typename.replace("const ", "", 1) +windows_structs32 = {} def find_windows_struct(struct): - for child in list(windows_build.cursor.get_children()): - if strip_const(struct.spelling) == child.spelling: - return child.type - return None + return windows_structs32.get(strip_const(struct.spelling), None) +windows_structs64 = {} def find_windows64_struct(struct): - for child in list(windows_build64.cursor.get_children()): - if strip_const(struct.spelling) == child.spelling: - return child.type - return None + return windows_structs64.get(strip_const(struct.spelling), None) +linux_structs64 = {} def find_linux64_struct(struct): - for child in list(linux_build64.cursor.get_children()): - if strip_const(struct.spelling) == child.spelling: - return child.type - return None + return linux_structs64.get(strip_const(struct.spelling), None) def struct_needs_conversion_nocache(struct): if strip_const(struct.spelling) in exempt_structs: @@ -1309,8 +1303,13 @@ for sdkver in sdk_versions: print('There were parse errors (windows build)') pprint.pprint(diagnostics) else: - children = list(linux_build.cursor.get_children()) - for child in children: + linux_structs64 = dict(reversed([(child.spelling, child.type) for child + in linux_build64.cursor.get_children()])) + windows_structs32 = dict(reversed([(child.spelling, child.type) for child + in windows_build.cursor.get_children()])) + windows_structs64 = dict(reversed([(child.spelling, child.type) for child + in windows_build64.cursor.get_children()])) + for child in linux_build.cursor.get_children(): if child.kind == CursorKind.CLASS_DECL and child.displayname in classes: handle_class(sdkver, child) if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]: