Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 3 | # $Id: gloffsets.py,v 1.5 2001/11/18 22:42:57 brianp Exp $ |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 4 | |
| 5 | # Mesa 3-D graphics library |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 6 | # Version: 4.1 |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 7 | # |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 8 | # Copyright (C) 1999-2001 Brian Paul All Rights Reserved. |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 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: |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 34 | # The apispec file must be in the current directory. |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 35 | |
| 36 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 37 | |
| 38 | import apiparser; |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 39 | |
| 40 | |
| 41 | def PrintHead(): |
Brian Paul | ecfdd88 | 2000-05-11 17:45:20 +0000 | [diff] [blame] | 42 | print '/* DO NOT EDIT - This file generated automatically by gloffsets.py script */' |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 43 | print '#ifndef _GLAPI_OFFSETS_H_' |
| 44 | print '#define _GLAPI_OFFSETS_H_' |
| 45 | print '' |
| 46 | return |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 47 | #enddef |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | def PrintTail(): |
| 51 | print '' |
| 52 | print '#endif' |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 53 | #enddef |
| 54 | |
| 55 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 56 | records = {} |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 57 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 58 | def AddOffset(name, returnType, argTypeList, argNameList, alias, offset): |
| 59 | argList = apiparser.MakeArgList(argTypeList, argNameList) |
| 60 | if offset >= 0 and not records.has_key(offset): |
| 61 | records[offset] = name |
| 62 | #print '#define _gloffset_%s %d' % (name, offset) |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 63 | #enddef |
| 64 | |
| 65 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 66 | def PrintRecords(): |
| 67 | keys = records.keys() |
| 68 | keys.sort() |
| 69 | prevk = -1 |
| 70 | for k in keys: |
| 71 | if k != prevk + 1: |
| 72 | #print 'Missing offset %d' % (prevk) |
| 73 | pass |
| 74 | prevk = int(k) |
| 75 | name = records[k] |
| 76 | print '#define _gloffset_%s %d' % (name, k) |
| 77 | #endef |
| 78 | |
| 79 | |
| 80 | |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 81 | |
| 82 | PrintHead() |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 83 | apiparser.ProcessSpecFile("APIspec", AddOffset) |
| 84 | PrintRecords() |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 85 | PrintTail() |