self.deprecated = None
self.has_no_error_variant = False
- # self.entry_point_api_map[name][api] is a decimal value
- # indicating the earliest version of the given API in which
- # each entry point exists. Every entry point is included in
- # the first level of the map; the second level of the map only
- # lists APIs which contain the entry point in at least one
- # version. For example,
- # self.entry_point_api_map['ClipPlanex'] == { 'es1':
- # Decimal('1.1') }.
- self.entry_point_api_map = {}
-
# self.api_map[api] is a decimal value indicating the earliest
# version of the given API in which ANY alias for the function
# exists. The map only lists APIs which contain the function
# in at least one version. For example, for the ClipPlanex
- # function, self.entry_point_api_map == { 'es1':
+ # function, self.api_map == { 'es1':
# Decimal('1.1') }.
self.api_map = {}
self.entry_points.append( name )
- self.entry_point_api_map[name] = {}
for api in ('es1', 'es2'):
version_str = element.get(api, 'none')
assert version_str is not None
if version_str != 'none':
version_decimal = Decimal(version_str)
- self.entry_point_api_map[name][api] = version_decimal
if api not in self.api_map or \
version_decimal < self.api_map[api]:
self.api_map[api] = version_decimal
else:
return "_dispatch_stub_%u" % (self.offset)
- def entry_points_for_api_version(self, api, version = None):
- """Return a list of the entry point names for this function
- which are supported in the given API (and optionally, version).
-
- Use the decimal.Decimal type to precisely express non-integer
- versions.
- """
- result = []
- for entry_point, api_to_ver in self.entry_point_api_map.items():
- if api not in api_to_ver:
- continue
- if version is not None and version < api_to_ver[api]:
- continue
- result.append(entry_point)
- return result
-
-
class gl_item_factory(object):
"""Factory to create objects derived from gl_item."""
typeexpr.create_initial_types()
return
- def filter_functions(self, entry_point_list):
- """Filter out entry points not in entry_point_list."""
- functions_by_name = {}
- for func in self.functions_by_name.values():
- entry_points = [ent for ent in func.entry_points if ent in entry_point_list]
- if entry_points:
- func.filter_entry_points(entry_points)
- functions_by_name[func.name] = func
-
- self.functions_by_name = functions_by_name
-
- def filter_functions_by_api(self, api, version = None):
- """Filter out entry points not in the given API (or
- optionally, not in the given version of the given API).
- """
- functions_by_name = {}
- for func in self.functions_by_name.values():
- entry_points = func.entry_points_for_api_version(api, version)
- if entry_points:
- func.filter_entry_points(entry_points)
- functions_by_name[func.name] = func
-
- self.functions_by_name = functions_by_name
-
-
def parse_file(self, file_name):
doc = ET.parse( file_name )
self.process_element(file_name, doc)
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_ */"""
-
- return header
-
class SharedGLAPIPrinter(GLAPIPrinter):
"""Shared GLAPI API Printer"""
def main():
printers = {
'glapi': GLAPIPrinter,
- 'es1api': ES1APIPrinter,
- 'es2api': ES2APIPrinter,
'shared-glapi': SharedGLAPIPrinter,
}