]> git.cworth.org Git - apitrace/blobdiff - specs/stdapi.py
Bring some of the virtual-memory-regions
[apitrace] / specs / stdapi.py
index 1b9bf58ad5f5ab0f4b6cb57f5f6f275048e3f628..a92b9ba5669035725e9e54c5ca2d136119106caa 100644 (file)
@@ -220,7 +220,8 @@ class Arg:
 
 class Function:
 
-    __id = 0
+    # 0-3 are reserved to memcpy, malloc, free, and realloc
+    __id = 4
 
     def __init__(self, type, name, args, call = '', fail = None, sideeffects=True):
         self.id = Function.__id
@@ -349,6 +350,22 @@ class Polymorphic(Type):
     def visit(self, visitor, *args, **kwargs):
         return visitor.visit_polymorphic(self, *args, **kwargs)
 
+    def iterswitch(self):
+        cases = [['default']]
+        types = [self.default_type]
+
+        for expr, type in self.switch_types:
+            case = 'case %s' % expr
+            try:
+                i = types.index(type)
+            except ValueError:
+                cases.append([case])
+                types.append(type)
+            else:
+                cases[i].append(case)
+
+        return zip(cases, types)
+
 
 class Visitor: