added const to casts
[mesa.git] / src / mesa / glapi / glapitemp.py
index 422a86a7984bc16ba5e8ff72244c6f7304d29776..cb24b04e656f344c14a92c0ed6db912dcd177958 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# $Id: glapitemp.py,v 1.2 2001/12/14 03:17:00 brianp Exp $
+# $Id: glapitemp.py,v 1.5 2002/11/30 17:18:46 brianp Exp $
 
 # Mesa 3-D graphics library
 # Version:  4.1
@@ -34,7 +34,7 @@
 #    The apispec file must be in the current directory.
 
 
-
+import string
 import apiparser;
 
 
@@ -87,7 +87,7 @@ def PrintHead():
 #error RETURN_DISPATCH must be defined
 #endif
 
-extern void gl__unused413(void);  /* silence warning */
+GLAPI void GLAPIENTRY gl__unused413(void);  /* silence warning */
 """
 
 #enddef
@@ -120,23 +120,44 @@ def MakeParamList(nameList):
 #enddef
 
 
+def Contains(haystack, needle):
+       if string.find(haystack, needle) >= 0:
+               return 1
+       else:
+               return 0
+#enddef
+
+               
 def MakePrintfString(funcName, argTypeList, argNameList):
        result = '(F, "gl%s(' % (funcName)
 
        n = len(argTypeList)
        i = 1
        isPointer = {}
+       floatv = {}
        for argType in argTypeList:
                isPointer[i] = 0
+               floatv[i] = 0
                if argType == 'GLenum':
                        result = result + '0x%x'
                elif argType in ['GLfloat', 'GLdouble', 'GLclampf', 'GLclampd']:
                        result = result + '%f'
-               elif argType in ['GLbyte', 'GLubyte', 'GLshort', 'GLushort', 'GLint', 'GLuint', 'GLboolean']:
+               elif argType in ['GLbyte', 'GLubyte', 'GLshort', 'GLushort', 'GLint', 'GLuint', 'GLboolean', 'GLsizei']:
                        result = result + '%d'
                else:
                        result = result + '%p'
                        isPointer[i] = 1
+                       if argType[0:13] == 'const GLfloat' or argType[0:14] == 'const GLdouble':
+                               if Contains(funcName, '2fv') or Contains(funcName, '2dv'):
+                                       result = result + ' /* %g, %g */'
+                                       floatv[i] = 2
+                               elif Contains(funcName, '3fv') or Contains(funcName, '3dv'):
+                                       result = result + ' /* %g, %g, %g */'
+                                       floatv[i] = 3
+                               elif Contains(funcName, '4fv') or Contains(funcName, '4dv'):
+                                       result = result + ' /* %g, %g, %g, %g */'
+                                       floatv[i] = 4
+                       #endif
                if i < n:
                        result = result + ', '
                i = i + 1
@@ -150,8 +171,14 @@ def MakePrintfString(funcName, argTypeList, argNameList):
                result = result + ', '
        for pname in argNameList:
                if isPointer[i]:
-                       result = result + '(void *) '
+                       result = result + '(const void *) '
                result = result + pname
+               if floatv[i] == 2:
+                       result = result + ', ' + pname + '[0], ' + pname + '[1]'
+               elif floatv[i] == 3:
+                       result = result + ', ' + pname + '[0], ' + pname + '[1], ' + pname + '[2]'
+               elif floatv[i] == 4:
+                       result = result + ', ' + pname + '[0], ' + pname + '[1], ' + pname + '[2], ' + pname + '[3]'
                if i < n:
                        result = result + ', '
                i = i + 1