Mesa (gallium-0.1): mesa: fix cast/conversion for optional code

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 6 21:23:37 UTC 2009


Module: Mesa
Branch: gallium-0.1
Commit: c3be5e4a050561e25854f38aa221bbf657848762
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3be5e4a050561e25854f38aa221bbf657848762

Author: Brian <brian.paul at tungstengraphics.com>
Date:   Thu Sep 25 19:57:34 2008 -0600

mesa: fix cast/conversion for optional code

(cherry picked from commit 1e3a44fab068f00378613456036716d0c3772969)

---

 src/mesa/main/get.c      |    2 +-
 src/mesa/main/get_gen.py |    8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 19cc480..80dcea9 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1092,7 +1092,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
          ASSERT(n <= 100);
          for (i = 0; i < n; i++)
-            params[i] = ENUM_TO_INT(formats[i]);
+            params[i] = ENUM_TO_BOOLEAN(formats[i]);
          }
          break;
       case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT:
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index 4c841d0..f99e0a0 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -50,7 +50,8 @@ TypeStrings = {
 #  - the GL state name, such as GL_CURRENT_COLOR
 #  - the state datatype, one of GLint, GLfloat, GLboolean or GLenum
 #  - list of code fragments to get the state, such as ["ctx->Foo.Bar"]
-#  - optional extra code or empty string
+#  - optional extra code or empty string.  If present, "CONVERSION" will be
+#    replaced by ENUM_TO_FLOAT, INT_TO_FLOAT, etc.
 #  - optional extensions to check, or None
 #
 StateVars = [
@@ -532,7 +533,7 @@ StateVars = [
          GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
          ASSERT(n <= 100);
          for (i = 0; i < n; i++)
-            params[i] = ENUM_TO_INT(formats[i]);""",
+            params[i] = CONVERSION(formats[i]);""",
 	  ["ARB_texture_compression"] ),
 
 	# GL_EXT_compiled_vertex_array
@@ -1078,10 +1079,11 @@ def EmitGetFunction(stateVars, returnType):
 				assert len(extensions) == 4
 				print ('         CHECK_EXT4(%s, %s, %s, %s, "%s");' %
 					   (extensions[0], extensions[1], extensions[2], extensions[3], function))
+		conversion = ConversionFunc(varType, returnType)
 		if optionalCode:
+			optionalCode = string.replace(optionalCode, "CONVERSION", conversion);	
 			print "         {"
 			print "         " + optionalCode
-		conversion = ConversionFunc(varType, returnType)
 		n = len(state)
 		for i in range(n):
 			if conversion:




More information about the mesa-commit mailing list