1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | import sys, string, re
|
---|
7 |
|
---|
8 | import apiutil
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 | apiutil.CopyrightC()
|
---|
13 |
|
---|
14 | print """
|
---|
15 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_dispatch.py SCRIPT */
|
---|
16 | #include "cr_spu.h"
|
---|
17 | #include "chromium.h"
|
---|
18 | #include "cr_error.h"
|
---|
19 | #include "server_dispatch.h"
|
---|
20 | #include "server.h"
|
---|
21 | #include "cr_unpack.h"
|
---|
22 |
|
---|
23 | CRCurrentStatePointers crServerCurrent;
|
---|
24 | """
|
---|
25 |
|
---|
26 |
|
---|
27 | def GetTestWrapper(func_name):
|
---|
28 | """Return a C preprocessor token to test in order to wrap code.
|
---|
29 | This handles extensions.
|
---|
30 | Example: GetTestWrapper("glActiveTextureARB") = "CR_multitexture"
|
---|
31 | Example: GetTestWrapper("glBegin") = ""
|
---|
32 | """
|
---|
33 | cat = apiutil.Category(func_name)
|
---|
34 | if (cat == "1.0" or
|
---|
35 | cat == "1.1" or
|
---|
36 | cat == "1.2" or
|
---|
37 | cat == "Chromium" or
|
---|
38 | cat == "GL_chromium"):
|
---|
39 | return ''
|
---|
40 | elif cat[0] =='1':
|
---|
41 | # i.e. OpenGL 1.3 or 1.4 or 1.5
|
---|
42 | return "OPENGL_VERSION_" + string.replace(cat, ".", "_")
|
---|
43 | else:
|
---|
44 | assert cat != ''
|
---|
45 | return string.replace(cat, "GL_", "")
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 | for func_name in apiutil.AllSpecials( sys.argv[1]+"/../state_tracker/state" ):
|
---|
50 | params = apiutil.Parameters(func_name)
|
---|
51 | if (apiutil.FindSpecial( "server", func_name ) or
|
---|
52 | "get" in apiutil.Properties(func_name)):
|
---|
53 | continue
|
---|
54 |
|
---|
55 | wrap = GetTestWrapper(func_name)
|
---|
56 | if wrap:
|
---|
57 | print '#if defined(CR_%s)' % wrap
|
---|
58 | print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString( params ) )
|
---|
59 | print '{'
|
---|
60 | print '\tcrState%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
|
---|
61 | print '\tcr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString( params ) )
|
---|
62 | print '}'
|
---|
63 | if wrap:
|
---|
64 | print '#endif'
|
---|
65 |
|
---|
66 |
|
---|
67 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
68 | for func_name in keys:
|
---|
69 | current = 0
|
---|
70 | array = ""
|
---|
71 | m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
72 | if m :
|
---|
73 | current = 1
|
---|
74 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
75 | type = m.group(3) + m.group(2)
|
---|
76 | m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)(EXT)$", func_name )
|
---|
77 | if m :
|
---|
78 | current = 1
|
---|
79 | name = string.lower(m.group(1)[:1] ) + m.group(1)[1:]
|
---|
80 | type = m.group(3) + m.group(2)
|
---|
81 | m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
82 | if m :
|
---|
83 | current = 1
|
---|
84 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
85 | type = m.group(3) + m.group(2)
|
---|
86 | array = "[0]"
|
---|
87 | m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
|
---|
88 | if m :
|
---|
89 | current = 1
|
---|
90 | name = "texCoord"
|
---|
91 | type = m.group(3) + m.group(2)
|
---|
92 | array = "[texture-GL_TEXTURE0_ARB]"
|
---|
93 | m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
94 | if m :
|
---|
95 | current = 1
|
---|
96 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
97 | type = m.group(2) + "1"
|
---|
98 | m = re.match( r"^(EdgeFlag)$", func_name )
|
---|
99 | if m :
|
---|
100 | current = 1
|
---|
101 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
102 | type = "l1"
|
---|
103 | m = re.match( r"^(FogCoord)(f|d)(EXT)$", func_name)
|
---|
104 | if m :
|
---|
105 | current = 1
|
---|
106 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
107 | type = m.group(2) + "1"
|
---|
108 |
|
---|
109 | # Vertex attribute commands w/ some special cases
|
---|
110 | m = re.search( r"^(VertexAttrib)([1234])(s|i|f|d)ARB$", func_name )
|
---|
111 | if m :
|
---|
112 | current = 1
|
---|
113 | name = string.lower( m.group(1)[:1] ) + m.group(1)[1:]
|
---|
114 | type = m.group(3) + m.group(2)
|
---|
115 | array = "[index]"
|
---|
116 | if func_name == "VertexAttrib4NubARB":
|
---|
117 | current = 1
|
---|
118 | name = "vertexAttrib"
|
---|
119 | type = "ub4"
|
---|
120 | array = "[index]"
|
---|
121 |
|
---|
122 | if current:
|
---|
123 | params = apiutil.Parameters(func_name)
|
---|
124 | print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params) )
|
---|
125 | print '{'
|
---|
126 | print '\tcr_server.head_spu->dispatch_table.%s( %s );' % (func_name, apiutil.MakeCallString(params) )
|
---|
127 | print "\tcr_server.current.c.%s.%s%s = cr_unpackData;" % (name,type,array)
|
---|
128 | print '}\n'
|
---|
129 |
|
---|
130 | print """
|
---|
131 | void crServerInitDispatch(void)
|
---|
132 | {
|
---|
133 | crSPUInitDispatchTable( &(cr_server.dispatch) );
|
---|
134 | crSPUCopyDispatchTable( &(cr_server.dispatch), &(cr_server.head_spu->dispatch_table ) );
|
---|
135 | """
|
---|
136 |
|
---|
137 | for func_name in keys:
|
---|
138 | if ("get" in apiutil.Properties(func_name) or
|
---|
139 | apiutil.FindSpecial( "server", func_name ) or
|
---|
140 | apiutil.FindSpecial( sys.argv[1]+"/../state_tracker/state", func_name )):
|
---|
141 |
|
---|
142 | wrap = GetTestWrapper(func_name)
|
---|
143 | if wrap:
|
---|
144 | print '#if defined(CR_%s)' % wrap
|
---|
145 |
|
---|
146 | print '\tcr_server.dispatch.%s = crServerDispatch%s;' % (func_name, func_name)
|
---|
147 | if wrap:
|
---|
148 | print '#endif'
|
---|
149 |
|
---|
150 | print '}'
|
---|
151 |
|
---|