summaryrefslogtreecommitdiff
path: root/src/mapi/glapi
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2011-08-07 23:19:51 +0900
committerChia-I Wu <olv@lunarg.com>2011-08-13 13:54:54 +0800
commitb8202b3d44b18a3db281c64d1ca01e851ae6deb1 (patch)
tree44c8ad48089c238b7122684a3dcfad58b99d2395 /src/mapi/glapi
parent281947b3511f606df365e0985631f31d237e63f1 (diff)
glapi: add methods to filter functions
add gl_api::filter_functions and gl_function::filter_entry_points to filter out unwanted functions and entry points. Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/mapi/glapi')
-rw-r--r--src/mapi/glapi/gen/gl_XML.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py
index 4d414e8b0f..4dc2e8fa7f 100644
--- a/src/mapi/glapi/gen/gl_XML.py
+++ b/src/mapi/glapi/gen/gl_XML.py
@@ -618,7 +618,7 @@ class gl_function( gl_item ):
# for each entry-point. Otherwise, they may generate code
# that won't compile.
- self.parameter_strings = {}
+ self.entry_point_parameters = {}
self.process_element( element )
@@ -703,12 +703,34 @@ class gl_function( gl_item ):
if element.children:
self.initialized = 1
- self.parameter_strings[name] = create_parameter_string(parameters, 1)
+ self.entry_point_parameters[name] = parameters
else:
- self.parameter_strings[name] = None
+ self.entry_point_parameters[name] = []
return
+ def filter_entry_points(self, entry_point_list):
+ """Filter out entry points not in entry_point_list."""
+ if not self.initialized:
+ raise RuntimeError('%s is not initialized yet' % self.name)
+
+ entry_points = []
+ for ent in self.entry_points:
+ if ent not in entry_point_list:
+ if ent in self.static_entry_points:
+ self.static_entry_points.remove(ent)
+ self.entry_point_parameters.pop(ent)
+ else:
+ entry_points.append(ent)
+
+ if not entry_points:
+ raise RuntimeError('%s has no entry point after filtering' % self.name)
+
+ self.entry_points = entry_points
+ if self.name not in entry_points:
+ # use the first remaining entry point
+ self.name = entry_points[0]
+ self.parameters = self.entry_point_parameters[entry_points[0]]
def get_images(self):
"""Return potentially empty list of input images."""
@@ -721,11 +743,11 @@ class gl_function( gl_item ):
def get_parameter_string(self, entrypoint = None):
if entrypoint:
- s = self.parameter_strings[ entrypoint ]
- if s:
- return s
+ params = self.entry_point_parameters[ entrypoint ]
+ else:
+ params = self.parameters
- return create_parameter_string( self.parameters, 1 )
+ return create_parameter_string( params, 1 )
def get_called_parameter_string(self):
p_string = ""
@@ -791,6 +813,16 @@ class gl_api:
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.itervalues():
+ 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 process_element(self, doc):
element = doc.children