Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions steamworksparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
'isteamapps.h',
)

g_TypeNames = {
'bool': 'bool',
'const char *': 'string',
'double *': 'doublePtr',
'float *': 'floatPtr',
'float': 'float',
'int32 *': 'int32Ptr',
'int32': 'int32',
'int64 *': 'int64Ptr',
'int64': 'int64'
}

class Settings:
warn_utf8bom = False
warn_includeguardname = False
Expand Down Expand Up @@ -98,6 +110,7 @@ def __init__(self):
class Function:
def __init__(self):
self.name = ""
self.originalName = "" # name before overload correction
self.returntype = ""
self.args = [] # Arg
self.ifstatements = []
Expand All @@ -109,7 +122,7 @@ def __init__(self):
class Interface:
def __init__(self):
self.name = ""
self.functions = [] # Function
self.functions = {} # Function
self.c = None # Comment

class Define:
Expand Down Expand Up @@ -707,7 +720,7 @@ def parse_interface_functions(self, s):
continue

if s.funcState == 1: # Method Name
s.function.name = token.split("(", 1)[0]
s.function.originalName = s.function.name = token.split("(", 1)[0]

if token[-1] == ")":
s.funcState = 3
Expand Down Expand Up @@ -814,7 +827,24 @@ def parse_interface_functions(self, s):
if s.funcState == 3: # = 0; or line
if token.endswith(";"):
s.funcState = 0
s.interface.functions.append(s.function)

prevDecl = s.interface.functions.get(s.function.name)
# if function with same name already exists, find the
# different typed argument in order to rename accordingly
if prevDecl != None:
t1 = None
t2 = None
for i, arg in enumerate(s.function.args):
t1 = arg.type
t2 = prevDecl.args[i].type
if t1 != t2:
break
prevDecl.name = s.function.name + '_' + g_TypeNames[t2]
s.function.name = s.function.name + '_' + g_TypeNames[t1]

s.interface.functions[prevDecl.name] = prevDecl

s.interface.functions[s.function.name] = s.function
s.function = None
break
continue
Expand Down