1
<?xml version="1.0" encoding="UTF-8" ?>
4
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
7
<xsl:output method="text"/>
8
<xsl:strip-space elements="RiAPI"/>
12
<xsl:template match="RiAPI">
14
<xsl:apply-templates select="Procedures/Procedure"/>
15
<xsl:apply-templates select="Procedures/Procedure" mode="macro"/>
20
<xsl:template match="Procedure">
21
<xsl:if test="not(./NoCache)">
22
<xsl:value-of select="concat('class ', @name, 'Cache : public RiCacheBase
')"/>
23
<xsl:text>{
</xsl:text>
24
<xsl:text>public:
</xsl:text>
25
<xsl:call-template name="Constructor"/>
26
<xsl:call-template name="Destructor"/>
27
<xsl:value-of select="concat('	virtual void ReCall()
	{
		', @name)"/>
28
<xsl:if test="Arguments/Argument[last()]/@type = 'PARAMETERLIST'">
29
<xsl:text>V</xsl:text>
31
<xsl:text>(</xsl:text>
32
<xsl:apply-templates select="Arguments/Argument" mode="recall_args"/>
33
<xsl:text>);
</xsl:text>
34
<xsl:text>	}
</xsl:text>
35
<xsl:text>
</xsl:text>
36
<xsl:text>private:
</xsl:text>
37
<xsl:apply-templates name="Argument" mode="member_vars" select="Arguments/Argument"/>
38
<xsl:text>};

