summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorPaul Berry <stereotype441@gmail.com>2012-10-10 15:19:21 -0700
committerPaul Berry <stereotype441@gmail.com>2012-10-16 12:03:56 -0700
commit137f8ef2258cda926074d1c4708b4925f7da71a8 (patch)
tree859942999fde111e63f8e64a1b34175768fe45a0 /src/mapi
parent4f6fc905c68fc1f7deab27d0b931f58e0558630e (diff)
downloadexternal_mesa3d-137f8ef2258cda926074d1c4708b4925f7da71a8.zip
external_mesa3d-137f8ef2258cda926074d1c4708b4925f7da71a8.tar.gz
external_mesa3d-137f8ef2258cda926074d1c4708b4925f7da71a8.tar.bz2
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>
Diffstat (limited to 'src/mapi')
-rw-r--r--src/mapi/mapi/mapi_abi.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py
index c2d9085..b1b08a2 100644
--- a/src/mapi/mapi/mapi_abi.py
+++ b/src/mapi/mapi/mapi_abi.py
@@ -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_