blob: 54dacb18d2cb5680f2b5fcf6fc32df1f26a36146 [file] [log] [blame]
Brian Paulfeaf04a2000-02-22 22:45:20 +00001#!/usr/bin/env python
2
Brian Paul6c0d72f2001-11-18 22:42:57 +00003# $Id: gltable.py,v 1.3 2001/11/18 22:42:57 brianp Exp $
Brian Paulfeaf04a2000-02-22 22:45:20 +00004
5# Mesa 3-D graphics library
Brian Paul6c0d72f2001-11-18 22:42:57 +00006# Version: 4.1
Brian Paulfeaf04a2000-02-22 22:45:20 +00007#
Brian Paul6c0d72f2001-11-18 22:42:57 +00008# Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
Brian Paulfeaf04a2000-02-22 22:45:20 +00009#
10# Permission is hereby granted, free of charge, to any person obtaining a
11# copy of this software and associated documentation files (the "Software"),
12# to deal in the Software without restriction, including without limitation
13# the rights to use, copy, modify, merge, publish, distribute, sublicense,
14# and/or sell copies of the Software, and to permit persons to whom the
15# Software is furnished to do so, subject to the following conditions:
16#
17# The above copyright notice and this permission notice shall be included
18# in all copies or substantial portions of the Software.
19#
20# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27
28# Generate the glapitable.h file.
29#
30# Usage:
Brian Paul6c0d72f2001-11-18 22:42:57 +000031# gloffsets.py >glapitable.h
Brian Paulfeaf04a2000-02-22 22:45:20 +000032#
33# Dependencies:
Brian Paul6c0d72f2001-11-18 22:42:57 +000034# The apispec file must be in the current directory.
Brian Paulfeaf04a2000-02-22 22:45:20 +000035
36
Brian Paul6c0d72f2001-11-18 22:42:57 +000037import apiparser;
Brian Paulfeaf04a2000-02-22 22:45:20 +000038
39
40def PrintHead():
Brian Paul6c0d72f2001-11-18 22:42:57 +000041 print '/* DO NOT EDIT - This file generated automatically with gltable.py script */'
42 print '#ifndef _GLAPI_TABLE_H_'
43 print '#define _GLAPI_TABLE_H_'
44 print ''
45 print '#include <GL/gl.h>'
46 print ''
47 print 'struct _glapi_table'
48 print '{'
49 return
Brian Paulfeaf04a2000-02-22 22:45:20 +000050#endif
51
52
53def PrintTail():
Brian Paul6c0d72f2001-11-18 22:42:57 +000054 print '};'
55 print ''
56 print '#endif'
Brian Paulfeaf04a2000-02-22 22:45:20 +000057#endif
58
59
Brian Paul6c0d72f2001-11-18 22:42:57 +000060records = {}
Brian Paulfeaf04a2000-02-22 22:45:20 +000061
Brian Paul6c0d72f2001-11-18 22:42:57 +000062def DoRecord(name, returnType, argTypeList, argNameList, alias, offset):
63 argList = apiparser.MakeArgList(argTypeList, argNameList)
64 if offset >= 0 and not records.has_key(offset):
65 records[offset] = (name, returnType, argList)
66 #print '#define _gloffset_%s %d' % (name, offset)
67#endif
68
69
70def PrintRecords():
71 keys = records.keys()
72 keys.sort()
73 prevk = -1
74 for k in keys:
75 if k != prevk + 1:
76 #print 'Missing offset %d' % (prevk)
77 pass
78 prevk = int(k)
79 (name, returnType, argList) = records[k]
80 print ' %s (*%s)(%s); /* %d */' % (returnType, name, argList, k)
81#endef
82
83
84PrintHead()
85apiparser.ProcessSpecFile("APIspec", DoRecord)
86PrintRecords()
87PrintTail()
88