=== modified file 'demongle/backends/msvc.py' --- demongle/backends/msvc.py 2007-10-10 06:52:58 +0000 +++ demongle/backends/msvc.py 2007-10-11 10:33:57 +0000 @@ -144,10 +144,10 @@ # ReferenceOrPointer in the BNF Syntax ptrtypes = { - "A": (None, "&"), - "P": (None, "*"), - "Q": ("const", "*"), - "R": ("volatile", "*"), + "A": ((), "&"), + "P": ((), "*"), + "Q": (("const",), "*"), + "R": (("volatile",), "*"), } # Pointer in the BNF Syntax @@ -155,9 +155,9 @@ # second char of each of these doesn't conflict with SimpleDataType/X # this might change in the future so be weary of breakage ptrtypes2 = { - "AP": (None, "*"), - "BQ": ("const", "*"), - "CR": ("volatile", "*"), + "AP": ((), "*"), + "BQ": (("const",), "*"), + "CR": (("volatile",), "*"), } storageclasses = { @@ -175,6 +175,10 @@ "D": "const volatile", } +modifiers2 = { + "E": "__ptr64", +} + digits = { "A": "0", "B": "1", @@ -297,7 +301,7 @@ # XXX: what's the proper pointer syntax? - Think I got it right now (http://articles.techrepublic.com.com/5100-22-1052161.html) # XXX: should these be reversed here or when constructing the object? types = reversed(self.types) - pairs = ["%s%s " % (ptrtype, modifier) if modifier else "%s" % ptrtype for modifier, ptrtype in types] + pairs = ["%s%s " % (ptrtype, " ".join(modifiers)) if modifiers else "%s" % ptrtype for modifiers, ptrtype in types] #prefixes = [t[0] for t in self.types if t[0]] #ptrs = reversed([t[1] for t in self.types]) return "%s %s" % (self.to, "".join(pairs).rstrip()) @@ -328,13 +332,13 @@ return "%s %s(%s)" % (ret_type, self.name, args) class Method(Function): - def __init__(self, name, type, modifier, callingconv, ret_type, args, storage): + def __init__(self, name, type, modifiers, callingconv, ret_type, args, storage): Function.__init__(self, name, type, callingconv, ret_type, args, storage) - self.modifier = modifier + self.modifiers = modifiers def __str__(self): #args = ", ".join(str(arg) for arg in self.args) - postfix = " %s" % self.modifier if self.modifier else "" + postfix = " %s" % " ".join(self.modifiers) if self.modifiers else "" prefix = "%s " % self.type["special"] if self.type["special"] else "" return "%s%s%s" % (prefix, Function.__str__(self), postfix) @@ -472,14 +476,24 @@ # XXX: Pointers? m = rop_re.match(curr) if m: - types = [ptrtypes[m.group(0)]] + types = [] + curtype = ptrtypes[m.group(0)] curr = curr[m.end():] + if curr[0] in modifiers2: + curtype = (curtype[0] + (modifiers2[curr[0]],),) + curtype[1:] + curr = curr[1:] + types.append(curtype) while True: m = ptrref_re.match(curr) if not m: break - types.append(ptrtypes2[m.group(0)]) + curtype = ptrtypes2[m.group(0)] curr = curr[m.end():] + if curr[0] in modifiers2: + curtype = (curtype[0] + (modifiers2[curr[0]],),) + curtype[1:] + curr = curr[1:] + types.append(curtype) + #print curr, types if curr[0] in ("A", "B", "C"): # XXX: looks like A == normal, B == const, C == volatile modifier = modifiers[curr[0]] @@ -574,12 +588,19 @@ typecode_d["type"] = typecodes[gd["function"]] if typecode_d["type"]["type"] == "method": if typecode_d["type"]["special"] not in ("static", "thunk"): - # read the modifier - typecode_d["modifier"] = modifiers[curr[0]] + # read the modifier(s) + mods = [] + if curr[0] in modifiers2: + mods.append(modifiers2[curr[0]]) + curr = curr[1:] + mod = modifiers[curr[0]] + if mod is not None: + mods.append(modifiers[curr[0]]) + typecode_d["modifiers"] = mods curr = curr[1:] else: # static method, has no modifier, fake it though - typecode_d["modifier"] = None + typecode_d["modifiers"] = () functype, curr = get_functype(curr, data) typecode_d.update(functype) elif gd["datatype"]: @@ -645,7 +666,7 @@ if type == "data": ret = Variable(name, typecode["type"], typecode["datatype"], typecode["storage_class"]) elif type == "method": - ret = Method(name, typecode["type"], typecode["modifier"], typecode["cconv"], typecode["ret"], typecode["args"], typecode["storage_class"]) + ret = Method(name, typecode["type"], typecode["modifiers"], typecode["cconv"], typecode["ret"], typecode["args"], typecode["storage_class"]) elif type == "compiler_data": ret = CompilerData(name, typecode["type"], typecode["modifier"], typecode["name"]) elif type == "function":