blob: 061d71b7e002cda5768b5a2e6acdc0bfb27de965 [file] [log] [blame]
Brian Paulfeaf04a2000-02-22 22:45:20 +00001#!/usr/bin/env python
2
3# $Id: gloffsets.py,v 1.1 2000/02/22 22:45:20 brianp Exp $
4
5# Mesa 3-D graphics library
6# Version: 3.3
7#
8# Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
9#
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 glapioffsets.h file.
29#
30# Usage:
31# gloffsets.py >glapioffsets.h
32#
33# Dependencies:
34# The gl.spec file from the SI must be in the current directory.
35#
36# Brian Paul 3 February 2000
37
38
39import string
40import re
41
42
43def PrintHead():
44 print '/* DO NOT EDIT - This file generated automatically */'
45 print '#ifndef _GLAPI_OFFSETS_H_'
46 print '#define _GLAPI_OFFSETS_H_'
47 print ''
48 return
49#endif
50
51
52def PrintTail():
53 print ''
54 print '#endif'
55#endif
56
57
58def GenerateDefine(name, offset):
59 s = '#define _gloffset_' + name + ' ' + offset
60 return s;
61#enddef
62
63
64def PrintDefines():
65 functionPattern = re.compile('^[a-zA-Z0-9]+\(')
66 functionNamePattern = re.compile('^[a-zA-Z0-9]+')
67
68 funcName = ''
69
70 f = open('gl.spec')
71 for line in f.readlines():
72
73 m = functionPattern.match(line)
74 if m:
75 # extract funcName
76 n = functionNamePattern.findall(line)
77 funcName = n[0]
78
79 m = string.split(line)
80 if len(m) > 1:
81 if m[0] == 'param':
82 paramName = m[1]
83 if m[0] == 'offset':
84 funcOffset = m[1]
85 s = GenerateDefine(funcName, funcOffset)
86 print s
87 #endif
88 #endfor
89#enddef
90
91
92
93PrintHead()
94PrintDefines()
95PrintTail()