4 # Helper for the getprocaddress.c test.
6 glapi_xml_path
= "../../src/mapi/glapi/gen/"
9 sys
.path
.append(glapi_xml_path
)
14 def FindTestFunctions():
15 """Scan getprocaddress.c for lines that start with "test_" to find
16 extension function tests. Return a list of names found."""
18 f
= open("getprocaddress.c")
21 for line
in f
.readlines():
22 v
= re
.search("^test_([a-zA-Z0-9]+)", line
)
25 functions
.append(func
)
30 class PrintExports(gl_XML
.gl_print_base
):
32 gl_XML
.gl_print_base
.__init
__(self
)
34 self
.name
= "getprocaddress.py (from Mesa)"
35 self
.license
= license
.bsd_license_template
% ( \
36 """Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
37 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
39 self
.tests
= FindTestFunctions()
40 self
.prevCategory
= ""
44 def printRealHeader(self
):
46 struct name_test_pair {
48 GLboolean (*test)(generic_func);
51 static struct name_test_pair functions[] = {"""
53 def printBody(self
, api
):
57 for f
in api
.functionIterateByCategory():
58 [category
, num
] = api
.get_category_for_name( f
.name
)
59 if category
!= prev_category
:
60 print ' { "-%s", NULL},' % category
61 prev_category
= category
64 for name
in f
.entry_points
:
65 if name
in self
.tests
:
66 test
= "test_%s" % name
69 print ' { "gl%s", %s },' % (f
.name
, test
)
72 print ' { NULL, NULL }'
78 if __name__
== '__main__':
79 file_name
= glapi_xml_path
+ "gl_API.xml"
82 (args
, trail
) = getopt
.getopt(sys
.argv
[1:], "f:")
86 for (arg
,val
) in args
:
90 printer
= PrintExports()
92 api
= gl_XML
.parse_GL_API( file_name
, gl_XML
.gl_item_factory() )