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"']
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. */'
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)
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
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)
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
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)))
if ent.handcode:
asm.append('#endif')
asm.append('')
- asm.append(');')
return "\n".join(asm)
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)
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
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'
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"""
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>')
'vgapi': VGAPIPrinter,
'glapi': GLAPIPrinter,
'es1api': ES1APIPrinter,
- 'es2api': ES2APIPrinter
+ 'es2api': ES2APIPrinter,
+ 'shared-glapi': SharedGLAPIPrinter,
}
filename, options = parse_args()