</xsl:text>
42
<xsl:template match="Procedure" mode="macro">
43
<xsl:if test="not(./NoCache)">
44
<xsl:value-of select="concat('#define Cache_', @name, '\
')"/>
45
<xsl:value-of select="string('	if( QGetRenderContext()->pCurrentObject()) \
')"/>
47
QGetRenderContext()->pCurrentObject()->AddCacheCommand( \
49
<xsl:value-of select="concat('new ', @name, 'Cache(')"/>
50
<xsl:apply-templates select="Arguments/Argument" mode="macro_call"/>
51
<xsl:value-of select="string(') ); \
')"/>
52
<xsl:text> return</xsl:text>
53
<xsl:if test="@return != 'RtVoid'">
54
<xsl:text>(0)</xsl:text>
62
<xsl:template name="Constructor">
63
<xsl:value-of select="concat('	', @name, 'Cache(')"/>
64
<xsl:apply-templates select="Arguments/Argument" mode="constructor_sig"/>
65
<xsl:text>) : RiCacheBase()
	{
</xsl:text>
66
<xsl:apply-templates select="Arguments/Argument" mode="constructor_copy"/>
67
<xsl:text>	}
</xsl:text>
70
<xsl:template name="Destructor">
71
<xsl:value-of select="concat('	virtual ~', @name, 'Cache()
	{
')"/>
72
<xsl:apply-templates select="Arguments/Argument" mode="destructor"/>
73
<xsl:text>	}
</xsl:text>
76
<!-- Argument to the cache constructor -->
77
<xsl:template match="Argument" mode="constructor_sig">
79
<xsl:when test="@type = 'PARAMETERLIST'">
80
<xsl:text>RtInt count, RtToken tokens[], RtPointer values[]</xsl:text>
82
<xsl:when test="contains( @type, 'Array')">
83
<xsl:value-of select="concat(substring-before(@type, 'Array'), ' ', @name, '[]')"/>
86
<xsl:value-of select="concat(@type, ' ', @name)"/>
89
<xsl:if test="last() != position()">
90
<xsl:text>, </xsl:text>
94
<!-- Argument copy within the constructor -->
95
<xsl:template match="Argument" mode="constructor_copy">
97
<xsl:when test="@type = 'PARAMETERLIST'">
98
<xsl:text>		// Copy the plist here.
</xsl:text>
99
<xsl:text> int constant_size = 1;
100
int uniform_size = 1;
101
int varying_size = 1;
103
int facevarying_size = 1;
105
<xsl:if test="../../ConstantSize">
106
<xsl:value-of select="../../ConstantSize"/>
108
<xsl:if test="../../UniformSize">
109
<xsl:value-of select="../../UniformSize"/>
111
<xsl:if test="../../VaryingSize">
112
<xsl:value-of select="../../VaryingSize"/>
114
<xsl:if test="../../VertexSize">
115
<xsl:value-of select="../../VertexSize"/>
117
<xsl:if test="../../FaceVaryingSize">
118
<xsl:value-of select="../../FaceVaryingSize"/>
120
<xsl:text> CachePlist(count, tokens, values, constant_size, uniform_size, varying_size, vertex_size, facevarying_size);
</xsl:text>
122
<xsl:when test="contains( @type, 'Array')">
124
<xsl:when test="./Length">
125
<xsl:value-of select="./Length"/>
128
<xsl:text>		// \note: Need to specify the length method here!
</xsl:text>
129
<xsl:value-of select="concat('		int __', @name, '_length = 1;
')"/>
132
<xsl:value-of select="concat('		m_', @name, ' = new ', substring-before(@type, 'Array'), '[__', @name, '_length];
')"/>
133
<xsl:value-of select="concat('		int __', @name, '_index;
')"/>
134
<xsl:value-of select="concat('		for(__', @name, '_index = 0; __', @name, '_index<__', @name, '_length; __', @name, '_index++)
')"/>
135
<xsl:text>		{
</xsl:text>
137
<xsl:when test="@type = 'RtTokenArray' or @type = 'RtStringArray'">
138
<xsl:value-of select="concat('			int __', @name, '_slength = strlen(', @name, '[__', @name, '_index]);
')"/>
139
<xsl:value-of select="concat('			m_', @name, '[__', @name, '_index] = new char[ __', @name, '_slength + 1 ];
')"/>
140
<xsl:value-of select="concat('			strcpy(m_', @name, '[__', @name, '_index], ', @name, '[__', @name, '_index]);
')"/>
142
<xsl:when test="@type = 'RtColorArray' or @type = 'RtPointArray'">
143
<xsl:value-of select="concat('			m_', @name, '[__', @name, '_index][0] = ', @name, '[__', @name, '_index][0];
')"/>
144
<xsl:value-of select="concat('			m_', @name, '[__', @name, '_index][1] = ', @name, '[__', @name, '_index][1];
')"/>
145
<xsl:value-of select="concat('			m_', @name, '[__', @name, '_index][2] = ', @name, '[__', @name, '_index][2];
')"/>
148
<xsl:value-of select="concat('			m_', @name, '[__', @name, '_index] = ', @name, '[__', @name, '_index];
')"/>
151
<xsl:text>		}
</xsl:text>
155
<xsl:when test="@type = 'RtToken' or @type = 'RtString'">
156
<xsl:value-of select="concat('		int __', @name, '_length = strlen(', @name, ');
')"/>
157
<xsl:value-of select="concat('		m_', @name, ' = new char[ __', @name, '_length + 1 ];
')"/>
158
<xsl:value-of select="concat('		strcpy(m_', @name, ', ', @name, ');
')"/>
160
<xsl:when test="@type = 'RtColor' or @type = 'RtPoint'">
161
<xsl:value-of select="concat('		m_', @name, '[0] = ', @name, '[0];
')"/>
162
<xsl:value-of select="concat('		m_', @name, '[1] = ', @name, '[1];
')"/>
163
<xsl:value-of select="concat('		m_', @name, '[2] = ', @name, '[2];
')"/>
165
<xsl:when test="@type = 'RtMatrix' or @type = 'RtBasis'">
166
<xsl:value-of select="concat('		int __', @name, '_i, __', @name, '_j;
')"/>
167
<xsl:value-of select="concat('		for(__', @name, '_j = 0; __', @name, '_j<4; __', @name, '_j++)
')"/>
168
<xsl:value-of select="concat('			for(__', @name, '_i = 0; __', @name, '_i<4; __', @name, '_i++)
')"/>
169
<xsl:value-of select="concat('				m_', @name, '[__', @name, '_j][__', @name, '_i] = ', @name, '[__', @name, '_j][__', @name, '_i];
')"/>
171
<xsl:when test="@type = 'RtBound'">
172
<xsl:value-of select="concat('		m_', @name, '[0] = ', @name, '[0];
')"/>
173
<xsl:value-of select="concat('		m_', @name, '[1] = ', @name, '[1];
')"/>
174
<xsl:value-of select="concat('		m_', @name, '[2] = ', @name, '[2];
')"/>
175
<xsl:value-of select="concat('		m_', @name, '[3] = ', @name, '[3];
')"/>
176
<xsl:value-of select="concat('		m_', @name, '[4] = ', @name, '[4];
')"/>
177
<xsl:value-of select="concat('		m_', @name, '[5] = ', @name, '[5];
')"/>
180
<xsl:value-of select="concat('		m_', @name, ' = ', @name, ';
')"/>
187
<!-- Argument storage members -->
188
<xsl:template match="Argument" mode="member_vars">
189
<xsl:text>	</xsl:text>
191
<xsl:when test="@type = 'PARAMETERLIST'">
192
<xsl:text>// plist information is stored in the base class.</xsl:text>
194
<xsl:when test="contains( @type, 'Array')">
195
<xsl:value-of select="concat(substring-before(@type, 'Array'), '* m_', @name, ';')"/>
198
<xsl:value-of select="concat(@type, ' m_', @name, ';')"/>
201
<xsl:text>
</xsl:text>
204
<!-- Arguments to recall method -->
205
<xsl:template match="Argument" mode="recall_args">
207
<xsl:when test="@type = 'PARAMETERLIST'">
208
<xsl:text>m_count, m_tokens, m_values</xsl:text>
211
<xsl:value-of select="concat('m_', @name)"/>
214
<xsl:if test="last() != position()">
215
<xsl:text>, </xsl:text>
219
<!-- Argument cleanup in the destructor -->
220
<xsl:template match="Argument" mode="destructor">
222
<xsl:when test="@type = 'PARAMETERLIST'">
223
<xsl:text>		// plist gets destroyed by the base class.
</xsl:text>
225
<xsl:when test="contains( @type, 'Array')">
227
<xsl:when test="@type = 'RtTokenArray' or @type = 'RtStringArray'">
228
<xsl:value-of select="concat('		int __', @name, '_length = 1;
')"/>
229
<xsl:value-of select="concat('		int __', @name, '_index;
')"/>
230
<xsl:value-of select="concat('		for(__', @name, '_index = 0; __', @name, '_index<__', @name, '_length; __', @name, '_index++)
')"/>
231
<xsl:text>		{
</xsl:text>
232
<xsl:value-of select="concat('			delete[](m_', @name, '[__', @name, '_index]);
')"/>
233
<xsl:text>		}
</xsl:text>
236
<xsl:value-of select="concat('		delete[](m_', @name, ');
')"/>
240
<xsl:when test="@type = 'RtToken' or @type = 'RtString'">
241
<xsl:value-of select="concat('		delete[](m_', @name, ');
')"/>
249
<!-- Arguments to macro construct method -->
250
<xsl:template match="Argument" mode="macro_call">
252
<xsl:when test="@type = 'PARAMETERLIST'">
253
<xsl:text>count, tokens, values</xsl:text>
256
<xsl:value-of select="@name"/>
259
<xsl:if test="last() != position()">
260
<xsl:text>, </xsl:text>