blob: 743a35ebf6a83ed75ff273e9650800d87d2af942 [file] [log] [blame]
Brian Pauld1efbf02002-11-08 15:35:46 +00001#!/usr/bin/env python
2
Brian Paul9a2121c2003-06-10 14:54:37 +00003# $Id: getprocaddress.py,v 1.3 2003/06/10 14:54:37 brianp Exp $
Brian Pauld1efbf02002-11-08 15:35:46 +00004
5# Helper for the getprocaddress.c test.
6
7
8import re, string
9
Brian Paul0b0245c2002-11-08 15:49:31 +000010
Brian Pauld1efbf02002-11-08 15:35:46 +000011def PrintHead():
12 print """
13struct name_test_pair {
14 const char *name;
15 GLboolean (*test)(void *);
16};
17
18static struct name_test_pair functions[] = {"""
19
20
21def PrintTail():
22 print"""
23 { NULL, NULL }
24};
25"""
26
27
28def HaveTest(function):
29 testFuncs = [
30 "glActiveTextureARB",
31 "glSampleCoverageARB"
32 ]
33 if function in testFuncs:
34 return 1
35 else:
36 return 0
37
38
39def 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)
Brian Pauld1efbf02002-11-08 15:35:46 +000050 functions.append(func)
51 f.close
52 return functions
53
54
55def 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
Brian Pauld1efbf02002-11-08 15:35:46 +000075 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
91tests = FindTestFunctions()
92PrintHead()
Brian Paul9a2121c2003-06-10 14:54:37 +000093PrintFunctions("../../src/mesa/glapi/APIspec", tests)
Brian Pauld1efbf02002-11-08 15:35:46 +000094PrintTail()
95
96