Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / mapi / mapi_abi.py
index dc48fa5935fdcd55197184c43f30cb62c9a5e871..fd67ba68ef9f142425ac3566fb47df24246d65d5 100644 (file)
@@ -29,8 +29,8 @@ from __future__ import print_function
 import sys
 # make it possible to import glapi
 import os
-GLAPI = os.path.join(".", os.path.dirname(sys.argv[0]), "glapi/gen")
-sys.path.append(GLAPI)
+GLAPI = os.path.join(".", os.path.dirname(__file__), "glapi", "gen")
+sys.path.insert(0, GLAPI)
 
 from operator import attrgetter
 import re
@@ -184,75 +184,6 @@ def abi_parse_xml(xml):
 
     return entries
 
-def abi_parse_line(line):
-    cols = [col.strip() for col in line.split(',')]
-
-    attrs = {
-            'slot': -1,
-            'hidden': False,
-            'alias': None,
-            'handcode': None,
-    }
-
-    # extract attributes from the first column
-    vals = cols[0].split(':')
-    while len(vals) > 1:
-        val = vals.pop(0)
-        if val.startswith('slot='):
-            attrs['slot'] = int(val[5:])
-        elif val == 'hidden':
-            attrs['hidden'] = True
-        elif val.startswith('alias='):
-            attrs['alias'] = val[6:]
-        elif val.startswith('handcode='):
-            attrs['handcode'] = val[9:]
-        elif not val:
-            pass
-        else:
-            raise Exception('unknown attribute %s' % val)
-    cols[0] = vals[0]
-
-    return (attrs, cols)
-
-def abi_parse(filename):
-    """Parse a CSV file for ABI entries."""
-    fp = open(filename) if filename != '-' else sys.stdin
-    lines = [line.strip() for line in fp.readlines()
-            if not line.startswith('#') and line.strip()]
-
-    entry_dict = {}
-    next_slot = 0
-    for line in lines:
-        attrs, cols = abi_parse_line(line)
-
-        # post-process attributes
-        if attrs['alias']:
-            try:
-                alias = entry_dict[attrs['alias']]
-            except KeyError:
-                raise Exception('failed to alias %s' % attrs['alias'])
-            if alias.alias:
-                raise Exception('recursive alias %s' % ent.name)
-            slot = alias.slot
-            attrs['alias'] = alias
-        else:
-            slot = next_slot
-            next_slot += 1
-
-        if attrs['slot'] < 0:
-            attrs['slot'] = slot
-        elif attrs['slot'] != slot:
-            raise Exception('invalid slot in %s' % (line))
-
-        ent = ABIEntry(cols, attrs)
-        if ent.name in entry_dict:
-            raise Exception('%s is duplicated' % (ent.name))
-        entry_dict[ent.name] = ent
-
-    entries = sorted(entry_dict.values())
-
-    return entries
-
 def abi_sanity_check(entries):
     if not entries:
         return
@@ -334,7 +265,8 @@ class ABIPrinter(object):
             if not self.need_entry_point(ent):
                 continue
             export = self.api_call if not ent.hidden else ''
-            decls.append(self._c_decl(ent, prefix, True, export) + ';')
+            if not ent.hidden or not self.lib_need_non_hidden_entries:
+                decls.append(self._c_decl(ent, prefix, True, export) + ';')
 
         return "\n".join(decls)
 
@@ -671,70 +603,9 @@ class GLAPIPrinter(ABIPrinter):
     def _get_c_header(self):
         header = """#ifndef _GLAPI_TMP_H_
 #define _GLAPI_TMP_H_
-#ifdef USE_MGL_NAMESPACE
-#define GLAPI_PREFIX(func)  mgl##func
-#define GLAPI_PREFIX_STR(func)  "mgl"#func
-#else
 #define GLAPI_PREFIX(func)  gl##func
 #define GLAPI_PREFIX_STR(func)  "gl"#func
-#endif /* USE_MGL_NAMESPACE */
 
-typedef int GLclampx;
-#endif /* _GLAPI_TMP_H_ */"""
-
-        return header
-
-class ES1APIPrinter(GLAPIPrinter):
-    """OpenGL ES 1.x API Printer"""
-
-    def __init__(self, entries):
-        super(ES1APIPrinter, self).__init__(entries)
-        self.prefix_lib = 'gl'
-        self.prefix_warn = 'gl'
-
-    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')) \
-            or ent.hidden
-        ent.handcode = False
-
-    def _get_c_header(self):
-        header = """#ifndef _GLAPI_TMP_H_
-#define _GLAPI_TMP_H_
-typedef int GLclampx;
-#endif /* _GLAPI_TMP_H_ */"""
-
-        return header
-
-class ES2APIPrinter(GLAPIPrinter):
-    """OpenGL ES 2.x API Printer"""
-
-    def __init__(self, entries):
-        super(ES2APIPrinter, self).__init__(entries)
-        self.prefix_lib = 'gl'
-        self.prefix_warn = 'gl'
-
-    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')) \
-            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 GLclampx;
 #endif /* _GLAPI_TMP_H_ */"""
 
@@ -770,7 +641,7 @@ typedef int GLclampx;
 def parse_args():
     printers = ['glapi', 'es1api', 'es2api', 'shared-glapi']
 
-    parser = OptionParser(usage='usage: %prog [options] <filename>')
+    parser = OptionParser(usage='usage: %prog [options] <xml_file>')
     parser.add_option('-p', '--printer', dest='printer',
             help='printer to use: %s' % (", ".join(printers)))
 
@@ -779,22 +650,21 @@ def parse_args():
         parser.print_help()
         sys.exit(1)
 
+    if not args[0].endswith('.xml'):
+        parser.print_help()
+        sys.exit(1)
+
     return (args[0], options)
 
 def main():
     printers = {
         'glapi': GLAPIPrinter,
-        'es1api': ES1APIPrinter,
-        'es2api': ES2APIPrinter,
         'shared-glapi': SharedGLAPIPrinter,
     }
 
     filename, options = parse_args()
 
-    if filename.endswith('.xml'):
-        entries = abi_parse_xml(filename)
-    else:
-        entries = abi_parse(filename)
+    entries = abi_parse_xml(filename)
     abi_sanity_check(entries)
 
     printer = printers[options.printer](entries)