From 7520e259950f7ed356f9737e68d4514e7eec8f06 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Oct 2004 19:12:08 +0000 Subject: Updated getprocaddress test to use gl_API.xml instead of old APIspec file. --- progs/tests/Makefile | 2 +- progs/tests/getprocaddress.py | 135 +++++++++++++++++++++--------------------- 2 files changed, 68 insertions(+), 69 deletions(-) (limited to 'progs') diff --git a/progs/tests/Makefile b/progs/tests/Makefile index a826762e1cf..872fa0f6214 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -87,7 +87,7 @@ clean: # auto code generation getprocaddress: getprocaddress.c getproclist.h -getproclist.h: $(TOP)/src/mesa/glapi/APIspec getprocaddress.c getprocaddress.py +getproclist.h: $(TOP)/src/mesa/glapi/gl_API.xml getprocaddress.c getprocaddress.py python getprocaddress.py > getproclist.h diff --git a/progs/tests/getprocaddress.py b/progs/tests/getprocaddress.py index 743a35ebf6a..238e019b131 100644 --- a/progs/tests/getprocaddress.py +++ b/progs/tests/getprocaddress.py @@ -1,39 +1,17 @@ #!/usr/bin/env python -# $Id: getprocaddress.py,v 1.3 2003/06/10 14:54:37 brianp Exp $ +# $Id: getprocaddress.py,v 1.4 2004/10/29 19:12:08 brianp Exp $ # Helper for the getprocaddress.c test. +from xml.sax import saxutils +from xml.sax import make_parser +from xml.sax.handler import feature_namespaces -import re, string - - -def PrintHead(): - print """ -struct name_test_pair { - const char *name; - GLboolean (*test)(void *); -}; - -static struct name_test_pair functions[] = {""" - - -def PrintTail(): - print""" - { NULL, NULL } -}; -""" - - -def HaveTest(function): - testFuncs = [ - "glActiveTextureARB", - "glSampleCoverageARB" - ] - if function in testFuncs: - return 1 - else: - return 0 +import sys, getopt, re +sys.path.append("../../src/mesa/glapi/" ) +import gl_XML +import license def FindTestFunctions(): @@ -52,45 +30,66 @@ def FindTestFunctions(): return functions -def PrintFunctions(specFile, tests): +class PrintExports(gl_XML.FilterGLAPISpecBase): + name = "gl_exports.py (from Mesa)" - # init some vars - prevCategory = '' - funcName = '' - - f = open(specFile) - for line in f.readlines(): + def __init__(self): + gl_XML.FilterGLAPISpecBase.__init__(self) + self.license = license.bsd_license_template % ( \ +"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved. +(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + self.tests = FindTestFunctions() + self.prevCategory = "" - # split line into tokens - tokens = string.split(line) - - if len(tokens) > 0 and line[0] != '#': - - if tokens[0] == 'name': - if funcName != '': - if category != prevCategory: - print ' { "-%s", NULL},' % category - prevCategory = category - - if funcName in tests: - test = "test_%s" % funcName - else: - test = "NULL" - print ' { "gl%s", %s },' % (funcName, test) - funcName = tokens[1] - - elif tokens[0] == 'category': - category = tokens[1] - - #endif - #endif - #endfor -#enddef - - -tests = FindTestFunctions() -PrintHead() -PrintFunctions("../../src/mesa/glapi/APIspec", tests) -PrintTail() + def printRealHeader(self): + print """ +struct name_test_pair { + const char *name; + GLboolean (*test)(void *); +}; + +static struct name_test_pair functions[] = {""" + def printRealFooter(self): + print""" + { NULL, NULL } +}; +""" + def printFunction(self, f): + if f.category != self.prevCategory: + print ' { "-%s", NULL},' % f.category + self.prevCategory = f.category + + if f.name in self.tests: + test = "test_%s" % f.name + else: + test = "NULL" + print ' { "gl%s", %s }, /* %s */' % (f.name, test, f.category) + return + + +if __name__ == '__main__': + file_name = "../../src/mesa/glapi/gl_API.xml" + + try: + (args, trail) = getopt.getopt(sys.argv[1:], "f:") + except Exception,e: + show_usage() + + for (arg,val) in args: + if arg == "-f": + file_name = val + + dh = PrintExports() + + parser = make_parser() + parser.setFeature(feature_namespaces, 0) + parser.setContentHandler(dh) + + f = open(file_name) + + parser.parse(f) + dh.printHeader() + dh.printFunctions() + dh.printFooter() -- cgit v1.2.3