lsteamclient: Use declspec to generate C++ method signature.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-09-23 16:11:42 +02:00 committed by Arkadiusz Hiler
parent 992384b88f
commit 122e0e362c
192 changed files with 2659 additions and 2666 deletions

View File

@ -266,9 +266,9 @@ bool cppISteamFriends_SteamFriends010_SendClanChatMessage(void *linux_side, CSte
return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText); return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText);
} }
int cppISteamFriends_SteamFriends010_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void * prgchText, int cchTextMax, EChatEntryType * _a, CSteamID * _b) int cppISteamFriends_SteamFriends010_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void *prgchText, int cchTextMax, EChatEntryType *_e, CSteamID *_f)
{ {
return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_a, (CSteamID *)_b); return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_e, (CSteamID *)_f);
} }
bool cppISteamFriends_SteamFriends010_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser) bool cppISteamFriends_SteamFriends010_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser)

View File

@ -271,9 +271,9 @@ bool cppISteamFriends_SteamFriends011_SendClanChatMessage(void *linux_side, CSte
return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText); return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText);
} }
int cppISteamFriends_SteamFriends011_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void * prgchText, int cchTextMax, EChatEntryType * _a, CSteamID * _b) int cppISteamFriends_SteamFriends011_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void *prgchText, int cchTextMax, EChatEntryType *_e, CSteamID *_f)
{ {
return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_a, (CSteamID *)_b); return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_e, (CSteamID *)_f);
} }
bool cppISteamFriends_SteamFriends011_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser) bool cppISteamFriends_SteamFriends011_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser)

View File

@ -271,9 +271,9 @@ bool cppISteamFriends_SteamFriends012_SendClanChatMessage(void *linux_side, CSte
return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText); return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText);
} }
int cppISteamFriends_SteamFriends012_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void * prgchText, int cchTextMax, EChatEntryType * _a, CSteamID * _b) int cppISteamFriends_SteamFriends012_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void *prgchText, int cchTextMax, EChatEntryType *_e, CSteamID *_f)
{ {
return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_a, (CSteamID *)_b); return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_e, (CSteamID *)_f);
} }
bool cppISteamFriends_SteamFriends012_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser) bool cppISteamFriends_SteamFriends012_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser)

View File

@ -271,9 +271,9 @@ bool cppISteamFriends_SteamFriends013_SendClanChatMessage(void *linux_side, CSte
return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText); return ((ISteamFriends*)linux_side)->SendClanChatMessage((CSteamID)steamIDClanChat, (const char *)pchText);
} }
int cppISteamFriends_SteamFriends013_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void * prgchText, int cchTextMax, EChatEntryType * _a, CSteamID * _b) int cppISteamFriends_SteamFriends013_GetClanChatMessage(void *linux_side, CSteamID steamIDClanChat, int iMessage, void *prgchText, int cchTextMax, EChatEntryType *_e, CSteamID *_f)
{ {
return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_a, (CSteamID *)_b); return ((ISteamFriends*)linux_side)->GetClanChatMessage((CSteamID)steamIDClanChat, (int)iMessage, (void *)prgchText, (int)cchTextMax, (EChatEntryType *)_e, (CSteamID *)_f);
} }
bool cppISteamFriends_SteamFriends013_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser) bool cppISteamFriends_SteamFriends013_IsClanChatAdmin(void *linux_side, CSteamID steamIDClanChat, CSteamID steamIDUser)

View File

