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