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: gltable.py,v 1.3 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 glapitable.h file. |
| 29 | # |
| 30 | # Usage: |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame^] | 31 | # gloffsets.py >glapitable.h |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 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 | import apiparser; |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 38 | |
| 39 | |
| 40 | def PrintHead(): |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame^] | 41 | 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 Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 50 | #endif |
| 51 | |
| 52 | |
| 53 | def PrintTail(): |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame^] | 54 | print '};' |
| 55 | print '' |
| 56 | print '#endif' |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
| 59 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame^] | 60 | records = {} |
Brian Paul | feaf04a | 2000-02-22 22:45:20 +0000 | [diff] [blame] | 61 | |
Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame^] | 62 | def 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 | |
| 70 | def 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 | |
| 84 | PrintHead() |
| 85 | apiparser.ProcessSpecFile("APIspec", DoRecord) |
| 86 | PrintRecords() |
| 87 | PrintTail() |
| 88 | |