Brian Paul | 6c0d72f | 2001-11-18 22:42:57 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # $Id: glprocs.py,v 1.1 2001/11/18 22:42:57 brianp Exp $ |
| 4 | |
| 5 | # Mesa 3-D graphics library |
| 6 | # Version: 4.1 |
| 7 | # |
| 8 | # Copyright (C) 1999-2001 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 glprocs.h file. |
| 29 | # |
| 30 | # Usage: |
| 31 | # gloffsets.py >glprocs.h |
| 32 | # |
| 33 | # Dependencies: |
| 34 | # The apispec file must be in the current directory. |
| 35 | |
| 36 | |
| 37 | |
| 38 | import apiparser |
| 39 | import string |
| 40 | |
| 41 | |
| 42 | def PrintHead(): |
| 43 | print '/* DO NOT EDIT - This file generated automatically by glprocs.py script */' |
| 44 | print '' |
| 45 | print '/* This file is only included by glapi.c and is used for' |
| 46 | print ' * the GetProcAddress() function' |
| 47 | print ' */' |
| 48 | print '' |
| 49 | print 'static struct name_address_offset static_functions[] = {' |
| 50 | return |
| 51 | #enddef |
| 52 | |
| 53 | |
| 54 | def PrintTail(): |
| 55 | print ' { NULL, NULL } /* end of list marker */' |
| 56 | print '};' |
| 57 | #enddef |
| 58 | |
| 59 | |
| 60 | records = [] |
| 61 | |
| 62 | def FindOffset(funcName): |
| 63 | for (name, alias, offset) in records: |
| 64 | if name == funcName: |
| 65 | return offset |
| 66 | #endif |
| 67 | #endfor |
| 68 | return -1 |
| 69 | #enddef |
| 70 | |
| 71 | |
| 72 | def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset): |
| 73 | if alias == '': |
| 74 | dispatchName = name |
| 75 | else: |
| 76 | dispatchName = alias |
| 77 | if offset < 0: |
| 78 | offset = FindOffset(dispatchName) |
| 79 | if offset >= 0 and string.find(name, "unused") == -1: |
| 80 | print ' { "gl%s", (GLvoid *) gl%s, _gloffset_%s },' % (name, name, dispatchName) |
| 81 | # save this info in case we need to look up an alias later |
| 82 | records.append((name, dispatchName, offset)) |
| 83 | |
| 84 | #enddef |
| 85 | |
| 86 | |
| 87 | PrintHead() |
| 88 | apiparser.ProcessSpecFile("APIspec", EmitEntry) |
| 89 | PrintTail() |