for arg in fn["args"]: vartype = arg[0] varname = arg[1] a = a + [psimplevardecl(vartype, varname)] reto = "" s = "; \n".join(a) if p == "function": fnret = fn["return"] if fnret.endswith(" *"): fnret = fnret[:-2] + "*" # strip space in the middle reto = ": " + exttype( fnret, True ) #psimplevardecl(fn["return"], "") # exttype(, True) True) structlines.append(fn["name"] + ": " + p + "(" + s + ")" + reto + "; cdecl;") funcs[fn["name"]] = [fn, s, reto] else: # item contains "[]" is resolved incorrectly, so cheat: if item.find("[]") > -1: item = item.replace("[]", "[1]") # now use the normal variable parsing function vartype, varname = parseVar(item) # resolve "[5]" to unrolling
from tool2 import fnsFromFNLines, exttype path1 = "pango" ############ add external declarations ############### fnlib = path1.replace("-", "") + "lib" lines = file("/tmp/E", "r").readlines() fns = fnsFromFNLines(lines) for fnname, fn in fns.items(): if fn["return"] != "void" and fn["return"] != None: ftype = "function" fnreturn = ": " + exttype(fn["return"], True) else: ftype = "procedure" fnreturn = "" global c2pfuncparamoverride if fnname in c2pfuncparamoverride: over = c2pfuncparamoverride[fnname] else: over = None fnparams = [] ix = 1 for arg in fn["args"]: ty = arg[0] na = arg[1]
for arg in fn["args"]: vartype = arg[0] varname = arg[1] a = a + [psimplevardecl(vartype, varname)] reto = "" s = "; \n".join(a) if p == "function": fnret = fn["return"] if fnret.endswith(" *"): fnret = fnret[:-2] + "*" # strip space in the middle reto = ": " + exttype(fnret, True) #psimplevardecl(fn["return"], "") # exttype(, True) True) structlines.append(fn["name"] + ": " + p + "(" + s + ")" + reto + "; cdecl;") funcs[fn["name"]] = [fn, s, reto] else: # item contains "[]" is resolved incorrectly, so cheat: if item.find("[]") > -1: item = item.replace("[]", "[1]") # now use the normal variable parsing function vartype, varname = parseVar(item) # resolve "[5]" to unrolling ctr = 0 if varname.endswith("]"): # array that needs to be unrolled (sigh)