lsteamclient: Use a dict for SDK sources / class mapping.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-09-20 21:15:40 +02:00
parent 732ee565b5
commit 7f722fb6d1
2 changed files with 40 additions and 34 deletions

View File

@ -98,8 +98,8 @@ SDK_VERSIONS = [
"099u", "099u",
] ]
SDK_SOURCES = [ SDK_SOURCES = {
("steam_api.h", [ "steam_api.h": [
"ISteamApps", "ISteamApps",
"ISteamAppList", "ISteamAppList",
"ISteamClient", "ISteamClient",
@ -125,44 +125,47 @@ SDK_SOURCES = [
"ISteamUserStats", "ISteamUserStats",
"ISteamUtils", "ISteamUtils",
"ISteamVideo" "ISteamVideo"
]), ],
("isteamappticket.h", [ "isteamappticket.h": [
"ISteamAppTicket" "ISteamAppTicket"
]), ],
("isteamgameserver.h", [ "isteamgameserver.h": [
"ISteamGameServer" "ISteamGameServer"
]), ],
("isteamgameserverstats.h", [ "isteamgameserverstats.h": [
"ISteamGameServerStats" "ISteamGameServerStats"
]), ],
("isteamgamestats.h", [ "isteamgamestats.h": [
"ISteamGameStats" "ISteamGameStats"
]), ],
("isteammasterserverupdater.h", [ "isteammasterserverupdater.h": [
"ISteamMasterServerUpdater" "ISteamMasterServerUpdater"
]), ],
("isteamgamecoordinator.h", [ "isteamgamecoordinator.h": [
"ISteamGameCoordinator" "ISteamGameCoordinator"
]), ],
("isteamparentalsettings.h", [ "isteamparentalsettings.h": [
"ISteamParentalSettings" "ISteamParentalSettings"
]), ],
("isteamnetworkingmessages.h", [ "isteamnetworkingmessages.h": [
"ISteamNetworkingMessages" "ISteamNetworkingMessages"
]), ],
("isteamnetworkingsockets.h", [ "isteamnetworkingsockets.h": [
"ISteamNetworkingSockets" "ISteamNetworkingSockets"
]), ],
("isteamnetworkingsocketsserialized.h", [ "isteamnetworkingsocketsserialized.h": [
"ISteamNetworkingSocketsSerialized" "ISteamNetworkingSocketsSerialized"
]), ],
("isteamnetworkingutils.h", [ "isteamnetworkingutils.h": [
"ISteamNetworkingUtils" "ISteamNetworkingUtils"
]), ],
("steamnetworkingfakeip.h", [ "steamnetworkingfakeip.h": [
"ISteamNetworkingFakeUDPPort" "ISteamNetworkingFakeUDPPort"
]), ],
] }
SDK_CLASSES = {klass: source for source, klasses in SDK_SOURCES.items()
for klass in klasses}
VERSION_ALIASES = { VERSION_ALIASES = {
#these interfaces are undocumented and binary compatible #these interfaces are undocumented and binary compatible
@ -1281,9 +1284,10 @@ for sdkver in SDK_VERSIONS:
iface, version = result.group(1, 2) iface, version = result.group(1, 2)
iface_versions[iface] = version iface_versions[iface] = version
source = [f"""#if __has_include("{sdkdir}/{file}") source = [f'#if __has_include("{sdkdir}/{file}")\n'
#include "{sdkdir}/{file}" f'#include "{sdkdir}/{file}"\n'
#endif""" for file, _ in SDK_SOURCES] f'#endif\n'
for file in SDK_SOURCES.keys()]
sources["source.cpp"] = "\n".join(source) sources["source.cpp"] = "\n".join(source)
windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes", windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes",
"-mms-bitfields", "-U__linux__", "-Wno-incompatible-ms-struct"] "-mms-bitfields", "-U__linux__", "-Wno-incompatible-ms-struct"]
@ -1320,10 +1324,9 @@ for sdkver in SDK_VERSIONS:
windows_structs64 = dict(reversed([(child.spelling, child.type) for child windows_structs64 = dict(reversed([(child.spelling, child.type) for child
in windows_build64.cursor.get_children()])) in windows_build64.cursor.get_children()]))
classes = dict([(klass, file) for file, classes in SDK_SOURCES for klass in classes])
for child in linux_build32.cursor.get_children(): for child in linux_build32.cursor.get_children():
if child.kind == CursorKind.CLASS_DECL and child.displayname in classes: if child.kind == CursorKind.CLASS_DECL and child.displayname in SDK_CLASSES:
handle_class(sdkver, child, classes[child.displayname]) handle_class(sdkver, child, SDK_CLASSES[child.displayname])
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)

View File

@ -100,6 +100,9 @@ SDK_SOURCES = [
), ),
] ]
SDK_CLASSES = {klass: source for source, klasses in SDK_SOURCES.items()
for klass in klasses}
STRUCTS_NEXT_IS_SIZE = [ STRUCTS_NEXT_IS_SIZE = [
"VREvent_t", "VREvent_t",
"VRControllerState001_t", "VRControllerState001_t",