@ -706,7 +706,17 @@ def method_unique_name(method, existing_methods):
return used_name return used_name
def underlying_type(decl):
if type(decl) is Cursor:
decl = decl.type
if decl.kind == TypeKind.LVALUEREFERENCE: return underlying_type(decl.get_pointee())
if decl.kind == TypeKind.CONSTANTARRAY: return underlying_type(decl.element_type)
if decl.kind == TypeKind.POINTER: return underlying_type(decl.get_pointee())
return decl
def param_needs_conversion(decl): def param_needs_conversion(decl):
decl = underlying_type(decl)
return decl.spelling not in WRAPPED_CLASSES and \ return decl.spelling not in WRAPPED_CLASSES and \
decl.kind == TypeKind.RECORD and \ decl.kind == TypeKind.RECORD and \
struct_needs_conversion(decl) struct_needs_conversion(decl)
@ -748,39 +758,24 @@ def handle_method_hpp(method_name, cppname, method, cpp_h):
def handle_method_cpp(method_name, classname, cppname, method, cpp): def handle_method_cpp(method_name, classname, cppname, method, cpp):
returns_record = method.result_type.get_canonical().kind == TypeKind.RECORD ret = f'{method.result_type.spelling} '
if method.result_type.spelling.startswith("ISteam"): if ret.startswith("ISteam"): ret = 'void *'
cpp.write("void *")
elif returns_record:
cpp.write(f"{method.result_type.spelling} ")
else:
cpp.write(f"{method.result_type.spelling} ")
cpp.write(f"{cppname}_{method_name}(void *linux_side")
unnamed = 'a'
need_convert = []
manual_convert = []
for param in list(method.get_children()):
if param.kind == CursorKind.PARM_DECL:
real_type = param.type
while real_type.kind == TypeKind.POINTER:
real_type = real_type.get_pointee()
if real_type.kind == TypeKind.RECORD and \
not real_type.spelling in WRAPPED_CLASSES and \
struct_needs_conversion(real_type):
need_convert.append(param)
elif real_type.spelling in MANUAL_TYPES:
manual_convert.append(param)
elif param.spelling in MANUAL_PARAMS:
manual_convert.append(param)
win_name = declspec(param, "") names = [p.spelling if p.spelling != "" else f'_{chr(0x61 + i)}'
for i, p in enumerate(method.get_arguments())]
params = [declspec(p, names[i]) for i, p in enumerate(method.get_arguments())]
if param.spelling == "": names = ['linux_side'] + names
cpp.write(f", {win_name} _{unnamed}") params = ['void *linux_side'] + params
unnamed = chr(ord(unnamed) + 1)
else: cpp.write(f'{ret}{cppname}_{method_name}({", ".join(params)})\n')
cpp.write(f", {win_name} {param.spelling}") cpp.write("{\n")
cpp.write(")\n{\n")
need_convert = [p for p in method.get_arguments()
if param_needs_conversion(p)]
manual_convert = [p for p in method.get_arguments()
if underlying_type(p).spelling in MANUAL_TYPES
or p.spelling in MANUAL_PARAMS]
for param in need_convert: for param in need_convert:
if param.type.kind == TypeKind.POINTER: if param.type.kind == TypeKind.POINTER:
@ -815,17 +810,15 @@ def handle_method_cpp(method_name, classname, cppname, method, cpp):
cpp.write(post_exec + '('); cpp.write(post_exec + '(');
cpp.write(f"(({classname}*)linux_side)->{method.spelling}(") cpp.write(f"(({classname}*)linux_side)->{method.spelling}(")
unnamed = 'a'
first = True first = True
for param in list(method.get_children()): for i, param in enumerate(method.get_arguments()):
if param.kind == CursorKind.PARM_DECL: if param.kind == CursorKind.PARM_DECL:
if not first: if not first:
cpp.write(", ") cpp.write(", ")
else: else:
first = False first = False
if param.spelling == "": if param.spelling == "":
cpp.write(f"({param.type.spelling})_{unnamed}") cpp.write(f"({param.type.spelling})_{chr(0x61 + i)}")
unnamed = chr(ord(unnamed) + 1)
elif param.type.kind == TypeKind.POINTER and \ elif param.type.kind == TypeKind.POINTER and \
param.type.get_pointee().spelling in WRAPPED_CLASSES: param.type.get_pointee().spelling in WRAPPED_CLASSES:
cpp.write(f"({param.type.spelling}){param.spelling}") cpp.write(f"({param.type.spelling}){param.spelling}")