]> git.cworth.org Git - apitrace/blob - apitrace.xsl
Recognize more array arguments.
[apitrace] / apitrace.xsl
1 <?xml version="1.0"?>
2
3 <!--
4
5 Copyright 2008-2009 VMware, Inc.
6 All Rights Reserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25
26 !-->
27
28 <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
29
30         <xsl:output method="html" />
31
32         <xsl:strip-space elements="*" />
33
34         <xsl:template match="/trace">
35                 <html>
36                         <head>
37                                 <title>D3D Trace</title>
38                         </head>
39                         <style>
40                                 body {
41                                         font-family: verdana, sans-serif;
42                                         font-size: 11px;
43                                         font-weight: normal;
44                                         text-align : left;
45                                 }
46
47                                 ul.calls {
48                                         list-style: none;
49                                         margin-left: 0px;
50                                         padding-left: 0px;
51                                 }
52
53                                 ul.args {
54                                         display:inline;
55                                         list-style: none;
56                                         margin-left: 0px;
57                                         padding-left: 0px;
58                                 }
59
60                                 ul.args li {
61                                         display:inline;
62                                 }
63
64                                 ul.elems {
65                                         list-style: none;
66                                         margin-left: 2em;
67                                         padding-left: 0px;
68                                 }
69
70                                 ul.elems li {
71                                         display:block;
72                                 }
73
74                                 .fun {
75                                         font-weight: bold;
76                                 }
77
78                                 .var {
79                                         font-style: italic;
80                                 }
81
82                                 .typ {
83                                         display: none;
84                                 }
85
86                                 .lit {
87                                         color: #0000ff;
88                                 }
89
90                                 .addr {
91                                         color: #008000;
92                                 }
93
94                                 .ref {
95                                         position: relative;
96                                         cursor: help;
97                                 }
98
99                                 .def {
100                                         display: none;
101                                         position: absolute;
102                                         top: 1.5em;
103                                         left: 0;
104                                         width: 32em;
105                                         background: #f7f7f7;
106                                         cursor: default;
107                                 }
108
109                                 .ref:hover .def {
110                                         display: block;
111                                 }
112                         </style>
113                         <body>
114                                 <ul class="calls">
115                                         <xsl:apply-templates/>
116                                 </ul>
117                         </body>
118                 </html>
119         </xsl:template>
120
121         <xsl:template match="call">
122                 <li>
123                         <span class="fun">
124                                 <xsl:value-of select="@name"/>
125                         </span>
126                         <xsl:text>(</xsl:text>
127                         <ul class="args">
128                                 <xsl:apply-templates select="arg"/>
129                         </ul>
130                         <xsl:text>)</xsl:text>
131                         <xsl:apply-templates select="ret"/>
132                 </li>
133         </xsl:template>
134
135         <xsl:template match="arg|elem">
136                 <li>
137                         <xsl:apply-templates select="@type"/>
138                         <xsl:apply-templates select="@name"/>
139                         <xsl:text> = </xsl:text>
140                         <xsl:call-template name="compound"/>
141                         <xsl:if test="position() != last()">
142                                 <xsl:text>, </xsl:text>
143                         </xsl:if>
144                 </li>
145         </xsl:template>
146
147         <xsl:template match="@type">
148                 <xsl:attribute name="title">
149                         <xsl:value-of select="."/>
150                 </xsl:attribute>
151         </xsl:template>
152
153         <xsl:template match="@name">
154                 <span class="var">
155                         <xsl:value-of select="."/>
156                 </span>
157         </xsl:template>
158
159         <xsl:template match="ret">
160                 <xsl:text> = </xsl:text>
161                 <xsl:call-template name="compound"/>
162         </xsl:template>
163
164         <xsl:template match="ref">
165                 <xsl:choose>
166                         <xsl:when test="elem">
167                                 <span class="ref">
168                                         <xsl:apply-templates select="@addr"/>
169                                         <span class="def">
170                                                 <xsl:call-template name="compound"/>
171                                         </span>
172                                 </span>
173                         </xsl:when>
174                         <xsl:when test="*">
175                                 <xsl:text>&amp;</xsl:text>
176                                 <xsl:apply-templates />
177                         </xsl:when>
178                         <xsl:otherwise>
179                                 <xsl:apply-templates select="@addr"/>
180                         </xsl:otherwise>
181                 </xsl:choose>
182         </xsl:template>
183
184         <xsl:template match="@addr">
185                 <span class="addr">
186                         <xsl:value-of select="."/>
187                 </span>
188         </xsl:template>
189
190         <xsl:template match="text()">
191                 <span class="lit">
192                         <xsl:call-template name="break">
193                                 <xsl:with-param name="text" select="."/>
194                         </xsl:call-template>
195                 </span>
196         </xsl:template>
197
198         <xsl:template name="compound">
199                 <xsl:choose>
200                         <xsl:when test="elem">
201                                 <xsl:text>{</xsl:text>
202                                 <ul class="elems">
203                                         <xsl:apply-templates />
204                                 </ul>
205                                 <xsl:text>}</xsl:text>
206                         </xsl:when>
207                         <xsl:otherwise>
208                                 <xsl:apply-templates />
209                         </xsl:otherwise>
210                 </xsl:choose>
211         </xsl:template>
212
213         <xsl:template name="break">
214                 <xsl:param name="text" select="."/>
215                 <xsl:choose>
216                         <xsl:when test="contains($text, '&#xa;')">
217                                 <xsl:value-of select="substring-before($text, '&#xa;')"/>
218                                 <br/>
219                                 <xsl:call-template name="break">
220                                          <xsl:with-param name="text" select="substring-after($text, '&#xa;')"/>
221                                 </xsl:call-template>
222                         </xsl:when>
223                         <xsl:otherwise>
224                                 <xsl:value-of select="$text"/>
225                         </xsl:otherwise>
226                 </xsl:choose>
227         </xsl:template>
228 </xsl:transform>