summaryrefslogtreecommitdiffstats
path: root/src/mapi/glapi/gen/mesadef.py
blob: f6d33cb8c43ef58d56411ec7590f8b7e74fa561e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/usr/bin/env python


# Mesa 3-D graphics library
# 
# Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
# 
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


# Generate the mesa.def file for Windows.
#
# Usage:
#    mesadef.py >mesa.def
#    Then copy to src/mesa/drivers/windows/gdi
#
# Dependencies:
#    The apispec file must be in the current directory.



import apiparser
import string


def PrintHead():
    print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
    print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
    print 'VERSION 6.0'
    print ';'
    print '; Module definition file for Mesa (OPENGL32.DLL)'
    print ';'
    print '; Note: The OpenGL functions use the STDCALL'
    print '; function calling convention.  Microsoft\'s'
    print '; OPENGL32 uses this convention and so must the'
    print '; Mesa OPENGL32 so that the Mesa DLL can be used'
    print '; as a drop-in replacement.'
    print ';'
    print '; The linker exports STDCALL entry points with'
    print '; \'decorated\' names; e.g., _glBegin@0, where the'
    print '; trailing number is the number of bytes of '
    print '; parameter data pushed onto the stack.  The'
    print '; callee is responsible for popping this data'
    print '; off the stack, usually via a RETF n instruction.'
    print ';'
    print '; However, the Microsoft OPENGL32.DLL does not export'
    print '; the decorated names, even though the calling convention'
    print '; is STDCALL.  So, this module definition file is'
    print '; needed to force the Mesa OPENGL32.DLL to export the'
    print '; symbols in the same manner as the Microsoft DLL.'
    print '; Were it not for this problem, this file would not'
    print '; be needed (for the gl* functions) since the entry'
    print '; points are compiled with dllexport declspec.'
    print ';'
    print '; However, this file is still needed to export "internal"'
    print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
    print ';'
    print 'EXPORTS'
    return
#enddef


def PrintTail():
    print ';'
    print '; WGL API'
    print '\twglChoosePixelFormat'
    print '\twglCopyContext'
    print '\twglCreateContext'
    print '\twglCreateLayerContext'
    print '\twglDeleteContext'
    print '\twglDescribeLayerPlane'
    print '\twglDescribePixelFormat'
    print '\twglGetCurrentContext'
    print '\twglGetCurrentDC'
    print '\twglGetExtensionsStringARB'
    print '\twglGetLayerPaletteEntries'
    print '\twglGetPixelFormat'
    print '\twglGetProcAddress'
    print '\twglMakeCurrent'
    print '\twglRealizeLayerPalette'
    print '\twglSetLayerPaletteEntries'
    print '\twglSetPixelFormat'
    print '\twglShareLists'
    print '\twglSwapBuffers'
    print '\twglSwapLayerBuffers'
    print '\twglUseFontBitmapsA'
    print '\twglUseFontBitmapsW'
    print '\twglUseFontOutlinesA'
    print '\twglUseFontOutlinesW'
    print ';'
    print '; Mesa internals - mostly for OSMESA'
    print '\t_ac_CreateContext'
    print '\t_ac_DestroyContext'
    print '\t_ac_InvalidateState'
    print '\t_glapi_get_context'
    print '\t_glapi_get_proc_address'
    print '\t_mesa_buffer_data'
    print '\t_mesa_buffer_map'
    print '\t_mesa_buffer_subdata'
    print '\t_mesa_choose_tex_format'
    print '\t_mesa_compressed_texture_size'
    print '\t_mesa_create_framebuffer'
    print '\t_mesa_create_visual'
    print '\t_mesa_delete_buffer_object'
    print '\t_mesa_delete_texture_object'
    print '\t_mesa_destroy_framebuffer'
    print '\t_mesa_destroy_visual'
    print '\t_mesa_enable_1_3_extensions'
    print '\t_mesa_enable_1_4_extensions'
    print '\t_mesa_enable_1_5_extensions'
    print '\t_mesa_enable_sw_extensions'
    print '\t_mesa_error'
    print '\t_mesa_free_context_data'
    print '\t_mesa_get_current_context'
    print '\t_mesa_init_default_imports'
    print '\t_mesa_initialize_context'
    print '\t_mesa_make_current'
    print '\t_mesa_new_buffer_object'
    print '\t_mesa_new_texture_object'
    print '\t_mesa_problem'
    print '\t_mesa_ResizeBuffersMESA'
    print '\t_mesa_store_compressed_teximage1d'
    print '\t_mesa_store_compressed_teximage2d'
    print '\t_mesa_store_compressed_teximage3d'
    print '\t_mesa_store_compressed_texsubimage1d'
    print '\t_mesa_store_compressed_texsubimage2d'
    print '\t_mesa_store_compressed_texsubimage3d'
    print '\t_mesa_store_teximage1d'
    print '\t_mesa_store_teximage2d'
    print '\t_mesa_store_teximage3d'
    print '\t_mesa_store_texsubimage1d'
    print '\t_mesa_store_texsubimage2d'
    print '\t_mesa_store_texsubimage3d'
    print '\t_mesa_test_proxy_teximage'
    print '\t_mesa_Viewport'
    print '\t_mesa_meta_CopyColorSubTable'
    print '\t_mesa_meta_CopyColorTable'
    print '\t_mesa_meta_CopyConvolutionFilter1D'
    print '\t_mesa_meta_CopyConvolutionFilter2D'
    print '\t_mesa_meta_CopyTexImage1D'
    print '\t_mesa_meta_CopyTexImage2D'
    print '\t_mesa_meta_CopyTexSubImage1D'
    print '\t_mesa_meta_CopyTexSubImage2D'
    print '\t_mesa_meta_CopyTexSubImage3D'
    print '\t_swrast_Accum'
    print '\t_swrast_alloc_buffers'
    print '\t_swrast_Bitmap'
    print '\t_swrast_CopyPixels'
    print '\t_swrast_DrawPixels'
    print '\t_swrast_GetDeviceDriverReference'
    print '\t_swrast_Clear'
    print '\t_swrast_choose_line'
    print '\t_swrast_choose_triangle'
    print '\t_swrast_CreateContext'
    print '\t_swrast_DestroyContext'
    print '\t_swrast_InvalidateState'
    print '\t_swrast_ReadPixels'
    print '\t_swrast_zbuffer_address'
    print '\t_swsetup_Wakeup'
    print '\t_swsetup_CreateContext'
    print '\t_swsetup_DestroyContext'
    print '\t_swsetup_InvalidateState'
    print '\t_tnl_CreateContext'
    print '\t_tnl_DestroyContext'
    print '\t_tnl_InvalidateState'
    print '\t_tnl_MakeCurrent'
    print '\t_tnl_run_pipeline'
#enddef


records = []

def FindOffset(funcName):
    for (name, alias, offset) in records:
        if name == funcName:
            return offset
        #endif
    #endfor
    return -1
#enddef


def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset):
    if alias == '':
        dispatchName = name
    else:
        dispatchName = alias
    if offset < 0:
        offset = FindOffset(dispatchName)
    if offset >= 0 and string.find(name, "unused") == -1:
        print '\tgl%s' % (name)
        # save this info in case we need to look up an alias later
        records.append((name, dispatchName, offset))

#enddef


PrintHead()
apiparser.ProcessSpecFile("APIspec", EmitEntry)
PrintTail()