mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 18:08:40 +02:00
mapi_abi: Override 'hidden' and 'handcode' attributes using polymorphism.
Previously, the ES1, ES2, and shared GLAPI printers passed a list of function names to the base class constructor, which was used by the _override_for_api() function to loop over all the API functions and adjust their 'hidden' and 'handcode' attributes as appropriate for the API flavour being code-generated. This patch lifts the loop from _override_for_api() into its caller, and makes it into a polymorphic function, so that the derived classes can customize its behaviour directly. In a future patch, this will allow us to override the 'hidden' and 'handcode' attributes based on information from the XML rather than a list of functions. Tested-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
4f6fc905c6
commit
137f8ef225
1 changed files with 23 additions and 15 deletions
|
|
@ -688,8 +688,9 @@ class ABIPrinter(object):
|
|||
class GLAPIPrinter(ABIPrinter):
|
||||
"""OpenGL API Printer"""
|
||||
|
||||
def __init__(self, entries, api=None):
|
||||
self._override_for_api(entries, api)
|
||||
def __init__(self, entries):
|
||||
for ent in entries:
|
||||
self._override_for_api(ent)
|
||||
super(GLAPIPrinter, self).__init__(entries)
|
||||
|
||||
self.api_defines = ['GL_GLEXT_PROTOTYPES']
|
||||
|
|
@ -711,16 +712,11 @@ class GLAPIPrinter(ABIPrinter):
|
|||
|
||||
self.c_header = self._get_c_header()
|
||||
|
||||
def _override_for_api(self, entries, api):
|
||||
"""Override the entry attributes according to API."""
|
||||
# no override
|
||||
if api is None:
|
||||
return entries
|
||||
|
||||
for ent in entries:
|
||||
# override 'hidden' and 'handcode'
|
||||
ent.hidden = ent.name not in api
|
||||
ent.handcode = False
|
||||
def _override_for_api(self, ent):
|
||||
"""Override attributes of an entry if necessary for this
|
||||
printer."""
|
||||
# By default, no override is necessary.
|
||||
pass
|
||||
|
||||
def _get_c_header(self):
|
||||
header = """#ifndef _GLAPI_TMP_H_
|
||||
|
|
@ -743,10 +739,14 @@ class ES1APIPrinter(GLAPIPrinter):
|
|||
"""OpenGL ES 1.x API Printer"""
|
||||
|
||||
def __init__(self, entries):
|
||||
super(ES1APIPrinter, self).__init__(entries, es1_api)
|
||||
super(ES1APIPrinter, self).__init__(entries)
|
||||
self.prefix_lib = 'gl'
|
||||
self.prefix_warn = 'gl'
|
||||
|
||||
def _override_for_api(self, ent):
|
||||
ent.hidden = ent.name not in es1_api
|
||||
ent.handcode = False
|
||||
|
||||
def _get_c_header(self):
|
||||
header = """#ifndef _GLAPI_TMP_H_
|
||||
#define _GLAPI_TMP_H_
|
||||
|
|
@ -760,10 +760,14 @@ class ES2APIPrinter(GLAPIPrinter):
|
|||
"""OpenGL ES 2.x API Printer"""
|
||||
|
||||
def __init__(self, entries):
|
||||
super(ES2APIPrinter, self).__init__(entries, es2_api)
|
||||
super(ES2APIPrinter, self).__init__(entries)
|
||||
self.prefix_lib = 'gl'
|
||||
self.prefix_warn = 'gl'
|
||||
|
||||
def _override_for_api(self, ent):
|
||||
ent.hidden = ent.name not in es2_api
|
||||
ent.handcode = False
|
||||
|
||||
def _get_c_header(self):
|
||||
header = """#ifndef _GLAPI_TMP_H_
|
||||
#define _GLAPI_TMP_H_
|
||||
|
|
@ -777,7 +781,7 @@ class SharedGLAPIPrinter(GLAPIPrinter):
|
|||
"""Shared GLAPI API Printer"""
|
||||
|
||||
def __init__(self, entries):
|
||||
super(SharedGLAPIPrinter, self).__init__(entries, [])
|
||||
super(SharedGLAPIPrinter, self).__init__(entries)
|
||||
|
||||
self.lib_need_table_size = True
|
||||
self.lib_need_noop_array = True
|
||||
|
|
@ -788,6 +792,10 @@ class SharedGLAPIPrinter(GLAPIPrinter):
|
|||
self.prefix_lib = 'shared'
|
||||
self.prefix_warn = 'gl'
|
||||
|
||||
def _override_for_api(self, ent):
|
||||
ent.hidden = True
|
||||
ent.handcode = False
|
||||
|
||||
def _get_c_header(self):
|
||||
header = """#ifndef _GLAPI_TMP_H_
|
||||
#define _GLAPI_TMP_H_
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue