3 # Copyright 2008 VMware, Inc.
4 # Copyright 2004 IBM Corporation
7 # Permission is hereby granted, free of charge, to any person obtaining a
8 # copy of this software and associated documentation files (the "Software"),
9 # to deal in the Software without restriction, including without limitation
10 # on the rights to use, copy, modify, merge, publish, distribute, sub
11 # license, and/or sell copies of the Software, and to permit persons to whom
12 # the Software is furnished to do so, subject to the following conditions:
14 # The above copyright notice and this permission notice (including the next
15 # paragraph) shall be included in all copies or substantial portions of the
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 # THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 glapi_path = os.path.join(os.environ['MESA'], 'src/mapi/glapi/gen')
31 sys.path.insert(0, glapi_path)
42 def parse_type(tokens, count = 0):
44 if tokens[-1] == '**':
45 return 'Array(Pointer(%s), "%s")' % (parse_type(tokens[:-1]), count)
47 return 'Array(%s, "%s")' % (parse_type(tokens[:-1]), count)
49 if tokens[-1] == '**':
50 return 'Pointer(Pointer(%s))' % parse_type(tokens[:-1])
52 return 'Pointer(%s)' % parse_type(tokens[:-1])
53 if tokens[-1] == 'const':
54 return 'Const(%s)' % parse_type(tokens[:-1])
55 if tokens[0] == 'const':
56 return 'Const(%s)' % parse_type(tokens[1:])
57 assert len(tokens) == 1
59 return type_map.get(base, base)
61 def get_type(t, count = 0):
64 return parse_type(tokens, count)
67 class PrintGlTable(gl_XML.gl_print_base):
69 gl_XML.gl_print_base.__init__(self)
71 #self.header_tag = '_GLAPI_TABLE_H_'
72 self.name = "gl_trace.py (from Mesa)"
73 self.license = license.bsd_license_template % ( \
74 """Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
75 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
78 def printBody(self, api):
79 abi = [ "1.0", "1.1", "1.2", "1.5", "GL_ARB_multitexture" ]
80 for pass_ in range(2):
81 for f in api.functionIterateByOffset():
82 for name in f.entry_points:
83 [category, num] = api.get_category_for_name( name )
85 for p in f.parameters:
86 type = get_type(p.type_string(), p.count)
87 args.append('(%s, "%s")' % (type, p.name))
88 arg_string = '[' + ', '.join(args) + ']'
91 print ' GlFunction(%s, "gl%s", %s),' % (get_type(f.return_type), name, arg_string)
94 print ' GlFunction(%s, "gl%s", %s),' % (get_type(f.return_type), name, arg_string)
96 def printRealHeader(self):
99 def printRealFooter(self):
104 print "Usage: %s [-f input_file_name]" % sys.argv[0]
107 if __name__ == '__main__':
108 file_name = os.path.join(glapi_path, "gl_API.xml")
111 (args, trail) = getopt.getopt(sys.argv[1:], "f:")
115 for (arg,val) in args:
119 printer = PrintGlTable()
121 api = gl_XML.parse_GL_API( file_name )