X-Git-Url: http://git.tdb.fi/?p=gldbg.git;a=blobdiff_plain;f=genwrap.py;h=ec239853875a386fdca9a4961b733a77622177c5;hp=81c4e33f8a285bba41d5d65b2cf8979962aacce0;hb=53c5f5f90611ce35d13f7051b26ac482d1336fc5;hpb=49f8063ce156a50d4b3b8c77a1508a21ea2bfe90 diff --git a/genwrap.py b/genwrap.py index 81c4e33..ec23985 100755 --- a/genwrap.py +++ b/genwrap.py @@ -66,11 +66,13 @@ class Typemap: return a==b def __getitem__(self, key): - return self.map[(key[0], "*", "*")] - for k, v in self.map.iteritems(): - if strip_name(k[0])==strip_name(key[0]) and self.wildcard_match(k[1], key[1]) and self.wildcard_match(k[2], key[2]): - return v - raise KeyError, key + try: + return self.map[(key[0], "*", "*")] + except KeyError: + for k, v in self.map.iteritems(): + if strip_name(k[0])==strip_name(key[0]) and self.wildcard_match(k[1], key[1]) and self.wildcard_match(k[2], key[2]): + return v + raise KeyError, key def update(self, other): self.map.update(other.map) @@ -113,7 +115,12 @@ class Function: self.size = size def derive_ctype(self): - self.ctype = typemap[(self.type, self.direction, self.kind)][0] + m = typemap[(self.type, self.direction, self.kind)] + self.ctype = m[0] + if m[1]!="*": + self.direction = m[1] + if m[2]!="*": + self.kind = m[2] self.base_ctype = self.ctype if self.kind=="value": if self.base_ctype.startswith("const "): @@ -255,7 +262,7 @@ class Files: def __init__(self, fn): self.typemap = None self.iomap = None - self.spec = None + self.specs = [] self.prefix = None self.ignore_categs = [] self.ignore_funcs = [] @@ -267,7 +274,7 @@ class Files: elif parts[0]=="iomap": self.iomap = parts[1] elif parts[0]=="spec": - self.spec = parts[1] + self.specs.append(parts[1]) elif parts[0]=="prefix": self.prefix = parts[1] elif parts[0]=="ignore": @@ -316,14 +323,18 @@ def read_spec(fn, prefix): return funcs template = Template(sys.argv[1]) +functions = [] for i in sys.argv[2:]: files = Files(i) typemap = Typemap(files.typemap) iomap = IOmap(files.iomap) - functions = read_spec(files.spec, files.prefix) - functions = [f for f in functions if f.name not in files.ignore_funcs and f.category not in files.ignore_categs] - for f in functions: - f.finalize() - - template.process(functions) + for s in files.specs: + funcs = read_spec(s, files.prefix) + funcs = [f for f in funcs if f.name not in files.ignore_funcs and f.category not in files.ignore_categs] + for f in funcs: + f.finalize() + names = [f.name for f in funcs] + functions = [f for f in functions if f.name not in names]+funcs + +template.process(functions)