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 | from __future__ import print_function
|
---|
7 | import sys, string, re
|
---|
8 |
|
---|
9 | import apiutil
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 | apiutil.CopyrightC()
|
---|
14 |
|
---|
15 | print("""
|
---|
16 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY server_dispatch.py SCRIPT */
|
---|
17 | #include "cr_spu.h"
|
---|
18 | #include "chromium.h"
|
---|
19 | #include "cr_error.h"
|
---|
20 | #include "server_dispatch.h"
|
---|
21 | #include "server.h"
|
---|
22 | #include "cr_unpack.h"
|
---|
23 |
|
---|
24 | CRCurrentStatePointers crServerCurrent;
|
---|
25 | """)
|
---|
26 |
|
---|
27 |
|
---|
28 | for func_name in apiutil.AllSpecials( sys.argv[1]+"/../state_tracker/state" ):
|
---|
29 | params = apiutil.Parameters(func_name)
|
---|
30 | if (apiutil.FindSpecial( "server", func_name ) or
|
---|
31 | "get" in apiutil.Properties(func_name)):
|
---|
32 | continue
|
---|
33 |
|
---|
34 | wrap = apiutil.GetCategoryWrapper(func_name)
|
---|
35 | if wrap:
|
---|
36 | print('#if defined(CR_%s)' % wrap)
|
---|
37 | print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString( params ) ))
|
---|
38 | print('{')
|
---|
39 | print('\tcrState%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
|
---|
40 | print('\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
|
---|
41 | print('}')
|
---|
42 | if wrap:
|
---|
43 | print('#endif')
|
---|
44 |
|
---|
45 |
|
---|
46 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
47 | for func_name in keys:
|
---|
48 | current = 0
|
---|
49 | array = ""
|
---|
50 | condition = ""
|
---|
51 | m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
52 | if m :
|
---|
53 | current = 1
|
---|
54 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
55 | type = m.group(3) + m.group(2)
|
---|
56 | m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)(EXT)$", func_name )
|
---|
57 | if m :
|
---|
58 | current = 1
|
---|
59 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
60 | type = m.group(3) + m.group(2)
|
---|
61 | m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
62 | if m :
|
---|
63 | current = 1
|
---|
64 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
65 | type = m.group(3) + m.group(2)
|
---|
66 | array = "[0]"
|
---|
67 | m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name )
|
---|
68 | if m :
|
---|
69 | current = 1
|
---|
70 | name = "texCoord"
|
---|
71 | type = m.group(3) + m.group(2)
|
---|
72 | array = "[texture-GL_TEXTURE0_ARB]"
|
---|
73 | condition = "if (texture >= GL_TEXTURE0_ARB && texture < GL_TEXTURE0_ARB + CR_MAX_TEXTURE_UNITS)"
|
---|
74 | m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name )
|
---|
75 | if m :
|
---|
76 | current = 1
|
---|
77 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
78 | type = m.group(2) + "1"
|
---|
79 | m = re.match( r"^(EdgeFlag)$", func_name )
|
---|
80 | if m :
|
---|
81 | current = 1
|
---|
82 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
83 | type = "l1"
|
---|
84 | m = re.match( r"^(FogCoord)(f|d)(EXT)$", func_name)
|
---|
85 | if m :
|
---|
86 | current = 1
|
---|
87 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
88 | type = m.group(2) + "1"
|
---|
89 |
|
---|
90 | # Vertex attribute commands w/ some special cases
|
---|
91 | m = re.search( r"^(VertexAttrib)([1234])(s|i|f|d)ARB$", func_name )
|
---|
92 | if m :
|
---|
93 | current = 1
|
---|
94 | name = m.group(1)[:1].lower() + m.group(1)[1:]
|
---|
95 | type = m.group(3) + m.group(2)
|
---|
96 | array = "[index]"
|
---|
97 | condition = "if (index < CR_MAX_VERTEX_ATTRIBS)"
|
---|
98 | if func_name == "VertexAttrib4NubARB":
|
---|
99 | current = 1
|
---|
100 | name = "vertexAttrib"
|
---|
101 | type = "ub4"
|
---|
102 | array = "[index]"
|
---|
103 | condition = "if (index < CR_MAX_VERTEX_ATTRIBS)"
|
---|
104 |
|
---|
105 | if current:
|
---|
106 | params = apiutil.Parameters(func_name)
|
---|
107 | print('void SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
|
---|
108 | print('{')
|
---|
109 | print('\t%s' % (condition))
|
---|
110 | print('\t{')
|
---|
111 | print('\t\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallString(params) ))
|
---|
112 | print("\t\tcr_server.current.c.%s.%s%s = cr_unpackData;" % (name,type,array))
|
---|
113 | print('\t}')
|
---|
114 | print('}\n')
|
---|
115 |
|
---|
116 | print("""
|
---|
117 | void crServerInitDispatch(void)
|
---|
118 | {
|
---|
119 | crSPUInitDispatchTable( &(cr_server.dispatch) );
|
---|
120 | crSPUCopyDispatchTable( &(cr_server.dispatch), &(cr_server.head_spu->dispatch_table ) );
|
---|
121 | """)
|
---|
122 |
|
---|
123 | for func_name in keys:
|
---|
124 | if ("get" in apiutil.Properties(func_name) or
|
---|
125 | apiutil.FindSpecial( "server", func_name ) or
|
---|
126 | apiutil.FindSpecial( sys.argv[1]+"/../state_tracker/state", func_name )):
|
---|
127 |
|
---|
128 | wrap = apiutil.GetCategoryWrapper(func_name)
|
---|
129 | if wrap:
|
---|
130 | print('#if defined(CR_%s)' % wrap)
|
---|
131 |
|
---|
132 | print('\tcr_server.dispatch.%s = crServerDispatch%s;' % (func_name, func_name))
|
---|
133 | if wrap:
|
---|
134 | print('#endif')
|
---|
135 |
|
---|
136 | print('}')
|
---|
137 |
|
---|