mirror of
https://github.com/ValveSoftware/Proton.git
synced 2024-12-27 07:05:46 +03:00
lsteamclient: Assume manual wrappers are needed for newer revisions of the interfaces.
This commit is contained in:
parent
ade0363654
commit
be4a80dac6
@ -8,6 +8,7 @@ from __future__ import print_function
|
|||||||
CLANG_PATH='/usr/lib/clang/13.0.1'
|
CLANG_PATH='/usr/lib/clang/13.0.1'
|
||||||
|
|
||||||
from clang.cindex import CursorKind, Index, Type, TypeKind
|
from clang.cindex import CursorKind, Index, Type, TypeKind
|
||||||
|
from collections import namedtuple
|
||||||
import pprint
|
import pprint
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
@ -188,96 +189,59 @@ manually_handled_structs = [
|
|||||||
"SteamNetworkingMessage_t"
|
"SteamNetworkingMessage_t"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Method = namedtuple('Method', ['name', 'version_func'], defaults=[lambda _: True])
|
||||||
|
|
||||||
manually_handled_methods = {
|
manually_handled_methods = {
|
||||||
#TODO: 001
|
#TODO: 001 005 007
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets002": [
|
#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)
|
||||||
"ReceiveMessagesOnConnection",
|
"cppISteamNetworkingSockets_SteamNetworkingSockets": [
|
||||||
"ReceiveMessagesOnListenSocket"
|
Method("ReceiveMessagesOnConnection"),
|
||||||
|
Method("ReceiveMessagesOnListenSocket"),
|
||||||
|
Method("ReceiveMessagesOnPollGroup"),
|
||||||
|
Method("SendMessages"),
|
||||||
|
Method("CreateFakeUDPPort"),
|
||||||
],
|
],
|
||||||
# 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)
|
"cppISteamNetworkingUtils_SteamNetworkingUtils": [
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets004": [
|
Method("AllocateMessage"),
|
||||||
"ReceiveMessagesOnConnection",
|
Method("SetConfigValue", lambda version: version >= 3)
|
||||||
"ReceiveMessagesOnListenSocket",
|
|
||||||
],
|
],
|
||||||
#TODO: 005
|
"cppISteamNetworkingMessages_SteamNetworkingMessages": [
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets006": [
|
Method("ReceiveMessagesOnChannel"),
|
||||||
"ReceiveMessagesOnConnection",
|
|
||||||
"ReceiveMessagesOnListenSocket",
|
|
||||||
"SendMessages"
|
|
||||||
],
|
],
|
||||||
#TODO: 007
|
"cppISteamInput_SteamInput": [
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets008": [
|
Method("EnableActionEventCallbacks"),
|
||||||
"ReceiveMessagesOnConnection",
|
Method("GetGlyphForActionOrigin"),
|
||||||
"ReceiveMessagesOnPollGroup",
|
Method("GetGlyphPNGForActionOrigin"),
|
||||||
"SendMessages"
|
Method("GetGlyphSVGForActionOrigin"),
|
||||||
|
Method("GetGlyphForActionOrigin_Legacy"),
|
||||||
|
Method("GetGlyphForXboxOrigin"),
|
||||||
],
|
],
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets009": [
|
"cppISteamController_SteamController": [
|
||||||
"ReceiveMessagesOnConnection",
|
Method("GetGlyphForActionOrigin"),
|
||||||
"ReceiveMessagesOnPollGroup",
|
Method("GetGlyphForXboxOrigin"),
|
||||||
"SendMessages"
|
|
||||||
],
|
],
|
||||||
"cppISteamNetworkingSockets_SteamNetworkingSockets012": [
|
"cppISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort": [
|
||||||
"ReceiveMessagesOnConnection",
|
Method("DestroyFakeUDPPort"),
|
||||||
"ReceiveMessagesOnPollGroup",
|
Method("ReceiveMessages"),
|
||||||
"SendMessages",
|
|
||||||
"CreateFakeUDPPort"
|
|
||||||
],
|
],
|
||||||
"cppISteamNetworkingUtils_SteamNetworkingUtils003": [
|
"cppISteamUser_SteamUser": [
|
||||||
"AllocateMessage",
|
#TODO: Do we need the the value -> pointer conversion for other versions of the interface?
|
||||||
"SetConfigValue",
|
Method("InitiateGameConnection", lambda version: version == 8),
|
||||||
],
|
|
||||||
"cppISteamNetworkingUtils_SteamNetworkingUtils004": [
|
|
||||||
"AllocateMessage",
|
|
||||||
"SetConfigValue",
|
|
||||||
],
|
|
||||||
"cppISteamNetworkingMessages_SteamNetworkingMessages002": [
|
|
||||||
"ReceiveMessagesOnChannel"
|
|
||||||
],
|
|
||||||
"cppISteamInput_SteamInput001": [
|
|
||||||
"GetGlyphForActionOrigin",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamInput_SteamInput002": [
|
|
||||||
"GetGlyphForActionOrigin",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamInput_SteamInput005": [
|
|
||||||
"EnableActionEventCallbacks",
|
|
||||||
"GetGlyphPNGForActionOrigin",
|
|
||||||
"GetGlyphSVGForActionOrigin",
|
|
||||||
"GetGlyphForActionOrigin_Legacy",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamInput_SteamInput006": [
|
|
||||||
"EnableActionEventCallbacks",
|
|
||||||
"GetGlyphPNGForActionOrigin",
|
|
||||||
"GetGlyphSVGForActionOrigin",
|
|
||||||
"GetGlyphForActionOrigin_Legacy",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamController_SteamController005": [
|
|
||||||
"GetGlyphForActionOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamController_SteamController006": [
|
|
||||||
"GetGlyphForActionOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamController_SteamController007": [
|
|
||||||
"GetGlyphForActionOrigin",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamController_SteamController008": [
|
|
||||||
"GetGlyphForActionOrigin",
|
|
||||||
"GetGlyphForXboxOrigin"
|
|
||||||
],
|
|
||||||
"cppISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001": [
|
|
||||||
"DestroyFakeUDPPort",
|
|
||||||
"ReceiveMessages"
|
|
||||||
],
|
|
||||||
"cppISteamUser_SteamUser008": [
|
|
||||||
"InitiateGameConnection"
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 converters for simple types (function pointers)
|
||||||
manual_type_converters = [
|
manual_type_converters = [
|
||||||
"FSteamNetworkingSocketsDebugOutput",
|
"FSteamNetworkingSocketsDebugOutput",
|
||||||
@ -728,10 +692,8 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
|||||||
parambytes += 4
|
parambytes += 4
|
||||||
else:
|
else:
|
||||||
parambytes += int(math.ceil(param.type.get_size()/4.0) * 4)
|
parambytes += int(math.ceil(param.type.get_size()/4.0) * 4)
|
||||||
if cppname in manually_handled_methods and \
|
if method_needs_manual_handling(cppname, used_name):
|
||||||
used_name in manually_handled_methods[cppname]:
|
cpp = dummy_writer #just don't write the cpp function
|
||||||
#just don't write the cpp function
|
|
||||||
cpp = dummy_writer
|
|
||||||
cfile.write(f"DEFINE_THISCALL_WRAPPER({winclassname}_{used_name}, {parambytes})\n")
|
cfile.write(f"DEFINE_THISCALL_WRAPPER({winclassname}_{used_name}, {parambytes})\n")
|
||||||
cpp_h.write("extern ")
|
cpp_h.write("extern ")
|
||||||
if method.result_type.spelling.startswith("ISteam"):
|
if method.result_type.spelling.startswith("ISteam"):
|
||||||
|
Loading…
Reference in New Issue
Block a user