Skip to content

Commit

Permalink
Improve argument parsing (still doesn't work properly)
Browse files Browse the repository at this point in the history
  • Loading branch information
CristiFati committed Feb 18, 2024
1 parent 8cac068 commit 4e8e185
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions com/win32com/makegw/makegwparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,20 @@ class Argument:
# -------------- -------- ------------ ------
regex = re.compile(r"/\* \[([^\]]*.*?)] \*/[ \t](.*[* ]+)(\w+)(\[ *])?[\),]")

@classmethod
def drop_rpc_metadata(cls, type_):
return " ".join(e for e in type_.split(" ") if not e.startswith("__RPC_"))

def __init__(self, good_interface_names):
self.good_interface_names = good_interface_names
self.inout = self.name = self.type = None
self.inout = None
self.name = None
self.type = None
self.raw_type = None
self.unc_type = None
self.const = 0
self.arrayDecl = 0
self.indirectionLevel = 0

def BuildFromFile(self, file):
"""Parse and build my data from a file
Expand All @@ -825,21 +834,17 @@ def BuildFromFile(self, file):
self.inout = mo.group(1).split("][")
typ = mo.group(2).strip()
self.raw_type = typ
self.indirectionLevel = 0
if mo.group(4): # Has "[ ]" decl
self.arrayDecl = 1
try:
pos = typ.rindex("__RPC_FAR")
self.indirectionLevel = self.indirectionLevel + 1
typ = typ[:pos].strip()
except ValueError:
pass
typ_no_rpc = self.drop_rpc_metadata(typ)
if typ != typ_no_rpc:
self.indirectionLevel += 1

typ = typ.replace("__RPC_FAR", "")
typ = self.drop_rpc_metadata(typ)
while 1:
try:
pos = typ.rindex("*")
self.indirectionLevel = self.indirectionLevel + 1
self.indirectionLevel += 1
typ = typ[:pos].strip()
except ValueError:
break
Expand Down

0 comments on commit 4e8e185

Please sign in to comment.