summaryrefslogtreecommitdiff
path: root/src/mapi/mapi/mapi_abi.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapi/mapi/mapi_abi.py')
-rw-r--r--src/mapi/mapi/mapi_abi.py93
1 files changed, 76 insertions, 17 deletions
diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py
index 47be8c5b4a..cb9fc0ef84 100644
--- a/src/mapi/mapi/mapi_abi.py
+++ b/src/mapi/mapi/mapi_abi.py
@@ -295,6 +295,7 @@ class ABIPrinter(object):
self.indent = ' ' * 3
self.noop_warn = 'noop_warn'
self.noop_generic = 'noop_generic'
+ self.current_get = 'entry_current_get'
self.api_defines = []
self.api_headers = ['"KHR/khrplatform.h"']
@@ -307,7 +308,8 @@ class ABIPrinter(object):
self.lib_need_table_size = True
self.lib_need_noop_array = True
self.lib_need_stubs = True
- self.lib_need_entries = True
+ self.lib_need_all_entries = True
+ self.lib_need_non_hidden_entries = False
def c_notice(self):
return '/* This file is automatically generated by mapi_abi.py. Do not modify. */'
@@ -337,11 +339,7 @@ class ABIPrinter(object):
def c_mapi_table(self):
"""Return defines of the dispatch table size."""
- num_static_entries = 0
- for ent in self.entries:
- if not ent.alias:
- num_static_entries += 1
-
+ num_static_entries = self.entries[-1].slot + 1
return ('#define MAPI_TABLE_NUM_STATIC %d\n' + \
'#define MAPI_TABLE_NUM_DYNAMIC %d') % (
num_static_entries, ABI_NUM_DYNAMIC_ENTRIES)
@@ -418,10 +416,13 @@ class ABIPrinter(object):
return "\n".join(decls)
- def c_public_dispatches(self, prefix):
+ def c_public_dispatches(self, prefix, no_hidden):
"""Return the public dispatch functions."""
dispatches = []
for ent in self.entries:
+ if ent.hidden and no_hidden:
+ continue
+
if not self.need_entry_point(ent):
continue
@@ -434,7 +435,8 @@ class ABIPrinter(object):
if ent.ret:
ret = 'return '
stmt1 = self.indent
- stmt1 += 'const struct mapi_table *_tbl = u_current_get();'
+ stmt1 += 'const struct mapi_table *_tbl = %s();' % (
+ self.current_get)
stmt2 = self.indent
stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % (
ent.slot)
@@ -524,11 +526,13 @@ class ABIPrinter(object):
pre = self.indent + '(mapi_func) '
return pre + (',\n' + pre).join(entries)
- def c_asm_gcc(self, prefix):
+ def c_asm_gcc(self, prefix, no_hidden):
asm = []
- asm.append('__asm__(')
for ent in self.entries:
+ if ent.hidden and no_hidden:
+ continue
+
if not self.need_entry_point(ent):
continue
@@ -540,7 +544,7 @@ class ABIPrinter(object):
if ent.hidden:
asm.append('".hidden "%s"\\n"' % (name))
- if ent.alias:
+ if ent.alias and not (ent.alias.hidden and no_hidden):
asm.append('".globl "%s"\\n"' % (name))
asm.append('".set "%s", "%s"\\n"' % (name,
self._c_function(ent.alias, prefix, True, True)))
@@ -551,7 +555,6 @@ class ABIPrinter(object):
if ent.handcode:
asm.append('#endif')
asm.append('')
- asm.append(');')
return "\n".join(asm)
@@ -611,10 +614,10 @@ class ABIPrinter(object):
print '#undef MAPI_TMP_PUBLIC_STUBS'
print '#endif /* MAPI_TMP_PUBLIC_STUBS */'
- if self.lib_need_entries:
+ if self.lib_need_all_entries:
print
print '#ifdef MAPI_TMP_PUBLIC_ENTRIES'
- print self.c_public_dispatches(self.prefix_lib)
+ print self.c_public_dispatches(self.prefix_lib, False)
print
print 'static const mapi_func public_entries[] = {'
print self.c_public_initializer(self.prefix_lib)
@@ -624,10 +627,35 @@ class ABIPrinter(object):
print
print '#ifdef MAPI_TMP_STUB_ASM_GCC'
- print self.c_asm_gcc(self.prefix_lib)
+ print '__asm__('
+ print self.c_asm_gcc(self.prefix_lib, False)
+ print ');'
print '#undef MAPI_TMP_STUB_ASM_GCC'
print '#endif /* MAPI_TMP_STUB_ASM_GCC */'
+ if self.lib_need_non_hidden_entries:
+ all_hidden = True
+ for ent in self.entries:
+ if not ent.hidden:
+ all_hidden = False
+ break
+ if not all_hidden:
+ print
+ print '#ifdef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN'
+ print self.c_public_dispatches(self.prefix_lib, True)
+ print
+ print '/* does not need public_entries */'
+ print '#undef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN'
+ print '#endif /* MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN */'
+
+ print
+ print '#ifdef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN'
+ print '__asm__('
+ print self.c_asm_gcc(self.prefix_lib, True)
+ print ');'
+ 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
@@ -657,6 +685,12 @@ class GLAPIPrinter(ABIPrinter):
self.api_entry = 'APIENTRY'
self.api_attrs = ''
+ self.lib_need_table_size = False
+ self.lib_need_noop_array = False
+ self.lib_need_stubs = False
+ self.lib_need_all_entries = False
+ self.lib_need_non_hidden_entries = True
+
self.prefix_lib = 'GLAPI_PREFIX'
self.prefix_app = '_mesa_'
self.prefix_noop = 'noop'
@@ -1161,6 +1195,30 @@ typedef int GLclampx;
return header
+class SharedGLAPIPrinter(GLAPIPrinter):
+ """Shared GLAPI API Printer"""
+
+ def __init__(self, entries):
+ super(SharedGLAPIPrinter, self).__init__(entries, [])
+
+ self.lib_need_table_size = True
+ self.lib_need_noop_array = True
+ self.lib_need_stubs = True
+ self.lib_need_all_entries = True
+ self.lib_need_non_hidden_entries = False
+
+ self.prefix_lib = 'shared'
+ self.prefix_warn = 'gl'
+
+ 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"""
@@ -1179,7 +1237,7 @@ class VGAPIPrinter(ABIPrinter):
self.prefix_warn = 'vg'
def parse_args():
- printers = ['glapi', 'es1api', 'es2api', 'vgapi']
+ printers = ['vgapi', 'glapi', 'es1api', 'es2api', 'shared-glapi']
modes = ['lib', 'app']
parser = OptionParser(usage='usage: %prog [options] <filename>')
@@ -1201,7 +1259,8 @@ def main():
'vgapi': VGAPIPrinter,
'glapi': GLAPIPrinter,
'es1api': ES1APIPrinter,
- 'es2api': ES2APIPrinter
+ 'es2api': ES2APIPrinter,
+ 'shared-glapi': SharedGLAPIPrinter,
}
filename, options = parse_args()