forked from dtrebilco/glintercept
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgliIntercept_Basic.xsl
148 lines (107 loc) · 4.16 KB
/
gliIntercept_Basic.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- ========================================================================== -->
<!-- Root info -->
<!-- ========================================================================== -->
<xsl:template match="GLINTERCEPT">
<html>
<xsl:apply-templates select="HEADER"/>
<xsl:apply-templates select="FUNCTIONS"/>
</html>
</xsl:template>
<!-- ========================================================================== -->
<!-- Header info -->
<!-- ========================================================================== -->
<xsl:template match="HEADER">
<head><title>GL Intercept version <xsl:apply-templates select="VERSION"/> Run on <xsl:apply-templates select="TIMESTAMP"/></title></head>
</xsl:template>
<xsl:template match="VERSION">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="TIMESTAMP">
<xsl:apply-templates/>
</xsl:template>
<!-- ========================================================================== -->
<!-- Function info -->
<!-- ========================================================================== -->
<xsl:template match="FUNCTIONS">
<body><xsl:apply-templates select="FUNCTION"/></body>
</xsl:template>
<!-- Main function template -->
<xsl:template name="MainFunction">
<xsl:apply-templates select="NAME"/>
<!-- If this function has no parameters- it is unknown -->
(<xsl:choose>
<xsl:when test="count(child::PARAM) > 0">
<xsl:apply-templates select="PARAM"/>
</xsl:when>
<xsl:otherwise>???</xsl:otherwise>
</xsl:choose>)
<!-- Apply the return code -->
<xsl:apply-templates select="RETURN"/>
<!-- Apply any error codes -->
<xsl:apply-templates select="ERROR"/>
<!-- Apply any optional text -->
<xsl:apply-templates select="TEXT"/>
<!-- Apply any optional debug info -->
<xsl:apply-templates select="DEBUG"/>
<!-- Recursive call -->
<xsl:apply-templates select="FUNCTION"/>
</xsl:template>
<!-- Single function -->
<xsl:template match="FUNCTIONS/FUNCTION">
<br/><xsl:call-template name="MainFunction"/>
</xsl:template>
<!-- Function called from a function -->
<xsl:template match="FUNCTION/FUNCTION">
<br/><b><xsl:text>-----> </xsl:text></b><xsl:call-template name="MainFunction"/>
</xsl:template>
<xsl:template match="NAME">
<xsl:apply-templates/>
</xsl:template>
<!-- ========================================================================== -->
<!-- Parameter processing -->
<!-- ========================================================================== -->
<xsl:template match="PARAM">
<!-- Choose between an array of values and 1 value -->
<xsl:choose>
<xsl:when test="count(child::VALUE) = 1">
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="count(child::VALUE) > 1">
[<xsl:apply-templates/>]
</xsl:when>
</xsl:choose>
<!-- Add a comma -->
<xsl:if test="position() != last()">,</xsl:if>
</xsl:template>
<xsl:template match="VALUE">
<!-- Select the data -->
<xsl:value-of select="@data"/>
<!-- Add a comma -->
<xsl:if test="position() != last()">,</xsl:if>
</xsl:template>
<!-- ========================================================================== -->
<!-- Return processing -->
<!-- ========================================================================== -->
<xsl:template match="RETURN">
= <xsl:apply-templates select="VALUE"/>
</xsl:template>
<!-- ========================================================================== -->
<!-- Error processing -->
<!-- ========================================================================== -->
<xsl:template match="ERROR">
glGetError() = <xsl:apply-templates select="VALUE"/>
</xsl:template>
<!-- ========================================================================== -->
<!-- Text processing -->
<!-- ========================================================================== -->
<xsl:template match="TEXT">
<xsl:apply-templates/>
</xsl:template>
<!-- ========================================================================== -->
<!-- Debug processing -->
<!-- ========================================================================== -->
<xsl:template match="DEBUG">
<br/><xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>