mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-13 15:18:13 +03:00
lsteamclient: Add a manual override for the cpp side of the new networking API
This commit is contained in:
parent
81e8d149f3
commit
6195cb8a0a
@ -74,24 +74,6 @@ EResult cppISteamNetworkingSockets_SteamNetworkingSockets002_FlushMessagesOnConn
|
||||
return ((ISteamNetworkingSockets*)linux_side)->FlushMessagesOnConnection((HSteamNetConnection)hConn);
|
||||
}
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnConnection(void *linux_side, HSteamNetConnection hConn, winSteamNetworkingMessage_t_144 ** ppOutMessages, int nMaxMessages)
|
||||
{
|
||||
SteamNetworkingMessage_t * lin_ppOutMessages;
|
||||
win_to_lin_struct_SteamNetworkingMessage_t_144(ppOutMessages, &lin_ppOutMessages);
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection((HSteamNetConnection)hConn, &lin_ppOutMessages, (int)nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, &lin_ppOutMessages, ppOutMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnListenSocket(void *linux_side, HSteamListenSocket hSocket, winSteamNetworkingMessage_t_144 ** ppOutMessages, int nMaxMessages)
|
||||
{
|
||||
SteamNetworkingMessage_t * lin_ppOutMessages;
|
||||
win_to_lin_struct_SteamNetworkingMessage_t_144(ppOutMessages, &lin_ppOutMessages);
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnListenSocket((HSteamListenSocket)hSocket, &lin_ppOutMessages, (int)nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, &lin_ppOutMessages, ppOutMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool cppISteamNetworkingSockets_SteamNetworkingSockets002_GetConnectionInfo(void *linux_side, HSteamNetConnection hConn, SteamNetConnectionInfo_t * pInfo)
|
||||
{
|
||||
return ((ISteamNetworkingSockets*)linux_side)->GetConnectionInfo((HSteamNetConnection)hConn, (SteamNetConnectionInfo_t *)pInfo);
|
||||
|
@ -169,6 +169,13 @@ manually_handled_structs = [
|
||||
"SteamNetworkingMessage_t"
|
||||
]
|
||||
|
||||
manually_handled_methods = {
|
||||
"cppISteamNetworkingSockets_SteamNetworkingSockets002": [
|
||||
"ReceiveMessagesOnConnection",
|
||||
"ReceiveMessagesOnListenSocket"
|
||||
]
|
||||
}
|
||||
|
||||
# manual converters for simple types (function pointers)
|
||||
manual_type_converters = [
|
||||
"FSteamNetworkingSocketsDebugOutput"
|
||||
@ -432,6 +439,13 @@ def get_path_converter(parent):
|
||||
return conv
|
||||
return None
|
||||
|
||||
class DummyWriter(object):
|
||||
def write(self, s):
|
||||
#noop
|
||||
pass
|
||||
|
||||
dummy_writer = DummyWriter()
|
||||
|
||||
def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, existing_methods):
|
||||
used_name = method.spelling
|
||||
if used_name in existing_methods:
|
||||
@ -451,6 +465,10 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
||||
for param in list(method.get_children()):
|
||||
if param.kind == clang.cindex.CursorKind.PARM_DECL:
|
||||
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
|
||||
cfile.write("DEFINE_THISCALL_WRAPPER(%s_%s, %s)\n" % (winclassname, used_name, parambytes))
|
||||
cpp_h.write("extern ")
|
||||
if method.result_type.spelling.startswith("ISteam"):
|
||||
@ -629,10 +647,6 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
||||
real_type = param.type;
|
||||
while real_type.kind == clang.cindex.TypeKind.POINTER:
|
||||
real_type = real_type.get_pointee()
|
||||
if strip_const(real_type.spelling) in manually_handled_structs:
|
||||
#this is clumsy
|
||||
cpp.write(" lin_to_win_struct_%s_%s(retval, &lin_%s, %s);\n" % (real_type.spelling, sdkver, param.spelling, param.spelling))
|
||||
else:
|
||||
cpp.write(" lin_to_win_struct_%s_%s(&lin_%s, %s);\n" % (real_type.spelling, sdkver, param.spelling, param.spelling))
|
||||
else:
|
||||
cpp.write(" lin_to_win_struct_%s_%s(&lin_%s, &%s);\n" % (param.type.spelling, sdkver, param.spelling, param.spelling))
|
||||
@ -814,9 +828,6 @@ def handle_struct(sdkver, struct):
|
||||
hfile.write("struct %s;\n" % struct.displayname);
|
||||
|
||||
if strip_const(struct.spelling) in manually_handled_structs:
|
||||
#this is clumsy
|
||||
hfile.write("extern void %s(struct win%s **w, struct %s **l);\n" % (w2l_handler_name, struct_name, struct.displayname))
|
||||
hfile.write("extern void %s(int retval, struct %s **l, struct win%s **w);\n" % (l2w_handler_name, struct.displayname, struct_name))
|
||||
hfile.write("#endif\n\n")
|
||||
return
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "steam_defs.h"
|
||||
#include "steamworks_sdk_144/steam_api.h"
|
||||
#include "steamworks_sdk_144/isteamnetworkingsockets.h"
|
||||
#include "steamworks_sdk_144/steamnetworkingtypes.h"
|
||||
#include "steamclient_private.h"
|
||||
extern "C" {
|
||||
@ -58,13 +59,7 @@ void lin_FreeData(struct SteamNetworkingMessage_t *lin_msg)
|
||||
((void (__attribute__((ms_abi))*)(struct winSteamNetworkingMessage_t_144 *))msg->win_msg.m_pfnFreeData)(&msg->win_msg);
|
||||
}
|
||||
|
||||
void win_to_lin_struct_SteamNetworkingMessage_t_144(struct winSteamNetworkingMessage_t_144 **w, struct SteamNetworkingMessage_t **l)
|
||||
{
|
||||
TRACE("\n");
|
||||
/* it's an output param, do nothing. */
|
||||
}
|
||||
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_144(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_144 **w)
|
||||
void lin_to_win_struct_SteamNetworkingMessage_t_144(int n_messages, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_144 **w, int max_messages)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -114,6 +109,29 @@ void lin_to_win_struct_SteamNetworkingMessage_t_144(int n_messages, struct Steam
|
||||
w[i] = &msg->win_msg;
|
||||
TRACE("done with %u, returned wrapper %p\n", i, msg);
|
||||
}
|
||||
|
||||
for(; i < max_messages; ++i)
|
||||
w[i] = NULL;
|
||||
}
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnConnection(
|
||||
void *linux_side, HSteamNetConnection hConn,
|
||||
winSteamNetworkingMessage_t_144 **ppOutMessages, int nMaxMessages)
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnConnection(hConn, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cppISteamNetworkingSockets_SteamNetworkingSockets002_ReceiveMessagesOnListenSocket(
|
||||
void *linux_side, HSteamListenSocket hSocket,
|
||||
winSteamNetworkingMessage_t_144 **ppOutMessages, int nMaxMessages)
|
||||
{
|
||||
SteamNetworkingMessage_t *lin_ppOutMessages[nMaxMessages];
|
||||
int retval = ((ISteamNetworkingSockets*)linux_side)->ReceiveMessagesOnListenSocket(hSocket, lin_ppOutMessages, nMaxMessages);
|
||||
lin_to_win_struct_SteamNetworkingMessage_t_144(retval, lin_ppOutMessages, ppOutMessages, nMaxMessages);
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,8 +82,6 @@ struct winSteamNetworkingMessage_t_144 {
|
||||
#pragma pack( pop )
|
||||
typedef struct winSteamNetworkingMessage_t_144 winSteamNetworkingMessage_t_144;
|
||||
struct SteamNetworkingMessage_t;
|
||||
extern void win_to_lin_struct_SteamNetworkingMessage_t_144(struct winSteamNetworkingMessage_t_144 **w, struct SteamNetworkingMessage_t **l);
|
||||
extern void lin_to_win_struct_SteamNetworkingMessage_t_144(int retval, struct SteamNetworkingMessage_t **l, struct winSteamNetworkingMessage_t_144 **w);
|
||||
#endif
|
||||
|
||||
#if defined(SDKVER_143y) || !defined(__cplusplus)
|
||||
|
Loading…
x
Reference in New Issue
Block a user