summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2006-10-04 20:45:59 +0000
committerIan Romanick <idr@us.ibm.com>2006-10-04 20:45:59 +0000
commiteaeaaf6205b304be290f2f869b3d224c318be749 (patch)
tree170e324479f9abc7e6f6aacc81b5203f64fa57b7
parent553b8334bbe6b0af9496722f05cb8fc2e4d43a01 (diff)
Divide categories into four groups as they are processed from the XML. Add
an iterator to iterate over the categories in order, starting with "core" versions, then ARB extensions, then numbered non-ARB extensions, and finally unnumbered extensions. Use the new iterator in a couple places to ensure that output that is grouped by catgory is generated in a consistent order. More changes to the scripts are coming. The generated files will be committed one time after all the changes are in. Too bad we're not using GIT, or this would be easy. :(
-rw-r--r--src/mesa/glapi/glX_proto_send.py87
-rw-r--r--src/mesa/glapi/gl_XML.py151
2 files changed, 109 insertions, 129 deletions
diff --git a/src/mesa/glapi/glX_proto_send.py b/src/mesa/glapi/glX_proto_send.py
index aaee2f605d..f8153e4c2e 100644
--- a/src/mesa/glapi/glX_proto_send.py
+++ b/src/mesa/glapi/glX_proto_send.py
@@ -884,87 +884,18 @@ __GLapi * __glXNewIndirectAPI( void )
return
- def printCategory(self, category_group, show_num):
- cat_keys = category_group.keys()
- cat_keys.sort()
- for cat_num in cat_keys:
- first = 1
- for offset in category_group[ cat_num ]:
- [cat_name, func_name] = category_group[ cat_num ][ offset ]
-
- if first:
- print ''
- if show_num:
- print ' /* %3u. %s */' % (cat_num, cat_name)
- else:
- print ' /* %s */' % (cat_name)
- print ''
- first = 0
-
- print ' glAPI->%s = __indirect_gl%s;' % (func_name, func_name)
-
-
def printBody(self, api):
- core_categories = {}
- arb_categories = {}
- other_categories = {}
- next_unnum = 1000
-
- for func in api.functionIterateGlx():
- [cat, num] = api.get_category_for_name( func.name )
-
- # There are three groups of "categories" that we
- # care about here. We want to separate the core GL
- # version categories from extensions. We also want to
- # separate the ARB extensions from the non-ARB
- # extensions.
- #
- # This is done by first trying to convert the category
- # name to a floating point number. All core GL
- # versions are of the form "N.M" where both N and M
- # are integers. If the cast to float fails, an
- # exception will be thrown. Once down that path,
- # we can look at the start of the extension string.
- # If it begins with "GL_ARB_", it's an ARB extension.
- #
- # Once the categories are separated, the are ordered
- # by number. The un-numbered non-ARB extensions
- # (e.g., GL_INGR_blend_func_separate) are assigned
- # arbitrary numbers starting at 1000.
- #
- # FIXME In order to maintain repeatability, the
- # FIXME unnumbered extensions should be put in their
- # FIXME own dictionary and ordered by name (since they
- # FIXME have no number).
-
- try:
- num = float(cat)
- if not core_categories.has_key( num ):
- core_categories[ num ] = {}
-
- core_categories[ num ][ func.offset ] = [cat, func.name]
-
- except Exception, e:
- if not num:
- num = next_unnum
- next_unnum += 1
- else:
- num = int(num)
-
- if cat.startswith( "GL_ARB_" ):
- if not arb_categories.has_key( num ):
- arb_categories[ num ] = {}
-
- arb_categories[ num ][ func.offset ] = [cat, func.name]
- else:
- if not other_categories.has_key( num ):
- other_categories[ num ] = {}
+ for [name, number] in api.categoryIterate():
+ if number != None:
+ preamble = '\n /* %3u. %s */\n\n' % (int(number), name)
+ else:
+ preamble = '\n /* %s */\n\n' % (name)
- other_categories[ num ][ func.offset ] = [cat, func.name]
+ for func in api.functionIterateByCategory(name):
+ if func.client_supported_for_indirect():
+ print '%s glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name)
+ preamble = ''
- self.printCategory( core_categories, 0 )
- self.printCategory( arb_categories, 1 )
- self.printCategory( other_categories, 1 )
return
diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py
index cde9cf7a43..3565d66f3b 100644
--- a/src/mesa/glapi/gl_XML.py
+++ b/src/mesa/glapi/gl_XML.py
@@ -44,58 +44,11 @@ def parse_GL_API( file_name, factory = None ):
# dispatch offsets to the functions that request that their offsets
# be assigned by the scripts. Typically this means all functions
# that are not part of the ABI.
- #
- # To bring some sanity to the generated offsets, we group all
- # functions into four groups. The groups have offsets assigned to
- # their functions in order. The groups are:
- #
- # 1. Core GL versions, sorted by version number.
- # 2. ARB extensions, sorted by extension number.
- # 3. Non-ARB extensions, sorted by extension number.
- # 4. Un-numbered, non-ARB extensions, sorted by extension name.
-
- lists = [{}, {}, {}, {}]
-
- for func in api.functionIterateAll():
- if func.assign_offset:
- [cat_name, cat_number] = api.category_dict[func.name]
-
- try:
- core_version = float(cat_name)
- except Exception,e:
- core_version = 0.0
-
- if core_version > 0.0:
- func_cat_type = 0
- key = cat_name
- elif cat_name.startswith( "GL_ARB_" ):
- func_cat_type = 1
- key = int(cat_number)
- else:
- if cat_number != None:
- func_cat_type = 2
- key = int(cat_number)
- else:
- func_cat_type = 3
- key = cat_name
-
- if not lists[func_cat_type].has_key(key):
- lists[func_cat_type][key] = {}
- lists[func_cat_type][key][func.name] = func
-
- for func_cat_type in range(0,4):
- keys = lists[func_cat_type].keys()
- keys.sort()
-
- for key in keys:
- names = lists[func_cat_type][key].keys()
- names.sort()
-
- for name in names:
- func = lists[func_cat_type][key][name]
- func.offset = api.next_offset;
- api.next_offset += 1
+ for func in api.functionIterateByCategory():
+ if func.assign_offset:
+ func.offset = api.next_offset;
+ api.next_offset += 1
doc.freeDoc()
@@ -316,6 +269,41 @@ def real_category_name(c):
return c
+def classify_category(name, number):
+ """Based on the category name and number, select a numerical class for it.
+
+ Categories are divided into four classes numbered 0 through 3. The
+ classes are:
+
+ 0. Core GL versions, sorted by version number.
+ 1. ARB extensions, sorted by extension number.
+ 2. Non-ARB extensions, sorted by extension number.
+ 3. Un-numbered extensions, sorted by extension name.
+ """
+
+ try:
+ core_version = float(name)
+ except Exception,e:
+ core_version = 0.0
+
+ if core_version > 0.0:
+ cat_type = 0
+ key = name
+ elif name.startswith("GL_ARB_") or name.startswith("GLX_ARB_") or name.startswith("WGL_ARB_"):
+ cat_type = 1
+ key = int(number)
+ else:
+ if number != None:
+ cat_type = 2
+ key = int(number)
+ else:
+ cat_type = 3
+ key = name
+
+
+ return [cat_type, key]
+
+
def create_parameter_string(parameters, include_names):
"""Create a parameter string from a list of gl_parameters."""
@@ -773,7 +761,9 @@ class gl_api:
self.functions_by_name = {}
self.enums_by_name = {}
self.types_by_name = {}
+
self.category_dict = {}
+ self.categories = [{}, {}, {}, {}]
self.factory = factory
@@ -811,6 +801,9 @@ class gl_api:
cat_name = cat.nsProp( "name", None )
cat_number = cat.nsProp( "number", None )
+ [cat_type, key] = classify_category(cat_name, cat_number)
+ self.categories[cat_type][key] = [cat_name, cat_number]
+
child = cat.children
while child:
if child.type == "element":
@@ -844,6 +837,43 @@ class gl_api:
return
+ def functionIterateByCategory(self, cat = None):
+ """Iterate over functions by category.
+
+ If cat is None, all known functions are iterated in category
+ order. See classify_category for details of the ordering.
+ Within a category, functions are sorted by name. If cat is
+ not None, then only functions in that category are iterated.
+ """
+ lists = [{}, {}, {}, {}]
+
+ for func in self.functionIterateAll():
+ [cat_name, cat_number] = self.category_dict[func.name]
+
+ if (cat == None) or (cat == cat_name):
+ [func_cat_type, key] = classify_category(cat_name, cat_number)
+
+ if not lists[func_cat_type].has_key(key):
+ lists[func_cat_type][key] = {}
+
+ lists[func_cat_type][key][func.name] = func
+
+
+ functions = []
+ for func_cat_type in range(0,4):
+ keys = lists[func_cat_type].keys()
+ keys.sort()
+
+ for key in keys:
+ names = lists[func_cat_type][key].keys()
+ names.sort()
+
+ for name in names:
+ functions.append(lists[func_cat_type][key][name])
+
+ return functions.__iter__()
+
+
def functionIterateByOffset(self):
max_offset = -1
for func in self.functions_by_name.itervalues():
@@ -880,6 +910,25 @@ class gl_api:
return list.__iter__()
+ def categoryIterate(self):
+ """Iterate over categories.
+
+ Iterate over all known categories in the order specified by
+ classify_category. Each iterated value is a tuple of the
+ name and number (which may be None) of the category.
+ """
+
+ list = []
+ for cat_type in range(0,4):
+ keys = self.categories[cat_type].keys()
+ keys.sort()
+
+ for key in keys:
+ list.append(self.categories[cat_type][key])
+
+ return list.__iter__()
+
+
def get_category_for_name( self, name ):
if self.category_dict.has_key(name):
return self.category_dict[name]