lsteamclient: Use dicts to lookup structs in gen_wrapper.py.

This commit is contained in:
Rémi Bernon 2021-12-14 18:31:34 +01:00 committed by Arkadiusz Hiler
parent e868aa6e1a
commit de5557448b

View file

@ -609,23 +609,17 @@ path_conversions = [
def strip_const(typename): def strip_const(typename):
return typename.replace("const ", "", 1) return typename.replace("const ", "", 1)
windows_structs32 = {}
def find_windows_struct(struct): def find_windows_struct(struct):
for child in list(windows_build.cursor.get_children()): return windows_structs32.get(strip_const(struct.spelling), None)
if strip_const(struct.spelling) == child.spelling:
return child.type
return None
windows_structs64 = {}
def find_windows64_struct(struct): def find_windows64_struct(struct):
for child in list(windows_build64.cursor.get_children()): return windows_structs64.get(strip_const(struct.spelling), None)
if strip_const(struct.spelling) == child.spelling:
return child.type
return None
linux_structs64 = {}
def find_linux64_struct(struct): def find_linux64_struct(struct):
for child in list(linux_build64.cursor.get_children()): return linux_structs64.get(strip_const(struct.spelling), None)
if strip_const(struct.spelling) == child.spelling:
return child.type
return None
def struct_needs_conversion_nocache(struct): def struct_needs_conversion_nocache(struct):
if strip_const(struct.spelling) in exempt_structs: if strip_const(struct.spelling) in exempt_structs:
@ -1309,8 +1303,13 @@ for sdkver in sdk_versions:
print('There were parse errors (windows build)') print('There were parse errors (windows build)')
pprint.pprint(diagnostics) pprint.pprint(diagnostics)
else: else:
children = list(linux_build.cursor.get_children()) linux_structs64 = dict(reversed([(child.spelling, child.type) for child
for child in children: 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: if child.kind == CursorKind.CLASS_DECL and child.displayname in classes:
handle_class(sdkver, child) handle_class(sdkver, child)
if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]: if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]: