2 # generate logging code
3 # this requires an analysis of the parameters for verbose and do actual call
6 from read import read_gl
8 def do_logfunc(f_in, f_out):
10 (gl, wgl, glX) = read_gl(f_in)
14 # process ret type to strip trailing spaces
15 t[0] = string.strip(t[0])
16 f_out.write('static %s APIENTRY log%s(%s) {\n' % ( t[0], t[2], t[3] ))
18 base_params = string.split(t[3], ',')
19 #f_out.write('// %s\n' % repr(base_params))
20 # init format string and parameter list
22 format = t[1][1:] + t[2]
27 regex = re.compile('([a-zA-Z0-9]*)$')
28 name = regex.search(i).group(1)
29 type = string.strip(i[0:len(i)-len(name)])
30 # catch type with no name
34 #f_out.write('// type: "%s" name: "%s"\n' % (type, name))
38 if (type == 'GLenum'):
40 params.append( 'EnumString(' + name + ')' )
41 elif (type == 'GLfloat' or type == 'GLclampf' or type == 'GLdouble'):
44 elif (type == 'GLint' or type == 'GLuint' or type == 'GLsizei' or type == 'GLbyte' or type == 'GLshort'
45 or type == 'GLubyte' or type == 'GLushort'):
48 elif (type == 'GLboolean'):
50 params.append( name + ' ? "Y" : "N"' )
51 elif (type == 'void'):
54 f_out.write('// unknown type: "%s" name: "%s"\n' % (type, name))
55 format += ' \'' + type + ' ' + name + '\''
56 f_out.write('\tfprintf( tr.logFile, "' + format + '\\n"')
58 f_out.write(', ' + par)
61 f_out.write('\treturn dll%s(' % t[2])
63 f_out.write('\tdll%s(' % t[2])
74 if __name__ == '__main__':
75 do_logfunc(sys.stdin, sys.stdout)