Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ValveSoftware/Proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArkadiusz Hiler <ahiler@codeweavers.com>2022-06-14 17:21:49 +0300
committerArkadiusz Hiler <ahiler@codeweavers.com>2022-08-03 14:24:42 +0300
commitbe4a80dac6fc28377d0f211a73c3bd7db5ff00c8 (patch)
treecb491f5e6ae2e9f70464ea3c77a062cc1d308839
parentade03636545af01b9b70f2a6a0bc498c742f1652 (diff)
lsteamclient: Assume manual wrappers are needed for newer revisions of the interfaces.
-rwxr-xr-xlsteamclient/gen_wrapper.py130
1 files changed, 46 insertions, 84 deletions
diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py
index f0520844..fda38876 100755
--- a/lsteamclient/gen_wrapper.py
+++ b/lsteamclient/gen_wrapper.py
@@ -8,6 +8,7 @@ from __future__ import print_function
CLANG_PATH='/usr/lib/clang/13.0.1'
from clang.cindex import CursorKind, Index, Type, TypeKind
+from collections import namedtuple
import pprint
import sys
import os
@@ -188,96 +189,59 @@ manually_handled_structs = [
"SteamNetworkingMessage_t"
]
+Method = namedtuple('Method', ['name', 'version_func'], defaults=[lambda _: True])
+
manually_handled_methods = {
- #TODO: 001
- "cppISteamNetworkingSockets_SteamNetworkingSockets002": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnListenSocket"
- ],
- # 003 never appeared in a public SDK, but is an alias for 002 (the version in SDK 1.45 is actually 004 but incorrectly versioned as 003)
- "cppISteamNetworkingSockets_SteamNetworkingSockets004": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnListenSocket",
- ],
- #TODO: 005
- "cppISteamNetworkingSockets_SteamNetworkingSockets006": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnListenSocket",
- "SendMessages"
- ],
- #TODO: 007
- "cppISteamNetworkingSockets_SteamNetworkingSockets008": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnPollGroup",
- "SendMessages"
- ],
- "cppISteamNetworkingSockets_SteamNetworkingSockets009": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnPollGroup",
- "SendMessages"
- ],
- "cppISteamNetworkingSockets_SteamNetworkingSockets012": [
- "ReceiveMessagesOnConnection",
- "ReceiveMessagesOnPollGroup",
- "SendMessages",
- "CreateFakeUDPPort"
- ],
- "cppISteamNetworkingUtils_SteamNetworkingUtils003": [
- "AllocateMessage",
- "SetConfigValue",
- ],
- "cppISteamNetworkingUtils_SteamNetworkingUtils004": [
- "AllocateMessage",
- "SetConfigValue",
- ],
- "cppISteamNetworkingMessages_SteamNetworkingMessages002": [
- "ReceiveMessagesOnChannel"
+ #TODO: 001 005 007
+ #NOTE: 003 never appeared in a public SDK, but is an alias for 002 (the version in SDK 1.45 is actually 004 but incorrectly versioned as 003)
+ "cppISteamNetworkingSockets_SteamNetworkingSockets": [
+ Method("ReceiveMessagesOnConnection"),
+ Method("ReceiveMessagesOnListenSocket"),
+ Method("ReceiveMessagesOnPollGroup"),
+ Method("SendMessages"),
+ Method("CreateFakeUDPPort"),
],
- "cppISteamInput_SteamInput001": [
- "GetGlyphForActionOrigin",
- "GetGlyphForXboxOrigin"
+ "cppISteamNetworkingUtils_SteamNetworkingUtils": [
+ Method("AllocateMessage"),
+ Method("SetConfigValue", lambda version: version >= 3)
],
- "cppISteamInput_SteamInput002": [
- "GetGlyphForActionOrigin",
- "GetGlyphForXboxOrigin"
+ "cppISteamNetworkingMessages_SteamNetworkingMessages": [
+ Method("ReceiveMessagesOnChannel"),
],
- "cppISteamInput_SteamInput005": [
- "EnableActionEventCallbacks",
- "GetGlyphPNGForActionOrigin",
- "GetGlyphSVGForActionOrigin",
- "GetGlyphForActionOrigin_Legacy",
- "GetGlyphForXboxOrigin"
+ "cppISteamInput_SteamInput": [
+ Method("EnableActionEventCallbacks"),
+ Method("GetGlyphForActionOrigin"),
+ Method("GetGlyphPNGForActionOrigin"),
+ Method("GetGlyphSVGForActionOrigin"),
+ Method("GetGlyphForActionOrigin_Legacy"),
+ Method("GetGlyphForXboxOrigin"),
],
- "cppISteamInput_SteamInput006": [
- "EnableActionEventCallbacks",
- "GetGlyphPNGForActionOrigin",
- "GetGlyphSVGForActionOrigin",
- "GetGlyphForActionOrigin_Legacy",
- "GetGlyphForXboxOrigin"
+ "cppISteamController_SteamController": [
+ Method("GetGlyphForActionOrigin"),
+ Method("GetGlyphForXboxOrigin"),
],
- "cppISteamController_SteamController005": [
- "GetGlyphForActionOrigin"
+ "cppISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort": [
+ Method("DestroyFakeUDPPort"),
+ Method("ReceiveMessages"),
],
- "cppISteamController_SteamController006": [
- "GetGlyphForActionOrigin"
- ],
- "cppISteamController_SteamController007": [
- "GetGlyphForActionOrigin",
- "GetGlyphForXboxOrigin"
- ],
- "cppISteamController_SteamController008": [
- "GetGlyphForActionOrigin",
- "GetGlyphForXboxOrigin"
- ],
- "cppISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001": [
- "DestroyFakeUDPPort",
- "ReceiveMessages"
- ],
- "cppISteamUser_SteamUser008": [
- "InitiateGameConnection"
+ "cppISteamUser_SteamUser": [
+ #TODO: Do we need the the value -> pointer conversion for other versions of the interface?
+ Method("InitiateGameConnection", lambda version: version == 8),
],
}
+INTERFACE_NAME_VERSION = re.compile(r'^(?P<name>.+?)(?P<version>\d*)$')
+
+def method_needs_manual_handling(interface_with_version, method_name):
+ match_dict = INTERFACE_NAME_VERSION.match(interface_with_version).groupdict()
+ interface = match_dict['name']
+ version = int(match_dict['version']) if match_dict['version'] else None
+
+ method_list = manually_handled_methods.get(interface, [])
+ method = next(filter(lambda m: m.name == method_name, method_list), None)
+
+ return method and method.version_func(version)
+
# manual converters for simple types (function pointers)
manual_type_converters = [
"FSteamNetworkingSocketsDebugOutput",
@@ -728,10 +692,8 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
parambytes += 4
else:
parambytes += int(math.ceil(param.type.get_size()/4.0) * 4)
- if cppname in manually_handled_methods and \
- used_name in manually_handled_methods[cppname]:
- #just don't write the cpp function
- cpp = dummy_writer
+ if method_needs_manual_handling(cppname, used_name):
+ cpp = dummy_writer #just don't write the cpp function
cfile.write(f"DEFINE_THISCALL_WRAPPER({winclassname}_{used_name}, {parambytes})\n")
cpp_h.write("extern ")
if method.result_type.spelling.startswith("ISteam"):