mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-16 00:28:27 +03:00
lsteamclient: Use the all_records dict to lookup structs.
CW-Bug-Id: #22729
This commit is contained in:
parent
95f33e076d
commit
819257a800
@ -610,20 +610,11 @@ def canonical_typename(cursor):
|
|||||||
return name.removeprefix("const ")
|
return name.removeprefix("const ")
|
||||||
|
|
||||||
|
|
||||||
windows_structs32 = {}
|
def find_struct(struct, abi):
|
||||||
def find_windows_struct(struct):
|
|
||||||
name = canonical_typename(struct)
|
name = canonical_typename(struct)
|
||||||
return windows_structs32.get(name, None)
|
ret = all_records[sdkver][abi][1].get(name, None)
|
||||||
|
return ret.type if ret else None
|
||||||
|
|
||||||
windows_structs64 = {}
|
|
||||||
def find_windows64_struct(struct):
|
|
||||||
name = canonical_typename(struct)
|
|
||||||
return windows_structs64.get(name, None)
|
|
||||||
|
|
||||||
linux_structs64 = {}
|
|
||||||
def find_linux64_struct(struct):
|
|
||||||
name = canonical_typename(struct)
|
|
||||||
return linux_structs64.get(name, None)
|
|
||||||
|
|
||||||
def struct_needs_conversion_nocache(struct):
|
def struct_needs_conversion_nocache(struct):
|
||||||
name = canonical_typename(struct)
|
name = canonical_typename(struct)
|
||||||
@ -633,7 +624,7 @@ def struct_needs_conversion_nocache(struct):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
#check 32-bit compat
|
#check 32-bit compat
|
||||||
windows_struct = find_windows_struct(struct)
|
windows_struct = find_struct(struct, 'w32')
|
||||||
if windows_struct is None:
|
if windows_struct is None:
|
||||||
print("Couldn't find windows struct for " + struct.spelling)
|
print("Couldn't find windows struct for " + struct.spelling)
|
||||||
assert(not windows_struct is None) #must find windows_struct
|
assert(not windows_struct is None) #must find windows_struct
|
||||||
@ -645,9 +636,10 @@ def struct_needs_conversion_nocache(struct):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
#check 64-bit compat
|
#check 64-bit compat
|
||||||
windows_struct = find_windows64_struct(struct)
|
windows_struct = find_struct(struct, 'w64')
|
||||||
assert(not windows_struct is None) #must find windows_struct
|
assert(not windows_struct is None) #must find windows_struct
|
||||||
lin64_struct = find_linux64_struct(struct)
|
lin64_struct = find_struct(struct, 'u64')
|
||||||
|
|
||||||
assert(not lin64_struct is None) #must find lin64_struct
|
assert(not lin64_struct is None) #must find lin64_struct
|
||||||
for field in lin64_struct.get_fields():
|
for field in lin64_struct.get_fields():
|
||||||
if lin64_struct.get_offset(field.spelling) != windows_struct.get_offset(field.spelling):
|
if lin64_struct.get_offset(field.spelling) != windows_struct.get_offset(field.spelling):
|
||||||
@ -1027,7 +1019,7 @@ cb_table64 = {}
|
|||||||
def get_field_attribute_str(field):
|
def get_field_attribute_str(field):
|
||||||
if field.type.kind != TypeKind.RECORD:
|
if field.type.kind != TypeKind.RECORD:
|
||||||
return ""
|
return ""
|
||||||
win_struct = find_windows_struct(field)
|
win_struct = find_struct(field, 'w32')
|
||||||
if win_struct is None:
|
if win_struct is None:
|
||||||
align = field.type.get_align()
|
align = field.type.get_align()
|
||||||
else:
|
else:
|
||||||
@ -1106,9 +1098,10 @@ def handle_struct(sdkver, struct):
|
|||||||
hfile.write("#endif\n\n")
|
hfile.write("#endif\n\n")
|
||||||
else:
|
else:
|
||||||
#for callbacks, we use the windows struct size in the cb dispatch switch
|
#for callbacks, we use the windows struct size in the cb dispatch switch
|
||||||
windows_struct = find_windows_struct(struct)
|
windows_struct = find_struct(struct, 'w32')
|
||||||
windows_struct64 = find_windows64_struct(struct)
|
windows_struct64 = find_struct(struct, 'w64')
|
||||||
struct64 = find_linux64_struct(struct)
|
struct64 = find_struct(struct, 'u64')
|
||||||
|
|
||||||
struct_name = f"{struct.displayname}_{windows_struct.get_size()}"
|
struct_name = f"{struct.displayname}_{windows_struct.get_size()}"
|
||||||
l2w_handler_name = f"cb_{struct_name}"
|
l2w_handler_name = f"cb_{struct_name}"
|
||||||
if windows_struct64.get_size() != windows_struct.get_size():
|
if windows_struct64.get_size() != windows_struct.get_size():
|
||||||
@ -1272,7 +1265,7 @@ def parse(sources, abi):
|
|||||||
assert len(diagnostics) == 0
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
structs = build.cursor.get_children()
|
structs = build.cursor.get_children()
|
||||||
structs = [(child.spelling, child.type) for child in structs]
|
structs = [(child.spelling, child) for child in structs]
|
||||||
structs = dict(reversed(structs))
|
structs = dict(reversed(structs))
|
||||||
|
|
||||||
return build, structs
|
return build, structs
|
||||||
@ -1308,18 +1301,8 @@ def load(sdkver):
|
|||||||
|
|
||||||
|
|
||||||
def generate(sdkver, records):
|
def generate(sdkver, records):
|
||||||
global linux_structs32
|
|
||||||
global linux_structs64
|
|
||||||
global windows_structs32
|
|
||||||
global windows_structs64
|
|
||||||
|
|
||||||
print(f'generating SDK version {sdkver}...')
|
print(f'generating SDK version {sdkver}...')
|
||||||
linux_build32, linux_structs32 = records['u32']
|
for child in records['u32'][0].cursor.get_children():
|
||||||
linux_build64, linux_structs64 = records['u64']
|
|
||||||
windows_build32, windows_structs32 = records['w32']
|
|
||||||
windows_build64, windows_structs64 = records['w64']
|
|
||||||
|
|
||||||
for child in linux_build32.cursor.get_children():
|
|
||||||
if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]:
|
if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]:
|
||||||
handle_struct(sdkver, child)
|
handle_struct(sdkver, child)
|
||||||
|
|
||||||
@ -1364,12 +1347,6 @@ print('enumerating classes... 100%')
|
|||||||
|
|
||||||
for version, tuple in sorted(all_classes.items()):
|
for version, tuple in sorted(all_classes.items()):
|
||||||
sdkver, klass = tuple
|
sdkver, klass = tuple
|
||||||
|
|
||||||
linux_build32, linux_structs32 = all_records[sdkver]['u32']
|
|
||||||
linux_build64, linux_structs64 = all_records[sdkver]['u64']
|
|
||||||
windows_build32, windows_structs32 = all_records[sdkver]['w32']
|
|
||||||
windows_build64, windows_structs64 = all_records[sdkver]['w64']
|
|
||||||
|
|
||||||
handle_class(sdkver, klass, version, SDK_CLASSES[klass.displayname])
|
handle_class(sdkver, klass, version, SDK_CLASSES[klass.displayname])
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user