Clone of mesa.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

getprocaddress.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env python
  2. # $Id: getprocaddress.py,v 1.7 2005/06/21 23:42:43 idr Exp $
  3. # Helper for the getprocaddress.c test.
  4. import sys, getopt, re
  5. sys.path.append("../../src/mesa/glapi/" )
  6. import gl_XML
  7. import license
  8. def FindTestFunctions():
  9. """Scan getprocaddress.c for lines that start with "test_" to find
  10. extension function tests. Return a list of names found."""
  11. functions = []
  12. f = open("getprocaddress.c")
  13. if not f:
  14. return functions
  15. for line in f.readlines():
  16. v = re.search("^test_([a-zA-Z0-9]+)", line)
  17. if v:
  18. func = v.group(1)
  19. functions.append(func)
  20. f.close
  21. return functions
  22. class PrintExports(gl_XML.gl_print_base):
  23. def __init__(self):
  24. gl_XML.gl_print_base.__init__(self)
  25. self.name = "getprocaddress.py (from Mesa)"
  26. self.license = license.bsd_license_template % ( \
  27. """Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
  28. (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
  29. self.tests = FindTestFunctions()
  30. self.prevCategory = ""
  31. return
  32. def printRealHeader(self):
  33. print """
  34. struct name_test_pair {
  35. const char *name;
  36. GLboolean (*test)(generic_func);
  37. };
  38. static struct name_test_pair functions[] = {"""
  39. def printBody(self, api):
  40. prev_category = None
  41. for f in api.functionIterateByOffset():
  42. [category, num] = api.get_category_for_name( f.name )
  43. if category != prev_category:
  44. print ' { "-%s", NULL},' % category
  45. prev_category = category
  46. test = "NULL"
  47. for name in f.entry_points:
  48. if name in self.tests:
  49. test = "test_%s" % name
  50. break
  51. print ' { "gl%s", %s },' % (f.name, test)
  52. print ''
  53. print ' { NULL, NULL }'
  54. print '};'
  55. print ''
  56. return
  57. if __name__ == '__main__':
  58. file_name = "../../src/mesa/glapi/gl_API.xml"
  59. try:
  60. (args, trail) = getopt.getopt(sys.argv[1:], "f:")
  61. except Exception,e:
  62. show_usage()
  63. for (arg,val) in args:
  64. if arg == "-f":
  65. file_name = val
  66. printer = PrintExports()
  67. api = gl_XML.parse_GL_API( file_name, gl_XML.gl_item_factory() )
  68. printer.Print( api )