aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/glapi/gl_enums.py
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2005-06-21 23:42:43 +0000
committerIan Romanick <[email protected]>2005-06-21 23:42:43 +0000
commit66a5548fbbf4c04a74b0bbc451718a8fc95502d9 (patch)
treef0e5a5964bca25e1e48c62bdb09e7f4c2fb88ce1 /src/mesa/glapi/gl_enums.py
parentf292e13a20a262411360bf4af5337595976cebc7 (diff)
Mammoth update to the Python code generator scripts that live in
src/mesa/glapi. Basically, the scripts that did simple things (like gl_offsets.py) were simple, and the scripts that did more complicated things (like glX_proto_send.py) were getting progressively more and more out of control. So, I re-write the foundation classes on which everything is based. One problem with the existing code is that the division between the GL API database representation and the way the output code is generated was either blury or nonexistant. The new code somewhat follows the Model-View-Controller pattern, minus the Controller. There is a distinct set of classes that model the API data, and there is a distinct set of classes that generate code from that data. One big change is in the class that represents GL functions (was glFunction, is now gl_function). There used to be an instance of this calls for each function and for each alias to that function. For example, there was an instance for PointParameterivSGIS, PointParameterivEXT, PointParameterivARB, and PointParameteriv. In the new code, there is one instance. Each instance has a list of entrypoint names for the function. In the next revision, this will allow a couple useful things. The script will be able to verify that the parameters, return type, and GLX protocol for a function and all it's aliases match. It will also allow aliases to be represented in the XML more compactly. Instead of repeating all the information, an alias can be listed as: <function name="PointParameterivARB" alias="PointParameterivEXT"/> Because the data representation was changed, the order that the alias functions are processed by the scripts also changed. This accounts for at least 2,700 of the ~3,600 lines of diffs in the generated code. Most of the remaining ~900 lines of diffs are the result of bugs *fixed* by the new scripts. The old scripts also generated code with some bugs in it. These bugs were discovered while the new code was being written. These changes were discussed on the mesa3d-dev mailing list back at the end of May: http://marc.theaimsgroup.com/?t=111714569000004&r=1&w=2 Xorg bug: 3197, 3208
Diffstat (limited to 'src/mesa/glapi/gl_enums.py')
-rw-r--r--src/mesa/glapi/gl_enums.py62
1 files changed, 19 insertions, 43 deletions
diff --git a/src/mesa/glapi/gl_enums.py b/src/mesa/glapi/gl_enums.py
index 8520d9e33ea..33d621dcd6f 100644
--- a/src/mesa/glapi/gl_enums.py
+++ b/src/mesa/glapi/gl_enums.py
@@ -30,10 +30,10 @@ import license
import gl_XML
import sys, getopt
-class PrintGlEnums(gl_XML.FilterGLAPISpecBase):
+class PrintGlEnums(gl_XML.gl_print_base):
def __init__(self):
- gl_XML.FilterGLAPISpecBase.__init__(self)
+ gl_XML.gl_print_base.__init__(self)
self.name = "gl_enums.py (from Mesa)"
self.license = license.bsd_license_template % ( \
@@ -53,7 +53,7 @@ class PrintGlEnums(gl_XML.FilterGLAPISpecBase):
print ''
return
- def printBody(self):
+ def print_code(self):
print """
#define Elements(x) sizeof(x)/sizeof(*x)
@@ -124,7 +124,10 @@ int _mesa_lookup_enum_by_name( const char *symbol )
"""
return
- def printFunctions(self):
+
+ def printBody(self, api):
+ self.process_enums( api )
+
keys = self.enum_table.keys()
keys.sort()
@@ -175,50 +178,21 @@ int _mesa_lookup_enum_by_name( const char *symbol )
print '};'
- self.printBody();
+ self.print_code()
return
- def append(self, object_type, obj):
- if object_type == "enum":
+ def process_enums(self, api):
+ self.enum_table = {}
+
+ for obj in api.enumIterateByName():
if obj.value not in self.enum_table:
self.enum_table[ obj.value ] = []
- # Prevent duplicate names in the enum table.
-
- found_it = 0
- for [n, junk] in self.enum_table[ obj.value ]:
- if n == obj.name:
- found_it = 1
- break
-
- if not found_it:
-
- # Calculate a "priority" for this enum name.
- # When we lookup an enum by number, there may
- # be many possible names, but only one can be
- # returned. The priority is used by this
- # script to select which name is the "best".
- #
- # Highest precedence is given to "core" name.
- # ARB extension names have the next highest,
- # followed by EXT extension names. Vendor
- # extension names are the lowest.
-
- if obj.category.startswith( "GL_VERSION_" ):
- priority = 0
- elif obj.category.startswith( "GL_ARB_" ):
- priority = 1
- elif obj.category.startswith( "GL_EXT_" ):
- priority = 2
- else:
- priority = 3
-
- self.enum_table[ obj.value ].append( [obj.name, priority] )
-
- else:
- gl_XML.FilterGLAPISpecBase.append(self, object_type, obj)
+ name = "GL_" + obj.name
+ priority = obj.priority()
+ self.enum_table[ obj.value ].append( [name, priority] )
def show_usage():
@@ -237,5 +211,7 @@ if __name__ == '__main__':
if arg == "-f":
file_name = val
- dh = PrintGlEnums()
- gl_XML.parse_GL_API( dh, file_name )
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer = PrintGlEnums()
+ printer.Print( api )