]> git.tdb.fi Git - gldbg.git/blobdiff - genwrap.py
Support multiple .spec files
[gldbg.git] / genwrap.py
index 81c4e33f8a285bba41d5d65b2cf8979962aacce0..ec239853875a386fdca9a4961b733a77622177c5 100755 (executable)
@@ -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)