X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmapi%2Fmapi%2Fmapi_abi.py;h=cb9fc0ef84185efd819c2c725aa728288b2b9267;hb=45ba7afbd15b28ffd61548ee46334ff4527a7cde;hp=5c212420a80190e56801ce8f1d3ce14b9920fb30;hpb=cd1cf788280a1eb10d54e1a2b8b069ed7b89c724;p=mesa.git diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py index 5c212420a80..cb9fc0ef841 100644 --- a/src/mapi/mapi/mapi_abi.py +++ b/src/mapi/mapi/mapi_abi.py @@ -126,6 +126,61 @@ class ABIEntry(object): return res +def abi_parse_xml(xml): + """Parse a GLAPI XML file for ABI entries.""" + import os + GLAPI = "./%s/../glapi/gen" % (os.path.dirname(sys.argv[0])) + sys.path.append(GLAPI) + import gl_XML, glX_XML + + api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) + + entry_dict = {} + for func in api.functionIterateByOffset(): + # make sure func.name appear first + entry_points = func.entry_points[:] + entry_points.remove(func.name) + entry_points.insert(0, func.name) + + for name in entry_points: + attrs = { + 'slot': func.offset, + 'hidden': not func.is_static_entry_point(name), + 'alias': None if name == func.name else func.name, + 'handcode': bool(func.has_different_protocol(name)), + } + + # post-process attrs + 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) + attrs['alias'] = alias + if attrs['handcode']: + attrs['handcode'] = func.static_glx_name(name) + else: + attrs['handcode'] = None + + if entry_dict.has_key(name): + raise Exception('%s is duplicated' % (name)) + + cols = [] + cols.append(func.return_type) + cols.append(name) + params = func.get_parameter_string(name) + cols.extend([p.strip() for p in params.split(',')]) + + ent = ABIEntry(cols, attrs) + entry_dict[ent.name] = ent + + entries = entry_dict.values() + entries.sort() + + return entries + def abi_parse_line(line): cols = [col.strip() for col in line.split(',')] @@ -194,9 +249,16 @@ def abi_parse(filename): entries = entry_dict.values() entries.sort() - # sanity check + return entries + +def abi_sanity_check(entries): + if not entries: + return + + all_names = [] + last_slot = entries[-1].slot i = 0 - for slot in xrange(next_slot): + for slot in xrange(last_slot + 1): if entries[i].slot != slot: raise Exception('entries are not ordered by slots') if entries[i].alias: @@ -210,12 +272,16 @@ def abi_parse(filename): elif ent.handcode != handcode: raise Exception('two aliases with handcode %s != %s', ent.handcode, handcode) + + if ent.name in all_names: + raise Exception('%s is duplicated' % (ent.name)) + if ent.alias and ent.alias.name not in all_names: + raise Exception('failed to alias %s' % (ent.alias.name)) + all_names.append(ent.name) i += 1 if i < len(entries): raise Exception('there are %d invalid entries' % (len(entries) - 1)) - return entries - class ABIPrinter(object): """MAPI Printer""" @@ -229,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"'] @@ -236,10 +303,13 @@ class ABIPrinter(object): self.api_entry = 'KHRONOS_APIENTRY' self.api_attrs = 'KHRONOS_APIATTRIBUTES' + self.c_header = '' + 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. */' @@ -269,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) @@ -302,8 +368,11 @@ class ABIPrinter(object): def _c_function(self, ent, prefix, mangle=False, stringify=False): """Return the function name of an entry.""" - formats = { True: '"%s%s"', False: '%s%s' } - fmt = formats[stringify] + formats = { + True: { True: '%s_STR(%s)', False: '%s(%s)' }, + False: { True: '"%s%s"', False: '%s%s' }, + } + fmt = formats[prefix.isupper()][stringify] name = ent.name if mangle and ent.hidden: name = '_dispatch_stub_' + str(ent.slot) @@ -313,7 +382,8 @@ class ABIPrinter(object): """Return the function name used for calling.""" if ent.handcode: # _c_function does not handle this case - fmt = '%s%s' + formats = { True: '%s(%s)', False: '%s%s' } + fmt = formats[prefix.isupper()] name = fmt % (prefix, ent.handcode) elif self.need_entry_point(ent): name = self._c_function(ent, prefix, True) @@ -346,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 @@ -362,12 +435,13 @@ 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];' % ( + stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % ( ent.slot) stmt3 = self.indent - stmt3 += '%s((%s) func)(%s);' % (ret, cast, ent.c_args()) + stmt3 += '%s((%s) _func)(%s);' % (ret, cast, ent.c_args()) disp = '%s\n{\n%s\n%s\n%s\n}' % (proto, stmt1, stmt2, stmt3) @@ -452,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 @@ -468,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))) @@ -479,12 +555,16 @@ class ABIPrinter(object): if ent.handcode: asm.append('#endif') asm.append('') - asm.append(');') return "\n".join(asm) def output_for_lib(self): print self.c_notice() + + if self.c_header: + print + print self.c_header + print print '#ifdef MAPI_TMP_DEFINES' print self.c_public_includes() @@ -505,7 +585,7 @@ class ABIPrinter(object): print '#ifdef MAPI_TMP_NOOP_ARRAY' print '#ifdef DEBUG' print - print self.c_noop_functions(self.prefix_noop, self.prefix_lib) + print self.c_noop_functions(self.prefix_noop, self.prefix_warn) print print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop) print self.c_noop_initializer(self.prefix_noop, False) @@ -534,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) @@ -547,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 @@ -570,8 +675,9 @@ class ABIPrinter(object): class GLAPIPrinter(ABIPrinter): """OpenGL API Printer""" - def __init__(self, entries): - super(GLAPIPrinter, self).__init__(entries) + def __init__(self, entries, api=None): + api_entries = self._get_api_entries(entries, api) + super(GLAPIPrinter, self).__init__(api_entries) self.api_defines = ['GL_GLEXT_PROTOTYPES'] self.api_headers = ['"GL/gl.h"', '"GL/glext.h"'] @@ -579,33 +685,539 @@ class GLAPIPrinter(ABIPrinter): self.api_entry = 'APIENTRY' self.api_attrs = '' - self.prefix_lib = 'gl' + 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' + self.prefix_warn = self.prefix_lib - def output_for_app(self): - # not used - pass + self.c_header = self._get_c_header() + + def _get_api_entries(self, entries, api): + """Override the entry attributes according to API.""" + import copy + + # no override + if api is None: + return entries + + api_entries = {} + for ent in entries: + ent = copy.copy(ent) + + # override 'hidden' and 'handcode' + ent.hidden = ent.name not in api + ent.handcode = False + if ent.alias: + ent.alias = api_entries[ent.alias.name] + + api_entries[ent.name] = ent + + # sanity check + missed = [name for name in api if name not in api_entries] + if missed: + raise Exception('%s is missing' % str(missed)) + + entries = api_entries.values() + entries.sort() + + return entries + + 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 GLfixed; +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) + es1_api = [ + # OpenGL ES 1.1 + 'ActiveTexture', + 'AlphaFunc', + 'AlphaFuncx', + 'BindBuffer', + 'BindTexture', + 'BlendFunc', + 'BufferData', + 'BufferSubData', + 'Clear', + 'ClearColor', + 'ClearColorx', + 'ClearDepthf', + 'ClearDepthx', + 'ClearStencil', + 'ClientActiveTexture', + 'ClipPlanef', + 'ClipPlanex', + 'Color4f', + 'Color4ub', + 'Color4x', + 'ColorMask', + 'ColorPointer', + 'CompressedTexImage2D', + 'CompressedTexSubImage2D', + 'CopyTexImage2D', + 'CopyTexSubImage2D', + 'CullFace', + 'DeleteBuffers', + 'DeleteTextures', + 'DepthFunc', + 'DepthMask', + 'DepthRangef', + 'DepthRangex', + 'Disable', + 'DisableClientState', + 'DrawArrays', + 'DrawElements', + 'Enable', + 'EnableClientState', + 'Finish', + 'Flush', + 'Fogf', + 'Fogfv', + 'Fogx', + 'Fogxv', + 'FrontFace', + 'Frustumf', + 'Frustumx', + 'GenBuffers', + 'GenTextures', + 'GetBooleanv', + 'GetBufferParameteriv', + 'GetClipPlanef', + 'GetClipPlanex', + 'GetError', + 'GetFixedv', + 'GetFloatv', + 'GetIntegerv', + 'GetLightfv', + 'GetLightxv', + 'GetMaterialfv', + 'GetMaterialxv', + 'GetPointerv', + 'GetString', + 'GetTexEnvfv', + 'GetTexEnviv', + 'GetTexEnvxv', + 'GetTexParameterfv', + 'GetTexParameteriv', + 'GetTexParameterxv', + 'Hint', + 'IsBuffer', + 'IsEnabled', + 'IsTexture', + 'Lightf', + 'Lightfv', + 'LightModelf', + 'LightModelfv', + 'LightModelx', + 'LightModelxv', + 'Lightx', + 'Lightxv', + 'LineWidth', + 'LineWidthx', + 'LoadIdentity', + 'LoadMatrixf', + 'LoadMatrixx', + 'LogicOp', + 'Materialf', + 'Materialfv', + 'Materialx', + 'Materialxv', + 'MatrixMode', + 'MultiTexCoord4f', + 'MultiTexCoord4x', + 'MultMatrixf', + 'MultMatrixx', + 'Normal3f', + 'Normal3x', + 'NormalPointer', + 'Orthof', + 'Orthox', + 'PixelStorei', + 'PointParameterf', + 'PointParameterfv', + 'PointParameterx', + 'PointParameterxv', + 'PointSize', + 'PointSizex', + 'PolygonOffset', + 'PolygonOffsetx', + 'PopMatrix', + 'PushMatrix', + 'ReadPixels', + 'Rotatef', + 'Rotatex', + 'SampleCoverage', + 'SampleCoveragex', + 'Scalef', + 'Scalex', + 'Scissor', + 'ShadeModel', + 'StencilFunc', + 'StencilMask', + 'StencilOp', + 'TexCoordPointer', + 'TexEnvf', + 'TexEnvfv', + 'TexEnvi', + 'TexEnviv', + 'TexEnvx', + 'TexEnvxv', + 'TexImage2D', + 'TexParameterf', + 'TexParameterfv', + 'TexParameteri', + 'TexParameteriv', + 'TexParameterx', + 'TexParameterxv', + 'TexSubImage2D', + 'Translatef', + 'Translatex', + 'VertexPointer', + 'Viewport', + # GL_OES_EGL_image + 'EGLImageTargetTexture2DOES', + 'EGLImageTargetRenderbufferStorageOES', + # GL_OES_mapbuffer + 'GetBufferPointervOES', + 'MapBufferOES', + 'UnmapBufferOES', + # GL_EXT_multi_draw_arrays + 'MultiDrawArraysEXT', + 'MultiDrawElementsEXT', + # GL_OES_blend_equation_separate + 'BlendEquationSeparateOES', + # GL_OES_blend_func_separate + 'BlendFuncSeparateOES', + # GL_OES_blend_subtract + 'BlendEquationOES', + # GL_OES_draw_texture + 'DrawTexiOES', + 'DrawTexivOES', + 'DrawTexfOES', + 'DrawTexfvOES', + 'DrawTexsOES', + 'DrawTexsvOES', + 'DrawTexxOES', + 'DrawTexxvOES', + # GL_OES_fixed_point + 'AlphaFuncxOES', + 'ClearColorxOES', + 'ClearDepthxOES', + 'Color4xOES', + 'DepthRangexOES', + 'FogxOES', + 'FogxvOES', + 'FrustumxOES', + 'LightModelxOES', + 'LightModelxvOES', + 'LightxOES', + 'LightxvOES', + 'LineWidthxOES', + 'LoadMatrixxOES', + 'MaterialxOES', + 'MaterialxvOES', + 'MultiTexCoord4xOES', + 'MultMatrixxOES', + 'Normal3xOES', + 'OrthoxOES', + 'PointSizexOES', + 'PolygonOffsetxOES', + 'RotatexOES', + 'SampleCoveragexOES', + 'ScalexOES', + 'TexEnvxOES', + 'TexEnvxvOES', + 'TexParameterxOES', + 'TranslatexOES', + 'ClipPlanexOES', + 'GetClipPlanexOES', + 'GetFixedvOES', + 'GetLightxvOES', + 'GetMaterialxvOES', + 'GetTexEnvxvOES', + 'GetTexParameterxvOES', + 'PointParameterxOES', + 'PointParameterxvOES', + 'TexParameterxvOES', + # GL_OES_framebuffer_object + 'BindFramebufferOES', + 'BindRenderbufferOES', + 'CheckFramebufferStatusOES', + 'DeleteFramebuffersOES', + 'DeleteRenderbuffersOES', + 'FramebufferRenderbufferOES', + 'FramebufferTexture2DOES', + 'GenerateMipmapOES', + 'GenFramebuffersOES', + 'GenRenderbuffersOES', + 'GetFramebufferAttachmentParameterivOES', + 'GetRenderbufferParameterivOES', + 'IsFramebufferOES', + 'IsRenderbufferOES', + 'RenderbufferStorageOES', + # GL_OES_point_size_array + 'PointSizePointerOES', + # GL_OES_query_matrix + 'QueryMatrixxOES', + # GL_OES_single_precision + 'ClearDepthfOES', + 'DepthRangefOES', + 'FrustumfOES', + 'OrthofOES', + 'ClipPlanefOES', + 'GetClipPlanefOES', + # GL_OES_texture_cube_map + 'GetTexGenfvOES', + 'GetTexGenivOES', + 'GetTexGenxvOES', + 'TexGenfOES', + 'TexGenfvOES', + 'TexGeniOES', + 'TexGenivOES', + 'TexGenxOES', + 'TexGenxvOES', + ] + + super(ES1APIPrinter, self).__init__(entries, es1_api) + self.prefix_lib = 'gl' + 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_ */""" - self.api_headers = ['"GLES/gl.h"', '"GLES/glext.h"'] - self.api_call = 'GL_API' - self.api_entry = 'GL_APIENTRY' + return header class ES2APIPrinter(GLAPIPrinter): """OpenGL ES 2.x API Printer""" def __init__(self, entries): - super(ES2APIPrinter, self).__init__(entries) + es2_api = [ + # OpenGL ES 2.0 + "ActiveTexture", + "AttachShader", + "BindAttribLocation", + "BindBuffer", + "BindFramebuffer", + "BindRenderbuffer", + "BindTexture", + "BlendColor", + "BlendEquation", + "BlendEquationSeparate", + "BlendFunc", + "BlendFuncSeparate", + "BufferData", + "BufferSubData", + "CheckFramebufferStatus", + "Clear", + "ClearColor", + "ClearDepthf", + "ClearStencil", + "ColorMask", + "CompileShader", + "CompressedTexImage2D", + "CompressedTexSubImage2D", + "CopyTexImage2D", + "CopyTexSubImage2D", + "CreateProgram", + "CreateShader", + "CullFace", + "DeleteBuffers", + "DeleteFramebuffers", + "DeleteProgram", + "DeleteRenderbuffers", + "DeleteShader", + "DeleteTextures", + "DepthFunc", + "DepthMask", + "DepthRangef", + "DetachShader", + "Disable", + "DisableVertexAttribArray", + "DrawArrays", + "DrawElements", + "Enable", + "EnableVertexAttribArray", + "Finish", + "Flush", + "FramebufferRenderbuffer", + "FramebufferTexture2D", + "FrontFace", + "GenBuffers", + "GenerateMipmap", + "GenFramebuffers", + "GenRenderbuffers", + "GenTextures", + "GetActiveAttrib", + "GetActiveUniform", + "GetAttachedShaders", + "GetAttribLocation", + "GetBooleanv", + "GetBufferParameteriv", + "GetError", + "GetFloatv", + "GetFramebufferAttachmentParameteriv", + "GetIntegerv", + "GetProgramInfoLog", + "GetProgramiv", + "GetRenderbufferParameteriv", + "GetShaderInfoLog", + "GetShaderiv", + "GetShaderPrecisionFormat", + "GetShaderSource", + "GetString", + "GetTexParameterfv", + "GetTexParameteriv", + "GetUniformfv", + "GetUniformiv", + "GetUniformLocation", + "GetVertexAttribfv", + "GetVertexAttribiv", + "GetVertexAttribPointerv", + "Hint", + "IsBuffer", + "IsEnabled", + "IsFramebuffer", + "IsProgram", + "IsRenderbuffer", + "IsShader", + "IsTexture", + "LineWidth", + "LinkProgram", + "PixelStorei", + "PolygonOffset", + "ReadPixels", + "ReleaseShaderCompiler", + "RenderbufferStorage", + "SampleCoverage", + "Scissor", + "ShaderBinary", + "ShaderSource", + "StencilFunc", + "StencilFuncSeparate", + "StencilMask", + "StencilMaskSeparate", + "StencilOp", + "StencilOpSeparate", + "TexImage2D", + "TexParameterf", + "TexParameterfv", + "TexParameteri", + "TexParameteriv", + "TexSubImage2D", + "Uniform1f", + "Uniform1fv", + "Uniform1i", + "Uniform1iv", + "Uniform2f", + "Uniform2fv", + "Uniform2i", + "Uniform2iv", + "Uniform3f", + "Uniform3fv", + "Uniform3i", + "Uniform3iv", + "Uniform4f", + "Uniform4fv", + "Uniform4i", + "Uniform4iv", + "UniformMatrix2fv", + "UniformMatrix3fv", + "UniformMatrix4fv", + "UseProgram", + "ValidateProgram", + "VertexAttrib1f", + "VertexAttrib1fv", + "VertexAttrib2f", + "VertexAttrib2fv", + "VertexAttrib3f", + "VertexAttrib3fv", + "VertexAttrib4f", + "VertexAttrib4fv", + "VertexAttribPointer", + "Viewport", + # GL_OES_EGL_image + 'EGLImageTargetTexture2DOES', + 'EGLImageTargetRenderbufferStorageOES', + # GL_OES_mapbuffer + 'GetBufferPointervOES', + 'MapBufferOES', + 'UnmapBufferOES', + # GL_EXT_multi_draw_arrays + 'MultiDrawArraysEXT', + 'MultiDrawElementsEXT', + # GL_OES_texture_3D + 'CompressedTexImage3DOES', + 'CompressedTexSubImage3DOES', + 'CopyTexSubImage3DOES', + 'FramebufferTexture3DOES', + 'TexImage3DOES', + 'TexSubImage3DOES', + # GL_OES_get_program_binary + 'GetProgramBinaryOES', + 'ProgramBinaryOES', + ] + + super(ES2APIPrinter, self).__init__(entries, es2_api) + self.prefix_lib = 'gl' + 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 SharedGLAPIPrinter(GLAPIPrinter): + """Shared GLAPI API Printer""" + + def __init__(self, entries): + super(SharedGLAPIPrinter, self).__init__(entries, []) - self.api_headers = ['"GLES2/gl2.h"', '"GLES2/gl2ext.h"'] - self.api_call = 'GL_APICALL' - self.api_entry = 'GL_APIENTRY' + 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""" @@ -622,9 +1234,10 @@ class VGAPIPrinter(ABIPrinter): self.prefix_lib = 'vg' self.prefix_app = 'vega' self.prefix_noop = 'noop' + 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] ') @@ -646,12 +1259,18 @@ def main(): 'vgapi': VGAPIPrinter, 'glapi': GLAPIPrinter, 'es1api': ES1APIPrinter, - 'es2api': ES2APIPrinter + 'es2api': ES2APIPrinter, + 'shared-glapi': SharedGLAPIPrinter, } filename, options = parse_args() - entries = abi_parse(filename) + if filename.endswith('.xml'): + entries = abi_parse_xml(filename) + else: + entries = abi_parse(filename) + abi_sanity_check(entries) + printer = printers[options.printer](entries) if options.mode == 'lib': printer.output_for_lib()