broadcom/vc5: Introduce v3dx_macros.h and v3dx_pack.h headers.
[mesa.git] / src / mapi / mapi_abi.py
index faa34311cafd85bbd03ed77691794eeb9dad4d4d..82a2511ec39ef7a7c5ec865823f2d2c2b7413449 100644 (file)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 
 # Mesa 3-D graphics library
 #
@@ -347,28 +346,6 @@ class ABIPrinter(object):
                 '#define MAPI_TABLE_NUM_DYNAMIC %d') % (
                         num_static_entries, ABI_NUM_DYNAMIC_ENTRIES)
 
-    def c_mapi_table_initializer(self, prefix):
-        """Return the array initializer for mapi_table_fill."""
-        entries = [self._c_function(ent, prefix)
-                for ent in self.entries if not ent.alias]
-        pre = self.indent + '(mapi_proc) '
-        return pre + (',\n' + pre).join(entries)
-
-    def c_mapi_table_spec(self):
-        """Return the spec for mapi_init."""
-        specv1 = []
-        line = '"1'
-        for ent in self.entries:
-            if not ent.alias:
-                line += '\\0"\n'
-                specv1.append(line)
-                line = '"'
-            line += '%s\\0' % ent.name
-        line += '";'
-        specv1.append(line)
-
-        return self.indent + self.indent.join(specv1)
-
     def _c_function(self, ent, prefix, mangle=False, stringify=False):
         """Return the function name of an entry."""
         formats = {
@@ -412,13 +389,6 @@ class ABIPrinter(object):
 
         return cast
 
-    def c_private_declarations(self, prefix):
-        """Return the declarations of private functions."""
-        decls = [self._c_decl(ent, prefix) + ';'
-                for ent in self.entries if not ent.alias]
-
-        return "\n".join(decls)
-
     def c_public_dispatches(self, prefix, no_hidden):
         """Return the public dispatch functions."""
         dispatches = []
@@ -438,7 +408,7 @@ class ABIPrinter(object):
             if ent.ret:
                 ret = 'return '
             stmt1 = self.indent
-            stmt1 += 'const struct mapi_table *_tbl = %s();' % (
+            stmt1 += 'const struct _glapi_table *_tbl = %s();' % (
                     self.current_get)
             stmt2 = self.indent
             stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % (
@@ -668,22 +638,6 @@ class ABIPrinter(object):
                 print '#undef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN'
                 print '#endif /* MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN */'
 
-    def output_for_app(self):
-        print self.c_notice()
-        print
-        print self.c_private_declarations(self.prefix_app)
-        print
-        print '#ifdef API_TMP_DEFINE_SPEC'
-        print
-        print 'static const char %s_spec[] =' % (self.prefix_app)
-        print self.c_mapi_table_spec()
-        print
-        print 'static const mapi_proc %s_procs[] = {' % (self.prefix_app)
-        print self.c_mapi_table_initializer(self.prefix_app)
-        print '};'
-        print
-        print '#endif /* API_TMP_DEFINE_SPEC */'
-
 class GLAPIPrinter(ABIPrinter):
     """OpenGL API Printer"""
 
@@ -705,7 +659,6 @@ class GLAPIPrinter(ABIPrinter):
         self.lib_need_non_hidden_entries = True
 
         self.prefix_lib = 'GLAPI_PREFIX'
-        self.prefix_app = '_mesa_'
         self.prefix_noop = 'noop'
         self.prefix_warn = self.prefix_lib
 
@@ -728,7 +681,6 @@ class GLAPIPrinter(ABIPrinter):
 #define GLAPI_PREFIX_STR(func)  "gl"#func
 #endif /* USE_MGL_NAMESPACE */
 
-typedef int GLfixed;
 typedef int GLclampx;
 #endif /* _GLAPI_TMP_H_ */"""
 
@@ -745,14 +697,14 @@ class ES1APIPrinter(GLAPIPrinter):
     def _override_for_api(self, ent):
         if ent.xml_data is None:
             raise Exception('ES2 API printer requires XML input')
-        ent.hidden = ent.name not in \
-            ent.xml_data.entry_points_for_api_version('es1')
+        ent.hidden = (ent.name not in \
+            ent.xml_data.entry_points_for_api_version('es1')) \
+            or ent.hidden
         ent.handcode = False
 
     def _get_c_header(self):
         header = """#ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-typedef int GLfixed;
 typedef int GLclampx;
 #endif /* _GLAPI_TMP_H_ */"""
 
@@ -769,14 +721,22 @@ class ES2APIPrinter(GLAPIPrinter):
     def _override_for_api(self, ent):
         if ent.xml_data is None:
             raise Exception('ES2 API printer requires XML input')
-        ent.hidden = ent.name not in \
-            ent.xml_data.entry_points_for_api_version('es2')
+        ent.hidden = (ent.name not in \
+            ent.xml_data.entry_points_for_api_version('es2')) \
+            or ent.hidden
+
+        # This is hella ugly.  The same-named function in desktop OpenGL is
+        # hidden, but it needs to be exposed by libGLESv2 for OpenGL ES 3.0.
+        # There's no way to express in the XML that a function should be be
+        # hidden in one API but exposed in another.
+        if ent.name == 'GetInternalformativ':
+            ent.hidden = False
+
         ent.handcode = False
 
     def _get_c_header(self):
         header = """#ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-typedef int GLfixed;
 typedef int GLclampx;
 #endif /* _GLAPI_TMP_H_ */"""
 
@@ -804,42 +764,20 @@ class SharedGLAPIPrinter(GLAPIPrinter):
     def _get_c_header(self):
         header = """#ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-typedef int GLfixed;
 typedef int GLclampx;
 #endif /* _GLAPI_TMP_H_ */"""
 
         return header
 
-class VGAPIPrinter(ABIPrinter):
-    """OpenVG API Printer"""
-
-    def __init__(self, entries):
-        super(VGAPIPrinter, self).__init__(entries)
-
-        self.api_defines = ['VG_VGEXT_PROTOTYPES']
-        self.api_headers = ['"VG/openvg.h"', '"VG/vgext.h"']
-        self.api_call = 'VG_API_CALL'
-        self.api_entry = 'VG_API_ENTRY'
-        self.api_attrs = 'VG_API_EXIT'
-
-        self.prefix_lib = 'vg'
-        self.prefix_app = 'vega'
-        self.prefix_noop = 'noop'
-        self.prefix_warn = 'vg'
-
 def parse_args():
-    printers = ['vgapi', 'glapi', 'es1api', 'es2api', 'shared-glapi']
-    modes = ['lib', 'app']
+    printers = ['glapi', 'es1api', 'es2api', 'shared-glapi']
 
     parser = OptionParser(usage='usage: %prog [options] <filename>')
     parser.add_option('-p', '--printer', dest='printer',
             help='printer to use: %s' % (", ".join(printers)))
-    parser.add_option('-m', '--mode', dest='mode',
-            help='target user: %s' % (", ".join(modes)))
 
     options, args = parser.parse_args()
-    if not args or options.printer not in printers or \
-            options.mode not in modes:
+    if not args or options.printer not in printers:
         parser.print_help()
         sys.exit(1)
 
@@ -847,7 +785,6 @@ def parse_args():
 
 def main():
     printers = {
-        'vgapi': VGAPIPrinter,
         'glapi': GLAPIPrinter,
         'es1api': ES1APIPrinter,
         'es2api': ES2APIPrinter,
@@ -863,10 +800,7 @@ def main():
     abi_sanity_check(entries)
 
     printer = printers[options.printer](entries)
-    if options.mode == 'lib':
-        printer.output_for_lib()
-    else:
-        printer.output_for_app()
+    printer.output_for_lib()
 
 if __name__ == '__main__':
     main()