use GL_CALL() macro (Andreas Stenglein)
[mesa.git] / progs / tests / getprocaddress.py
1 #!/usr/bin/env python
2
3 # $Id: getprocaddress.py,v 1.3 2003/06/10 14:54:37 brianp Exp $
4
5 # Helper for the getprocaddress.c test.
6
7
8 import re, string
9
10
11 def PrintHead():
12 print """
13 struct name_test_pair {
14 const char *name;
15 GLboolean (*test)(void *);
16 };
17
18 static struct name_test_pair functions[] = {"""
19
20
21 def PrintTail():
22 print"""
23 { NULL, NULL }
24 };
25 """
26
27
28 def HaveTest(function):
29 testFuncs = [
30 "glActiveTextureARB",
31 "glSampleCoverageARB"
32 ]
33 if function in testFuncs:
34 return 1
35 else:
36 return 0
37
38
39 def FindTestFunctions():
40 """Scan getprocaddress.c for lines that start with "test_" to find
41 extension function tests. Return a list of names found."""
42 functions = []
43 f = open("getprocaddress.c")
44 if not f:
45 return functions
46 for line in f.readlines():
47 v = re.search("^test_([a-zA-Z0-9]+)", line)
48 if v:
49 func = v.group(1)
50 functions.append(func)
51 f.close
52 return functions
53
54
55 def PrintFunctions(specFile, tests):
56
57 # init some vars
58 prevCategory = ''
59 funcName = ''
60
61 f = open(specFile)
62 for line in f.readlines():
63
64 # split line into tokens
65 tokens = string.split(line)
66
67 if len(tokens) > 0 and line[0] != '#':
68
69 if tokens[0] == 'name':
70 if funcName != '':
71 if category != prevCategory:
72 print ' { "-%s", NULL},' % category
73 prevCategory = category
74
75 if funcName in tests:
76 test = "test_%s" % funcName
77 else:
78 test = "NULL"
79 print ' { "gl%s", %s },' % (funcName, test)
80 funcName = tokens[1]
81
82 elif tokens[0] == 'category':
83 category = tokens[1]
84
85 #endif
86 #endif
87 #endfor
88 #enddef
89
90
91 tests = FindTestFunctions()
92 PrintHead()
93 PrintFunctions("../../src/mesa/glapi/APIspec", tests)
94 PrintTail()
95
96