mapi: Add "handcode" attribute to the script.
authorChia-I Wu <olv@lunarg.com>
Tue, 7 Dec 2010 05:33:11 +0000 (13:33 +0800)
committerChia-I Wu <olv@lunarg.com>
Fri, 24 Dec 2010 09:28:52 +0000 (17:28 +0800)
Entries with handcode attribute will be handled normally, except no
entry point will be generated for them.

src/mapi/mapi/mapi_abi.py

index 74d8a39f1736cc1cb3bec7fea89cd39b37972666..0059171e6ab8d5967c93f529145e26b089392624 100644 (file)
@@ -45,6 +45,7 @@ class ABIEntry(object):
         self.slot = attrs['slot']
         self.hidden = attrs['hidden']
         self.alias = attrs['alias']
+        self.handcode = attrs['handcode']
 
     def c_prototype(self):
         return '%s %s(%s)' % (self.c_return(), self.name, self.c_params())
@@ -132,6 +133,7 @@ def abi_parse_line(line):
             'slot': -1,
             'hidden': False,
             'alias': None,
+            'handcode': None,
     }
 
     # extract attributes from the first column
@@ -144,6 +146,8 @@ def abi_parse_line(line):
             attrs['hidden'] = True
         elif val.startswith('alias='):
             attrs['alias'] = val[6:]
+        elif val.startswith('handcode='):
+            attrs['handcode'] = val[9:]
         elif not val:
             pass
         else:
@@ -198,7 +202,14 @@ def abi_parse(filename):
         if entries[i].alias:
             raise Exception('first entry of slot %d aliases %s'
                     % (slot, entries[i].alias.name))
+        handcode = None
         while i < len(entries) and entries[i].slot == slot:
+            ent = entries[i]
+            if not handcode and ent.handcode:
+                handcode = ent.handcode
+            elif ent.handcode != handcode:
+                raise Exception('two aliases with handcode %s != %s',
+                        ent.handcode, handcode)
             i += 1
     if i < len(entries):
         raise Exception('there are %d invalid entries' % (len(entries) - 1))
@@ -320,6 +331,10 @@ class ABIPrinter(object):
             stmt3 += '%s((%s) func)(%s);' % (ret, cast, ent.c_args())
 
             disp = '%s\n{\n%s\n%s\n%s\n}' % (proto, stmt1, stmt2, stmt3)
+
+            if ent.handcode:
+                disp = '#if 0\n' + disp + '\n#endif'
+
             dispatches.append(disp)
 
         return '\n\n'.join(dispatches)
@@ -393,6 +408,9 @@ class ABIPrinter(object):
         for ent in self.entries:
             name = self._c_function(ent, prefix, True)
 
+            if ent.handcode:
+                asm.append('#if 0')
+
             if ent.hidden:
                 asm.append('".hidden "%s"\\n"' % (name))
 
@@ -403,6 +421,10 @@ class ABIPrinter(object):
             else:
                 asm.append('STUB_ASM_ENTRY(%s)"\\n"' % (name))
                 asm.append('"\\t"STUB_ASM_CODE("%d")"\\n"' % (ent.slot))
+
+            if ent.handcode:
+                asm.append('#endif')
+            asm.append('')
         asm.append(');')
 
         return "\n".join(asm)