mirror of
https://git.suyu.dev/suyu/Yucom.git
synced 2025-12-24 08:14:34 +01:00
lsteamclient: Add ISteamNetworkingSockets support
This commit is contained in:
parent
528d5d26cf
commit
649421bf26
40 changed files with 877 additions and 70 deletions
|
|
@ -134,6 +134,9 @@ files = [
|
|||
("isteamparentalsettings.h", [
|
||||
"ISteamParentalSettings"
|
||||
]),
|
||||
("isteamnetworkingsockets.h", [
|
||||
"ISteamNetworkingSockets"
|
||||
]),
|
||||
("isteamnetworkingsocketsserialized.h", [
|
||||
"ISteamNetworkingSocketsSerialized"
|
||||
]),
|
||||
|
|
@ -157,6 +160,11 @@ exempt_structs = [
|
|||
"ValvePackingSentinel_t"
|
||||
]
|
||||
|
||||
# we have converters for these written by hand because they're too complicated to generate
|
||||
manually_handled_structs = [
|
||||
"SteamNetworkingMessage_t"
|
||||
]
|
||||
|
||||
#struct_conversion_cache = {
|
||||
# '142': {
|
||||
# 'SteamUGCDetails_t': True,
|
||||
|
|
@ -371,6 +379,8 @@ def find_windows_struct(struct):
|
|||
def struct_needs_conversion_nocache(struct):
|
||||
if strip_const(struct.spelling) in exempt_structs:
|
||||
return False
|
||||
if strip_const(struct.spelling) in manually_handled_structs:
|
||||
return True
|
||||
windows_struct = find_windows_struct(struct)
|
||||
assert(not windows_struct is None) #must find windows_struct
|
||||
for field in struct.get_fields():
|
||||
|
|
@ -505,9 +515,13 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
|||
for param in need_convert:
|
||||
if param.type.kind == clang.cindex.TypeKind.POINTER:
|
||||
#handle single pointers, but not double pointers
|
||||
assert(param.type.get_pointee().kind == clang.cindex.TypeKind.RECORD)
|
||||
real_type = param.type;
|
||||
while real_type.kind == clang.cindex.TypeKind.POINTER:
|
||||
real_type = real_type.get_pointee()
|
||||
assert(param.type.get_pointee().kind == clang.cindex.TypeKind.RECORD or \
|
||||
strip_const(real_type.spelling) in manually_handled_structs)
|
||||
cpp.write(" %s lin_%s;\n" % (strip_const(param.type.get_pointee().spelling), param.spelling))
|
||||
cpp.write(" win_to_lin_struct_%s_%s(%s, &lin_%s);\n" % (strip_const(param.type.get_pointee().spelling), sdkver, param.spelling, param.spelling))
|
||||
cpp.write(" win_to_lin_struct_%s_%s(%s, &lin_%s);\n" % (strip_const(real_type.spelling), sdkver, param.spelling, param.spelling))
|
||||
else:
|
||||
#raw structs
|
||||
cpp.write(" %s lin_%s;\n" % (param.type.spelling, param.spelling))
|
||||
|
|
@ -596,7 +610,14 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
|||
for param in need_convert:
|
||||
if param.type.kind == clang.cindex.TypeKind.POINTER:
|
||||
if not "const " in param.type.spelling: #don't modify const arguments
|
||||
cpp.write(" lin_to_win_struct_%s_%s(&lin_%s, %s);\n" % (param.type.get_pointee().spelling, sdkver, param.spelling, param.spelling))
|
||||
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))
|
||||
if method.result_type.kind != clang.cindex.TypeKind.VOID and \
|
||||
|
|
@ -653,6 +674,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
|||
cpp = open("%s.cpp" % cppname, "w")
|
||||
cpp.write("#include \"steam_defs.h\"\n")
|
||||
cpp.write("#include \"steamworks_sdk_%s/steam_api.h\"\n" % sdkver)
|
||||
if os.path.isfile("steamworks_sdk_%s/steamnetworkingtypes.h" % sdkver):
|
||||
cpp.write("#include \"steamworks_sdk_%s/steamnetworkingtypes.h\"\n" % sdkver)
|
||||
if not fname == "steam_api.h":
|
||||
cpp.write("#include \"steamworks_sdk_%s/%s\"\n" % (sdkver, fname))
|
||||
cpp.write("#include \"steamclient_private.h\"\n")
|
||||
|
|
@ -741,7 +764,11 @@ def handle_struct(sdkver, struct):
|
|||
struct_needs_conversion(m.type):
|
||||
to_file.write(" win%s_%s %s;\n" % (m.type.spelling, sdkver, m.displayname))
|
||||
else:
|
||||
to_file.write(" %s %s;\n" % (m.type.spelling, m.displayname))
|
||||
if m.type.kind == clang.cindex.TypeKind.POINTER and \
|
||||
m.type.get_pointee().kind == clang.cindex.TypeKind.FUNCTIONPROTO:
|
||||
to_file.write(" void *%s; /*fn pointer*/\n" % m.displayname)
|
||||
else:
|
||||
to_file.write(" %s %s;\n" % (m.type.spelling, m.displayname))
|
||||
to_file.write("} __attribute__ ((ms_struct));\n")
|
||||
to_file.write("#pragma pack( pop )\n")
|
||||
|
||||
|
|
@ -764,10 +791,16 @@ def handle_struct(sdkver, struct):
|
|||
hfile.write("typedef struct win%s win%s;\n" % (struct_name, struct_name))
|
||||
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
|
||||
|
||||
hfile.write("extern void %s(const struct win%s *w, struct %s *l);\n" % (w2l_handler_name, struct_name, struct.displayname))
|
||||
hfile.write("extern void %s(const struct %s *l, struct win%s *w);\n" % (l2w_handler_name, struct.displayname, struct_name))
|
||||
hfile.write("#endif\n\n")
|
||||
|
||||
else:
|
||||
#for callbacks, we use the windows struct size in the cb dispatch switch
|
||||
windows_struct = find_windows_struct(struct.type)
|
||||
|
|
@ -812,6 +845,8 @@ def handle_struct(sdkver, struct):
|
|||
cppfile.write("#include \"steamworks_sdk_%s/isteamgameserverstats.h\"\n" % (sdkver))
|
||||
if os.path.isfile("steamworks_sdk_%s/isteamgamecoordinator.h" % sdkver):
|
||||
cppfile.write("#include \"steamworks_sdk_%s/isteamgamecoordinator.h\"\n" % sdkver)
|
||||
if os.path.isfile("steamworks_sdk_%s/steamnetworkingtypes.h" % sdkver):
|
||||
cppfile.write("#include \"steamworks_sdk_%s/steamnetworkingtypes.h\"\n" % sdkver)
|
||||
cppfile.write("#include \"steamclient_private.h\"\n")
|
||||
cppfile.write("extern \"C\" {\n")
|
||||
cppfile.write("#define SDKVER_%s\n" % sdkver)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue