VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/dlm/dlm_header.py@ 65521

最後變更 在這個檔案從65521是 63942,由 vboxsync 提交於 8 年 前

OpenGL: fixed the most annoying coding style flaws, mainly removing spaces after '(' and before ')', no semantic change

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 10.6 KB
 
1# $Id: dlm_header.py 63942 2016-09-22 11:01:17Z vboxsync $
2import sys, cPickle, re, os
3
4sys.path.append( "../glapi_parser" )
5import apiutil
6
7# mode is "header" or "defs"
8mode = sys.argv[1]
9
10keys = apiutil.GetDispatchedFunctions(sys.argv[3]+"/APIspec.txt")
11
12# Any new function implemented in the DLM has to have an entry added here.
13# Each function has its return type, function name, and parameters provided.
14# We'll use these to generate both a header file, and a definition file.
15additionalFunctions = [
16 ('CRDLM DLM_APIENTRY *', 'crDLMNewDLM', 'unsigned int configSize, const CRDLMConfig *config'),
17 ('CRDLMContextState DLM_APIENTRY *', 'crDLMNewContext', 'CRDLM *dlm'),
18 ('void DLM_APIENTRY', 'crDLMFreeContext', 'CRDLMContextState *state, SPUDispatchTable *dispatchTable'),
19 ('void DLM_APIENTRY', 'crDLMUseDLM', 'CRDLM *dlm'),
20 ('void DLM_APIENTRY','crDLMFreeDLM', 'CRDLM *dlm, SPUDispatchTable *dispatchTable'),
21 ('void DLM_APIENTRY', 'crDLMSetCurrentState', 'CRDLMContextState *state'),
22 ('CRDLMContextState DLM_APIENTRY *', 'crDLMGetCurrentState', 'void'),
23 ('void DLM_APIENTRY', 'crDLMSetupClientState', 'SPUDispatchTable *dispatchTable'),
24 ('void DLM_APIENTRY', 'crDLMRestoreClientState', 'CRClientState *clientState, SPUDispatchTable *dispatchTable'),
25 ('void DLM_APIENTRY', 'crDLMSendAllDLMLists', 'CRDLM *dlm, SPUDispatchTable *dispatchTable'),
26 ('void DLM_APIENTRY', 'crDLMSendAllLists', 'SPUDispatchTable *dispatchTable'),
27 ('void DLM_APIENTRY', 'crDLMSendDLMList', 'CRDLM *dlm, unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
28 ('void DLM_APIENTRY', 'crDLMSendList', 'unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
29 ('void DLM_APIENTRY', 'crDLMReplayDLMList', 'CRDLM *dlm, unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
30 ('void DLM_APIENTRY', 'crDLMReplayList', 'unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
31 ('void DLM_APIENTRY', 'crDLMReplayDLMListState', 'CRDLM *dlm, unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
32 ('void DLM_APIENTRY', 'crDLMReplayListState', 'unsigned long listIdentifier, SPUDispatchTable *dispatchTable'),
33 ('void DLM_APIENTRY', 'crDLMReplayDLMLists', 'CRDLM *dlm, GLsizei n, GLenum type, const GLvoid *lists, SPUDispatchTable *dispatchTable'),
34 ('void DLM_APIENTRY', 'crDLMReplayLists', 'GLsizei n, GLenum type, const GLvoid *lists, SPUDispatchTable *dispatchTable'),
35 ('void DLM_APIENTRY', 'crDLMReplayDLMListsState', 'CRDLM *dlm, GLsizei n, GLenum type, const GLvoid *lists, SPUDispatchTable *dispatchTable'),
36 ('void DLM_APIENTRY', 'crDLMReplayListsState', 'GLsizei n, GLenum type, const GLvoid *lists, SPUDispatchTable *dispatchTable'),
37 ('CRDLMError DLM_APIENTRY', 'crDLMDeleteListContent', 'CRDLM *dlm, unsigned long listIdentifier'),
38 ('void DLM_APIENTRY', 'crDLMComputeBoundingBox', 'unsigned long listId'),
39 ('GLuint DLM_APIENTRY', 'crDLMGetCurrentList', 'void'),
40 ('GLenum DLM_APIENTRY', 'crDLMGetCurrentMode', 'void'),
41 ('void DLM_APIENTRY', 'crDLMErrorFunction', 'CRDLMErrorCallback callback'),
42 ('void DLM_APIENTRY', 'crDLMNewList', 'GLuint list, GLenum mode, SPUDispatchTable *dispatchTable'),
43 ('void DLM_APIENTRY', 'crDLMEndList', 'SPUDispatchTable *dispatchTable'),
44 ('void DLM_APIENTRY', 'crDLMCallList', 'GLuint list, SPUDispatchTable *dispatchTable'),
45 ('void DLM_APIENTRY', 'crDLMCallLists', 'GLsizei n, GLenum type, const GLvoid *lists, SPUDispatchTable *dispatchTable'),
46 ('void DLM_APIENTRY', 'crDLMDeleteLists', 'GLuint list, GLsizei range, SPUDispatchTable *dispatchTable'),
47 ('void DLM_APIENTRY', 'crDLMListBase', 'GLuint base, SPUDispatchTable *dispatchTable'),
48 ('GLboolean DLM_APIENTRY', 'crDLMIsList', 'GLuint list, SPUDispatchTable *dispatchTable'),
49 ('GLuint DLM_APIENTRY', 'crDLMGenLists', 'GLsizei range, SPUDispatchTable *dispatchTable'),
50 ('int32_t DLM_APIENTRY', 'crDLMSaveState', 'CRDLM *dlm, PSSMHANDLE pSSM'),
51 ('bool DLM_APIENTRY', 'crDLMLoadState', 'CRDLM *dlm, PSSMHANDLE pSSM, SPUDispatchTable *dispatchTable'),
52 #('void DLM_APIENTRY', 'crDLMListSent', 'CRDLM *dlm, unsigned long listIdentifier'),
53 #('GLboolean DLM_APIENTRY', 'crDLMIsListSent', 'CRDLM *dlm, unsigned long listIdentifier'),
54 #('GLint DLM_APIENTRY', 'crDLMListSize', 'CRDLM *dlm, unsigned long listIdentifier'),
55]
56
57if mode == 'header':
58 print """#ifndef CR_DLM_H
59
60/* DO NOT EDIT. This file is auto-generated by %s. */
61#define CR_DLM_H
62
63#if defined(WINDOWS)
64#define DLM_APIENTRY
65#else
66#define DLM_APIENTRY
67#endif
68
69#include "chromium.h"
70#include "state/cr_client.h"
71#include "cr_spu.h"
72#include "cr_hash.h"
73#include "cr_threads.h"
74#include "cr_pack.h"
75#ifdef CHROMIUM_THREADSAFE
76#include "cr_threads.h"
77#endif
78#include <VBox/types.h>
79""" % os.path.basename(sys.argv[0])
80
81 # Generate operation codes enum to be used for saving and restoring lists.
82 print "/* OpCodes codes enum to be used for saving and restoring lists. */"
83 print "typedef enum {"
84
85 for func_name in keys:
86 if apiutil.CanCompile(func_name) and not apiutil.FindSpecial("dlm", func_name):
87 print " VBOX_DL_OPCODE_%s," % func_name
88
89 print " VBOX_DL_OPCODE_MAX,"
90 print "} VBoxDLOpCode;"
91
92 print """
93/* 3D bounding box */
94typedef struct {
95 double xmin, xmax, ymin, ymax, zmin, zmax;
96} CRDLMBounds;
97
98/* Indicates whether we're currently involved in playback or not */
99typedef enum {
100 CRDLM_IMMEDIATE = 0,
101 CRDLM_REPLAY_STATE_FUNCTIONS = 1,
102 CRDLM_REPLAY_ALL_FUNCTIONS = 2
103} CRDLMReplayState;
104
105/* This is enough information to hold an instance of a single function call. */
106typedef struct DLMInstanceList {
107 struct DLMInstanceList *next;
108 struct DLMInstanceList *stateNext;
109 int cbInstance;
110 VBoxDLOpCode iVBoxOpCode; /* This field name should not interfere w/ OpenGL function parameters names (for example w/ param 'opcode' for glLogicOp()). */
111 void (*execute)(struct DLMInstanceList *instance, SPUDispatchTable *dispatchTable);
112} DLMInstanceList;
113
114typedef struct {
115 DLMInstanceList *first, *last;
116 uint32_t numInstances;
117 DLMInstanceList *stateFirst, *stateLast;
118 GLuint hwid;
119} DLMListInfo;
120
121typedef struct {
122 /* This holds all the display list information, hashed by list identifier. */
123 CRHashTable *displayLists;
124
125 /* This is a count of the number of contexts/users that are using
126 * this DLM.
127 */
128 unsigned int userCount;
129
130#ifdef CHROMIUM_THREADSAFE
131 /* This mutex protects the displayLists hash table from simultaneous
132 * updates by multiple contexts.
133 */
134 CRmutex dlMutex;
135 CRtsd tsdKey;
136#endif
137
138 /* Configuration information - see the CRDLMConfig structure below
139 * for details.
140 */
141 unsigned int bufferSize;
142} CRDLM;
143
144/* This structure holds thread-specific state. Each thread can be
145 * associated with one (and only one) context; and each context can
146 * be associated with one (and only one) DLM. Making things interesting,
147 * though, is that each DLM can be associated with multiple contexts.
148 *
149 * So the thread-specific data key is associated with each context, not
150 * with each DLM. Two different threads can, through two different
151 * contexts that share a single DLM, each have independent state and
152 * conditions.
153 */
154
155typedef struct {
156 CRDLM *dlm; /* the DLM associated with this state */
157 unsigned long currentListIdentifier; /* open display list */
158 DLMListInfo *currentListInfo; /* open display list data */
159 GLenum currentListMode; /* GL_COMPILE or GL_COMPILE_AND_EXECUTE */
160 GLuint listBase;
161
162} CRDLMContextState;
163
164/* These additional structures are for passing information to and from the
165 * CRDLM interface routines.
166 */
167typedef struct {
168 /* The size, in bytes, that the packer will initially allocate for
169 * each new buffer.
170 */
171#define CRDLM_DEFAULT_BUFFERSIZE (1024*1024)
172 unsigned int bufferSize; /* this will be allocated for each buffer */
173} CRDLMConfig;
174
175/* Positive values match GL error values.
176 * 0 (GL_NO_ERROR) is returned for success
177 * Negative values are internal errors.
178 * Possible positive values (from GL/gl.h) are:
179 * GL_NO_ERROR (0x0)
180 * GL_INVALID_ENUM (0x0500)
181 * GL_INVALID_VALUE (0x0501)
182 * GL_INVALID_OPERATION (0x0502)
183 * GL_STACK_OVERFLOW (0x0503)
184 * GL_STACK_UNDERFLOW (0x0504)
185 * GL_OUT_OF_MEMORY (0x0505)
186 */
187typedef int CRDLMError;
188
189/* This error reported if there's no current state. The caller is responsible
190 * for appropriately allocating context state with crDLMNewContext(), and
191 * for making it current with crDLMMakeCurrent().
192 */
193#define CRDLM_ERROR_STATE (-1)
194
195
196typedef void (*CRDLMErrorCallback)(int line, const char *file, GLenum error, const char *info);
197
198
199#ifdef __cplusplus
200extern "C" {
201#endif
202"""
203elif mode == 'defs':
204 apiutil.CopyrightDef()
205 print '''\t; DO NOT EDIT. This code is generated by %s.
206
207EXPORTS''' % os.path.basename(sys.argv[0])
208else:
209 raise "unknown generation mode '%s'" % mode
210
211# Generate the list of functions, starting with those coded into
212# the module
213for (returnValue, name, parameters) in additionalFunctions:
214 if mode == 'header':
215 print "extern %s %s(%s);" % (returnValue, name, parameters)
216 elif mode == 'defs':
217 print "%s" % name
218
219# Continue with functions that are auto-generated.
220
221if mode == 'header':
222 print
223 print "/* auto-generated compilation functions begin here */"
224
225
226
227for func_name in keys:
228 props = apiutil.Properties(func_name)
229 # We're interested in intercepting all calls that:
230 # - can be put into a display list (i.e. "not ("nolist" in props)")
231 # - change client-side state that affects saving DL elements (i.e. "setclient" in props)
232
233 if apiutil.CanCompile(func_name):
234 params = apiutil.Parameters(func_name)
235 argstring = apiutil.MakeDeclarationString(params)
236 if "useclient" in props or "pixelstore" in props:
237 argstring = argstring + ", CRClientState *c"
238
239 if mode == 'header':
240 print 'extern void DLM_APIENTRY crDLMCompile%s(%s);' % (func_name, argstring)
241 elif mode == 'defs':
242 print "crDLMCompile%s" % func_name
243
244# Next make declarations for all the checklist functions.
245if mode == 'header':
246 print """
247/* auto-generated CheckList functions begin here. There is one for each
248 * function that has a dual nature: even when there's an active glNewList,
249 * sometimes they are compiled into the display list, and sometimes they
250 * are treated like a control function. The CheckList function will
251 * return TRUE if the function should really be compiled into a display
252 * list. The calling SPU is responsible for checking this; but the
253 * DLM will also print an error if it detects an invalid use.
254 */
255"""
256elif mode == 'defs':
257 pass
258
259for func_name in keys:
260 if "checklist" in apiutil.ChromiumProps(func_name):
261 params = apiutil.Parameters(func_name)
262 argstring = apiutil.MakeDeclarationString(params)
263 if mode == 'header':
264 print 'int DLM_APIENTRY crDLMCheckList%s(%s);' % (func_name, argstring)
265 elif mode == 'defs':
266 print "crDLMCheckList%s" % func_name
267
268if mode == 'header':
269 print """
270#ifdef __cplusplus
271}
272#endif
273
274#endif /* CR_DLM_H */"""
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette