jvmtiLib.xsl revision 0:a61af66fc99e
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3
4 Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
5 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
7 This code is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License version 2 only, as
9 published by the Free Software Foundation.
10
11 This code is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 version 2 for more details (a copy is included in the LICENSE file that
15 accompanied this code).
16
17 You should have received a copy of the GNU General Public License version
18 2 along with this work; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 CA 95054 USA or visit www.sun.com if you need additional information or
23 have any questions.
24  
25-->
26
27<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
28                version="1.0">
29
30  <xsl:template name="microversion">
31    <xsl:value-of select="//specification/@microversion"/>
32  </xsl:template>
33
34  <xsl:template name="showbasicversion">
35    <xsl:value-of select="//specification/@majorversion"/>
36    <xsl:text>.</xsl:text>
37    <xsl:value-of select="//specification/@minorversion"/>
38  </xsl:template>
39
40  <xsl:template name="showversion">
41    <xsl:call-template name="showbasicversion"/>
42    <xsl:text>.</xsl:text>
43    <xsl:call-template name="microversion"/>
44  </xsl:template>
45
46  <xsl:template name="copyrightComment">
47    <xsl:text>/* </xsl:text>
48    <!-- Copy the Copyright comment from jvmti.xml -->
49    <xsl:value-of select="/comment()[position()=1]"/>
50    <xsl:text> */ &#xA;&#xA;</xsl:text>
51  </xsl:template>
52
53  <xsl:template name="includeHeader">
54    <xsl:call-template name="copyrightComment"/>
55    <xsl:text> /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ &#xA;</xsl:text>    
56  </xsl:template>
57
58  <xsl:template name="sourceHeader">
59    <xsl:call-template name="copyrightComment"/>
60    <xsl:text> // AUTOMATICALLY GENERATED FILE - DO NOT EDIT &#xA;</xsl:text>    
61  </xsl:template>
62
63
64<xsl:template match="parameters" mode="signature">
65  <xsl:param name="comma">
66    <xsl:text>,
67            </xsl:text>
68  </xsl:param>
69  <xsl:if test="count(param) != 0">
70    <xsl:value-of select="$comma"/>
71  </xsl:if>
72  <xsl:apply-templates select="." mode="signaturenoleadcomma">
73    <xsl:with-param name="comma" select="$comma"/>
74  </xsl:apply-templates>
75</xsl:template>
76
77
78<xsl:template match="parameters" mode="signaturenoleadcomma">
79  <xsl:param name="comma">
80    <xsl:text>,
81            </xsl:text>
82  </xsl:param>
83  <xsl:variable name="length" select="count(param)"/>
84  <xsl:for-each select="param">
85    <xsl:variable name="separator">
86        <xsl:choose>
87          <xsl:when test="position()=$length">
88            <xsl:text></xsl:text>
89          </xsl:when>
90          <xsl:otherwise>
91            <xsl:value-of select="$comma"/>
92          </xsl:otherwise>
93        </xsl:choose>
94    </xsl:variable>
95    <xsl:apply-templates select="." mode="signature">
96      <xsl:with-param name="comma" select="$separator"/>
97    </xsl:apply-templates>
98  </xsl:for-each>
99</xsl:template>
100
101
102<!-- remove jclass parameters that are jclass/jmethodID pairs.
103     since the jclass was removed in JVMTI.
104-->
105<xsl:template match="param" mode="signature">
106  <xsl:param name="comma"/>
107  <xsl:variable name="id" select="@id"/>
108  <xsl:for-each select="child::*[position()=1]">
109    <xsl:if test="count(@method)=0">
110      <xsl:apply-templates select="." mode="signature"/>
111      <xsl:text> </xsl:text>
112      <xsl:value-of select="$id"/>
113      <xsl:value-of select="$comma"/>
114    </xsl:if>
115  </xsl:for-each>
116</xsl:template>
117
118
119<xsl:template match="field" mode="signature">
120  <xsl:text>    </xsl:text>
121  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
122  <xsl:text> </xsl:text>
123  <xsl:value-of select="@id"/>
124  <xsl:text>;
125</xsl:text>
126</xsl:template>
127
128<xsl:template match="nullok" mode="funcdescription">
129  If
130  <code>
131    <xsl:value-of select="../../@id"/>
132  </code>
133  is
134  <code>NULL</code>, <xsl:apply-templates/>.
135</xsl:template>
136
137<xsl:template match="vmbuf|allocfieldbuf|struct" mode="funcdescription">
138  <xsl:message terminate="yes">
139    vmbuf|allocfieldbuf|struct as type of function parameter
140  </xsl:message>
141</xsl:template>
142
143<xsl:template match="ptrtype" mode="funcdescription">
144  <p/>
145  <xsl:apply-templates select="nullok" mode="funcdescription"/>
146</xsl:template>
147
148<xsl:template match="inptr" mode="funcdescription">
149  <p/>
150  <xsl:variable name="child" select="child::*[position()=1]"/>
151  <xsl:text>Agent passes in a pointer</xsl:text>
152  <xsl:if test="name($child)!='void'">
153    <xsl:text> to </xsl:text>
154    <code>
155      <xsl:apply-templates select="$child" mode="signature"/> 
156    </code>
157  </xsl:if>
158  <xsl:text>. </xsl:text>
159  <xsl:apply-templates select="nullok" mode="funcdescription"/>
160</xsl:template>
161
162<xsl:template match="inbuf" mode="funcdescription">
163  <p/>
164  <xsl:variable name="child" select="child::*[position()=1]"/>
165  <xsl:text>Agent passes in </xsl:text>
166  <xsl:choose>
167    <xsl:when test="name($child)='void'">
168      <xsl:text> a pointer</xsl:text>
169    </xsl:when>
170    <xsl:otherwise>
171      <xsl:text> an array of </xsl:text>
172      <xsl:if test="count(@incount)=1 and @incount!=''">
173        <code>
174          <xsl:value-of select="@incount"/>
175        </code>
176        <xsl:text> elements of </xsl:text>
177      </xsl:if>
178      <code>
179        <xsl:apply-templates select="$child" mode="signature"/> 
180      </code>
181    </xsl:otherwise>
182  </xsl:choose>
183  <xsl:text>. </xsl:text>
184  <xsl:apply-templates select="nullok" mode="funcdescription"/>
185</xsl:template>
186
187<xsl:template match="outptr" mode="funcdescription">
188  <p/>
189  <xsl:text>Agent passes a pointer to a </xsl:text>
190  <code>
191    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
192  </code>
193  <xsl:text>. </xsl:text>
194  <xsl:text>On return, the </xsl:text>
195  <code>
196    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
197  </code>
198  <xsl:text> has been set. </xsl:text>
199  <xsl:apply-templates select="nullok" mode="funcdescription"/>
200  <xsl:apply-templates select="child::*[position()=1]" mode="returndescription"/>
201</xsl:template>
202
203<xsl:template match="allocbuf" mode="funcdescription">
204  <p/>
205  <xsl:text>Agent passes a pointer to a </xsl:text>
206  <code>
207    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
208    <xsl:text>*</xsl:text>
209  </code>
210  <xsl:text>. </xsl:text>
211  <xsl:text>On return, the </xsl:text>
212  <code>
213    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
214    <xsl:text>*</xsl:text>
215  </code>
216  <xsl:text> points to a newly allocated array</xsl:text>
217  <xsl:choose>
218    <xsl:when test="count(@outcount)=1 and @outcount!=''">
219      <xsl:text> of size </xsl:text>
220      <code>
221        <xsl:text>*</xsl:text>
222        <xsl:value-of select="@outcount"/>
223      </code>
224    </xsl:when>
225    <xsl:otherwise>
226      <xsl:if test="count(@incount)=1 and @incount!=''">
227        <xsl:text> of size </xsl:text>
228        <code>
229          <xsl:value-of select="@incount"/>
230        </code>
231      </xsl:if>
232    </xsl:otherwise>
233  </xsl:choose>
234  <xsl:text>.  The array should be freed with </xsl:text>
235  <a href="#Deallocate"><code>Deallocate</code></a>
236  <xsl:text>. </xsl:text>
237  <xsl:apply-templates select="nullok" mode="funcdescription"/>
238  <xsl:apply-templates select="child::*[position()=1]" mode="returndescription">
239    <xsl:with-param name="plural" select="'plural'"/>
240  </xsl:apply-templates>
241</xsl:template>
242
243<xsl:template match="allocallocbuf" mode="funcdescription">
244  <p/>
245  <xsl:text>Agent passes a pointer to a </xsl:text>
246  <code>
247    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
248    <xsl:text>**</xsl:text>
249  </code>
250  <xsl:text>. </xsl:text>
251  <xsl:text>On return, the </xsl:text>
252  <code>
253    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
254    <xsl:text>**</xsl:text>
255  </code>
256  <xsl:text> points to a newly allocated array</xsl:text>
257  <xsl:choose>
258    <xsl:when test="count(@outcount)=1 and @outcount!=''">
259      <xsl:text> of size </xsl:text>
260      <code>
261        <xsl:text>*</xsl:text>
262        <xsl:value-of select="@outcount"/>
263      </code>
264    </xsl:when>
265    <xsl:otherwise>
266      <xsl:if test="count(@incount)=1 and @incount!=''">
267        <xsl:text> of size </xsl:text>
268        <code>
269          <xsl:value-of select="@incount"/>
270        </code>
271      </xsl:if>
272    </xsl:otherwise>
273  </xsl:choose>
274  <xsl:text>, each element of which is also newly allocated.
275  The array should be freed with </xsl:text>
276  <a href="#Deallocate"><code>Deallocate</code></a>
277  <xsl:text>. 
278  Each of the elements should be freed with </xsl:text>
279  <a href="#Deallocate"><code>Deallocate</code></a>
280  <xsl:text>. </xsl:text>
281  <xsl:apply-templates select="nullok" mode="funcdescription"/>
282  <xsl:apply-templates select="child::*[position()=1]" mode="returndescription">
283    <xsl:with-param name="plural" select="'plural'"/>
284  </xsl:apply-templates>
285</xsl:template>
286
287<xsl:template match="outbuf" mode="funcdescription">
288  <p/>
289  <xsl:text>Agent passes an array </xsl:text>
290  <xsl:if test="count(@incount)=1 and @incount!=''">
291    <xsl:text>large enough to hold </xsl:text>
292    <code>
293      <xsl:value-of select="@incount"/>
294    </code>
295    <xsl:text> elements </xsl:text>
296  </xsl:if>
297  <xsl:text>of </xsl:text>
298  <code>
299    <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 
300  </code>
301  <xsl:text>. The incoming values of the elements of the array are ignored. </xsl:text>
302  <xsl:text>On return, </xsl:text>
303  <xsl:if test="count(@outcount)=1 and @outcount!=''">
304    <code>
305      <xsl:text>*</xsl:text>
306      <xsl:value-of select="@outcount"/>
307    </code>
308    <xsl:text> of </xsl:text>
309  </xsl:if>
310  <xsl:text>the elements are set. </xsl:text>
311  <xsl:apply-templates select="nullok" mode="funcdescription"/>
312  <xsl:apply-templates select="child::*[position()=1]" mode="returndescription">
313    <xsl:with-param name="plural" select="'plural'"/>
314  </xsl:apply-templates>
315</xsl:template>
316
317<xsl:template match="agentbuf" mode="funcdescription">
318  <p/>
319  <xsl:apply-templates select="nullok" mode="funcdescription"/>
320  <xsl:apply-templates select="child::*[position()=1]" mode="returndescription">
321    <xsl:with-param name="plural" select="'plural'"/>
322  </xsl:apply-templates>
323</xsl:template>
324
325<xsl:template match="jmethodID|jfieldID|jframeID|jrawMonitorID|jclass|jobject|jvalue|jthreadGroup|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|varargs|struct" mode="funcdescription">
326</xsl:template>
327
328<xsl:template match="jthread" mode="funcdescription">
329  <xsl:if test="count(@null)!=0">
330    If
331    <code>
332      <xsl:value-of select="../@id"/>
333    </code>
334    is
335    <code>NULL</code>, the current thread is used.
336  </xsl:if>
337</xsl:template>
338
339<xsl:template match="jmethodID|jfieldID|jframeID|jrawMonitorID|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|varargs" mode="returndescription">
340</xsl:template>
341
342<xsl:template match="struct" mode="returndescription">
343  <xsl:param name="plural"/>
344  <xsl:variable name="structname" select="."/>
345  <xsl:for-each select="//typedef[@id=$structname]|//uniontypedef[@id=$structname]">
346    <xsl:for-each select="field">
347      <xsl:apply-templates select="child::*[position()=1]" mode="fieldreturndescription">
348        <xsl:with-param name="plural" select="$plural"/>
349      </xsl:apply-templates>
350    </xsl:for-each>
351  </xsl:for-each>
352</xsl:template>
353
354<xsl:template match="jclass|jthread|jobject|jvalue|jthreadGroup" mode="returndescription">
355  <xsl:param name="plural"/>
356  <xsl:text>The object</xsl:text>
357  <xsl:if test="$plural='plural'">
358    <xsl:text>s</xsl:text>
359  </xsl:if>
360  <xsl:text> returned by </xsl:text>
361  <code>
362    <xsl:value-of select="../../@id"/>
363  </code>
364  <xsl:choose>    
365    <xsl:when test="$plural='plural'">
366      <xsl:text> are JNI local references and must be </xsl:text>
367    </xsl:when>
368    <xsl:otherwise>
369      <xsl:text> is a JNI local reference and must be </xsl:text>
370    </xsl:otherwise>
371  </xsl:choose>
372  <a href="#refs">managed</a>.
373</xsl:template>
374
375<xsl:template match="outptr|inptr|inbuf|agentbuf|allocbuf|allocallocbuf" mode="fieldreturndescription">
376  <xsl:variable name="field" select="ancestor::field"/>
377  <xsl:message terminate="yes">
378    outptr, allocallocbuf, outbuf, vmbuf, allocbuf, inptr, inbuf or agentbuf as type of returned field:
379    <xsl:value-of select="$field/@id"/> of <xsl:value-of select="$field/../@id"/>
380  </xsl:message>
381</xsl:template>
382
383<xsl:template match="outbuf" mode="fieldreturndescription">
384  <!-- hand document this special case.
385  -->
386</xsl:template>
387
388<xsl:template match="struct" mode="fieldreturndescription">
389  <xsl:param name="plural"/>
390  <xsl:variable name="structname" select="."/>
391  <xsl:for-each select="//typedef[@id=$structname]|//uniontypedef[@id=$structname]">
392    <xsl:for-each select="field">
393      <xsl:apply-templates select="child::*[position()=1]" mode="fieldreturndescription">
394        <xsl:with-param name="plural" select="$plural"/>
395      </xsl:apply-templates>
396    </xsl:for-each>
397  </xsl:for-each>
398</xsl:template>
399
400<xsl:template match="allocfieldbuf" mode="fieldreturndescription">
401  <xsl:param name="plural"/>
402  <xsl:variable name="field" select="ancestor::field"/>
403  <xsl:text>The pointer</xsl:text>
404  <xsl:if test="$plural='plural'">
405    <xsl:text>s</xsl:text>
406  </xsl:if>
407  <xsl:text> returned in the field </xsl:text>
408  <code>
409    <xsl:value-of select="$field/@id"/>
410  </code>
411  <xsl:text> of </xsl:text>
412  <code>
413    <xsl:value-of select="$field/../@id"/>
414  </code>
415  <xsl:choose>    
416    <xsl:when test="$plural='plural'">
417      <xsl:text> are newly allocated arrays. The arrays</xsl:text>
418    </xsl:when>
419    <xsl:otherwise>
420      <xsl:text> is a newly allocated array. The array</xsl:text>
421    </xsl:otherwise>
422  </xsl:choose>
423  <xsl:text> should be freed with </xsl:text>
424  <a href="#Deallocate"><code>Deallocate</code></a>
425  <xsl:text>. </xsl:text>
426
427  <xsl:apply-templates select="child::*[position()=1]" mode="fieldreturndescription">
428    <xsl:with-param name="plural" select="'plural'"/>
429  </xsl:apply-templates>
430</xsl:template>
431
432<xsl:template match="ptrtype|vmbuf|jmethodID|jfieldID|jframeID|jrawMonitorID|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void" mode="fieldreturndescription">
433</xsl:template>
434
435<xsl:template match="jclass|jthread|jobject|jvalue|jthreadGroup" mode="fieldreturndescription">
436  <xsl:param name="plural"/>
437  <xsl:variable name="field" select="ancestor::field"/>
438  <xsl:text>The object</xsl:text>
439  <xsl:if test="$plural='plural'">
440    <xsl:text>s</xsl:text>
441  </xsl:if>
442  <xsl:text> returned in the field </xsl:text>
443  <code>
444    <xsl:value-of select="$field/@id"/>
445  </code>
446  <xsl:text> of </xsl:text>
447  <code>
448    <xsl:value-of select="$field/../@id"/>
449  </code>
450  <xsl:choose>    
451    <xsl:when test="$plural='plural'">
452      <xsl:text> are JNI local references and must be </xsl:text>
453    </xsl:when>
454    <xsl:otherwise>
455      <xsl:text> is a JNI local reference and must be </xsl:text>
456    </xsl:otherwise>
457  </xsl:choose>
458  <a href="#refs">managed</a>.
459</xsl:template>
460
461<xsl:template match="nullok" mode="signature">
462</xsl:template>
463
464<xsl:template match="jmethodID|jfieldID|jrawMonitorID|jclass|jthread|jobject|jvalue|jthreadGroup|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|size_t|void" mode="signature">
465  <xsl:value-of select="name()"/>
466</xsl:template>
467
468<xsl:template match="jframeID" mode="signature">
469  <xsl:text>jint</xsl:text>
470</xsl:template>
471
472<xsl:template match="uchar" mode="signature">
473  <xsl:text>unsigned char</xsl:text>
474</xsl:template>
475
476<xsl:template match="enum|struct" mode="signature">
477  <xsl:value-of select="."/>
478</xsl:template>
479
480<xsl:template match="varargs" mode="signature">
481</xsl:template>
482
483<xsl:template match="outptr|outbuf|allocfieldbuf" mode="signature">
484  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
485  <xsl:text>*</xsl:text>
486</xsl:template>
487
488<xsl:template match="ptrtype" mode="signature">
489  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
490</xsl:template>
491
492<xsl:template match="inptr|inbuf|vmbuf" mode="signature">
493  <xsl:text>const </xsl:text>
494  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
495  <xsl:text>*</xsl:text>
496</xsl:template>
497
498<xsl:template match="allocbuf|agentbuf" mode="signature">
499  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
500  <xsl:text>**</xsl:text>
501</xsl:template>
502
503<xsl:template match="allocallocbuf" mode="signature">
504  <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
505  <xsl:text>***</xsl:text>
506</xsl:template>
507
508<xsl:template match="nullok" mode="link">
509</xsl:template>
510
511<xsl:template match="jmethodID|jfieldID|jrawMonitorID|jclass|jthread|jobject|jvalue|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|jthreadGroup" mode="link">
512  <a>
513    <xsl:attribute name="href">
514      <xsl:text>#</xsl:text><xsl:value-of select="name()"/>
515    </xsl:attribute>
516    <xsl:value-of select="name()"/>
517  </a>
518</xsl:template>
519
520<xsl:template match="jframeID" mode="link">
521  <a>
522    <xsl:attribute name="href">
523      <xsl:text>#jint</xsl:text>
524    </xsl:attribute>
525    <xsl:text>jint</xsl:text>
526  </a>
527</xsl:template>
528
529<xsl:template match="enum|struct" mode="link">
530  <a>
531    <xsl:attribute name="href">
532      <xsl:text>#</xsl:text>
533      <xsl:value-of select="."/>
534    </xsl:attribute>
535    <xsl:value-of select="."/>
536  </a>
537</xsl:template>
538
539<xsl:template match="char|size_t|void" mode="link">
540    <xsl:value-of select="name()"/>
541</xsl:template>
542
543<xsl:template match="uchar" mode="link">
544    <xsl:text>unsigned char</xsl:text>
545</xsl:template>
546
547<xsl:template match="varargs" mode="link">
548  <xsl:text>...</xsl:text>
549</xsl:template>
550
551<xsl:template match="ptrtype" mode="link">
552  <xsl:apply-templates mode="link"/>
553</xsl:template>
554
555<xsl:template match="outptr|outbuf|allocfieldbuf" mode="link">
556  <xsl:apply-templates mode="link"/>
557  <xsl:text>*</xsl:text>
558</xsl:template>
559
560<xsl:template match="inptr|inbuf|vmbuf" mode="link">
561  <xsl:text>const </xsl:text>
562  <xsl:apply-templates mode="link"/>
563  <xsl:text>*</xsl:text>
564</xsl:template>
565
566<xsl:template match="allocbuf|agentbuf" mode="link">
567  <xsl:apply-templates mode="link"/>
568  <xsl:text>**</xsl:text>
569</xsl:template>
570
571<xsl:template match="allocallocbuf" mode="link">
572  <xsl:apply-templates mode="link"/>
573  <xsl:text>***</xsl:text>
574</xsl:template>
575
576<xsl:template match="jmethodID|jfieldID|jframeID|jrawMonitorID|jclass|jobject|jvalue|jthreadGroup|jthread|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|size_t|void" mode="btsig">
577  <xsl:value-of select="name()"/>
578</xsl:template>
579
580<xsl:template match="uchar" mode="btsig">
581  <xsl:text>unsigned char</xsl:text>
582</xsl:template>
583
584<xsl:template match="enum|struct" mode="btsig">
585  <xsl:value-of select="."/>
586</xsl:template>
587
588<xsl:template match="outbuf" mode="btsig">
589  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
590  <xsl:text>*</xsl:text>
591</xsl:template>
592
593<xsl:template name="gentypedef">
594  <xsl:param name="tdef"/>
595  <xsl:text>typedef struct {
596</xsl:text>
597<xsl:apply-templates select="$tdef/field" mode="signature"/>
598  <xsl:text>} </xsl:text>
599  <xsl:value-of select="$tdef/@id"/>
600  <xsl:text>;</xsl:text>
601</xsl:template>
602
603<xsl:template name="genuniontypedef">
604  <xsl:param name="tdef"/>
605  <xsl:text>typedef union {
606</xsl:text>
607<xsl:apply-templates select="$tdef/field" mode="signature"/>
608  <xsl:text>} </xsl:text>
609  <xsl:value-of select="$tdef/@id"/>
610  <xsl:text>;</xsl:text>
611</xsl:template>
612
613
614<xsl:template match="capabilitiestypedef" mode="genstruct">
615  <xsl:variable name="caps" select="count(capabilityfield)"/>
616  <xsl:text>typedef struct {
617</xsl:text>
618  <xsl:apply-templates select="capabilityfield" mode="signature"/>
619  <xsl:variable name="rem" select="$caps mod 16"/>
620  <xsl:if test="$rem != 0">
621    <xsl:text>    unsigned int : </xsl:text>
622    <xsl:value-of select="16 - $rem"/>
623    <xsl:text>;
624</xsl:text>
625  </xsl:if>
626  <xsl:if test="$caps &lt;= 32">
627    <xsl:text>    unsigned int : 16;
628</xsl:text>
629  </xsl:if>
630  <xsl:if test="$caps &lt;= 48">
631    <xsl:text>    unsigned int : 16;
632</xsl:text>
633  </xsl:if>
634  <xsl:if test="$caps &lt;= 64">
635    <xsl:text>    unsigned int : 16;
636</xsl:text>
637  </xsl:if>
638  <xsl:if test="$caps &lt;= 80">
639    <xsl:text>    unsigned int : 16;
640</xsl:text>
641  </xsl:if>
642  <xsl:if test="$caps &lt;= 96">
643    <xsl:text>    unsigned int : 16;
644</xsl:text>
645  </xsl:if>
646  <xsl:if test="$caps &lt;= 112">
647    <xsl:text>    unsigned int : 16;
648</xsl:text>
649  </xsl:if>
650  <xsl:text>} </xsl:text>
651  <xsl:value-of select="@id"/>
652  <xsl:text>;</xsl:text>
653</xsl:template>
654
655<xsl:template match="capabilityfield" mode="signature">
656  <xsl:text>    unsigned int </xsl:text>
657  <xsl:value-of select="@id"/>
658  <xsl:text> : 1;
659</xsl:text>
660</xsl:template>
661
662<xsl:template match="constants" mode="enum">
663  <xsl:text>
664typedef </xsl:text>
665  <xsl:apply-templates select="." mode="enumcore"/>
666  <xsl:text> </xsl:text>
667  <xsl:value-of select="@id"/>
668  <xsl:text>;</xsl:text>
669</xsl:template>
670
671<xsl:template match="constants" mode="constants">
672  <xsl:text>
673</xsl:text>
674  <xsl:apply-templates select="." mode="enumcore"/>
675  <xsl:text>;</xsl:text>
676</xsl:template>
677
678<xsl:template match="constants" mode="enumcore">
679  <xsl:text>enum {
680</xsl:text>
681  <xsl:for-each select="constant">
682    <xsl:if test="position() &gt; 1">
683      <xsl:text>,
684</xsl:text>
685    </xsl:if>
686    <xsl:apply-templates select="." mode="enum"/>
687  </xsl:for-each>
688  <xsl:text>
689}</xsl:text>
690</xsl:template>
691
692<xsl:template match="event" mode="enum">
693  <xsl:text>    </xsl:text>
694  <xsl:value-of select="@const"/>
695  <xsl:text> = </xsl:text>
696  <xsl:value-of select="@num"/>
697</xsl:template>
698
699<xsl:template match="constant|errorid" mode="enum">
700  <xsl:text>    </xsl:text>
701  <xsl:value-of select="@id"/>
702  <xsl:text> = </xsl:text>
703  <xsl:value-of select="@num"/>
704</xsl:template>
705
706
707  <xsl:template name="eventStruct">
708    <xsl:param name="events"/>
709    <xsl:param name="index"/>
710    <xsl:param name="started"/>
711    <xsl:param name="comment"/>
712    <xsl:variable name="thisEvent" select="$events[@num=$index]"/>
713    <xsl:choose>
714      <xsl:when test="count($thisEvent)=1">
715        <xsl:if test="$comment='Yes'">
716          <xsl:text>                              /* </xsl:text>
717          <xsl:number value="$index" format="  1"/>
718          <xsl:text> : </xsl:text>
719          <xsl:value-of select="$thisEvent/@label"/>
720          <xsl:text> */
721</xsl:text>
722        </xsl:if>
723        <xsl:text>    jvmtiEvent</xsl:text>
724        <xsl:value-of select="$thisEvent/@id"/>
725        <xsl:text> </xsl:text>
726        <xsl:value-of select="$thisEvent/@id"/>
727        <xsl:text>;
728</xsl:text>
729    </xsl:when>
730    <xsl:otherwise>
731      <xsl:if test="$started">
732        <xsl:if test="$comment='Yes'">
733          <xsl:text>                              /* </xsl:text>
734          <xsl:number value="$index" format="  1"/>
735          <xsl:text> */
736</xsl:text>
737        </xsl:if>
738        <xsl:text>    jvmtiEventReserved reserved</xsl:text>        
739        <xsl:value-of select="$index"/>
740        <xsl:text>;
741</xsl:text>     
742    </xsl:if>
743  </xsl:otherwise>
744</xsl:choose>
745    <xsl:if test="count($events[@num &gt; $index]) &gt; 0">
746      <xsl:call-template name="eventStruct">
747        <xsl:with-param name="events" select="$events"/>
748        <xsl:with-param name="index" select="1+$index"/>
749        <xsl:with-param name="started" select="$started or count($thisEvent)=1"/>
750        <xsl:with-param name="comment" select="$comment"/>
751      </xsl:call-template>
752    </xsl:if>
753  </xsl:template>
754
755
756<!-- ======== HotSpotType ======== -->
757
758<xsl:template match="parameters" mode="HotSpotSig">
759  <xsl:variable name="length" select="count(param)"/>
760  <xsl:for-each select="param">
761    <xsl:variable name="separator">
762        <xsl:choose>
763          <xsl:when test="position()=$length">
764            <xsl:text></xsl:text>
765          </xsl:when>
766          <xsl:otherwise>
767            <xsl:text>, </xsl:text>
768          </xsl:otherwise>
769        </xsl:choose>
770    </xsl:variable>
771    <xsl:apply-templates select="." mode="HotSpotSig">
772      <xsl:with-param name="comma" select="$separator"/>
773    </xsl:apply-templates>
774  </xsl:for-each>
775</xsl:template>
776
777<xsl:template match="param" mode="HotSpotSig">
778  <xsl:param name="comma"/>
779  <xsl:variable name="result">
780    <xsl:apply-templates select="child::*[position()=1]" mode="HotSpotType"/>
781  </xsl:variable>
782  <xsl:if test="string-length($result)!=0">
783    <xsl:value-of select="$result"/>
784    <xsl:text> </xsl:text>
785    <xsl:apply-templates select="child::*[position()=1]" mode="HotSpotName">
786      <xsl:with-param name="name" select="@id"/>
787    </xsl:apply-templates>
788    <xsl:value-of select="$comma"/>    
789  </xsl:if>
790</xsl:template>
791
792<xsl:template match="jthread" mode="HotSpotType">
793  <xsl:choose>
794    <xsl:when test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
795      <xsl:text>JavaThread*</xsl:text>
796    </xsl:when>
797    <xsl:otherwise>
798      <xsl:value-of select="name()"/>
799    </xsl:otherwise>
800  </xsl:choose>
801</xsl:template>
802
803<xsl:template match="jrawMonitorID" mode="HotSpotType">
804  <xsl:text>JvmtiRawMonitor *</xsl:text>
805</xsl:template>
806
807<xsl:template match="jframeID" mode="HotSpotType">
808  <xsl:text>jint</xsl:text>
809</xsl:template>
810
811<xsl:template match="jmethodID" mode="HotSpotType">
812  <xsl:text>methodOop</xsl:text>
813</xsl:template>
814
815<xsl:template match="jfieldID" mode="HotSpotType">
816  <xsl:text>fieldDescriptor*</xsl:text>
817</xsl:template>
818
819<xsl:template match="jclass" mode="HotSpotType">
820  <!--
821    classes passed as part of a class/method or class/field pair are used
822    by the wrapper to get the internal type but are not needed by nor 
823    passed to the implementation layer.
824  -->
825  <xsl:if test="count(@method|@field)=0">
826    <xsl:text>oop</xsl:text>
827  </xsl:if>
828</xsl:template>
829
830<xsl:template match="nullok" mode="HotSpotType">
831</xsl:template>
832
833<xsl:template match="jobject|jvalue|jthreadGroup|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|struct" mode="HotSpotType">
834  <xsl:apply-templates select="." mode="btsig"/>
835</xsl:template>
836
837<xsl:template match="varargs" mode="HotSpotType">
838  <xsl:text> </xsl:text>
839</xsl:template>
840
841<xsl:template match="outptr|outbuf|allocfieldbuf" mode="HotSpotType">
842  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
843  <xsl:text>*</xsl:text>
844</xsl:template>
845
846<xsl:template match="ptrtype" mode="HotSpotType">
847  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
848</xsl:template>
849
850<xsl:template match="inptr|inbuf|vmbuf" mode="HotSpotType">
851  <xsl:text>const </xsl:text>
852  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
853  <xsl:text>*</xsl:text>
854</xsl:template>
855
856<xsl:template match="allocbuf|agentbuf" mode="HotSpotType">
857  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
858  <xsl:text>**</xsl:text>
859</xsl:template>
860
861<xsl:template match="allocallocbuf" mode="HotSpotType">
862  <xsl:apply-templates select="child::*[position()=1]" mode="btsig"/>
863  <xsl:text>***</xsl:text>
864</xsl:template>
865
866<!-- ========  HotSpotName ======== -->
867
868<xsl:template match="jthread" mode="HotSpotName">
869  <xsl:param name="name"/>
870  <xsl:choose>
871    <xsl:when test="count(@impl)=0 or not(contains(@impl,'noconvert'))">
872      <xsl:text>java_thread</xsl:text>
873    </xsl:when>
874    <xsl:otherwise>
875      <xsl:value-of select="$name"/>
876    </xsl:otherwise>
877  </xsl:choose>
878</xsl:template>
879
880<xsl:template match="jrawMonitorID" mode="HotSpotName">
881  <xsl:text>rmonitor</xsl:text>
882</xsl:template>
883
884<xsl:template match="jframeID" mode="HotSpotName">
885  <xsl:text>depth</xsl:text>
886</xsl:template>
887
888<xsl:template match="jmethodID" mode="HotSpotName">
889  <xsl:text>method_oop</xsl:text>
890</xsl:template>
891
892<xsl:template match="jfieldID" mode="HotSpotName">
893  <xsl:text>fdesc_ptr</xsl:text>
894</xsl:template>
895
896<xsl:template match="jclass" mode="HotSpotName">
897  <!--
898    classes passed as part of a class/method or class/field pair are used
899    by the wrapper to get the internal type but are not needed by nor 
900    passed to the implementation layer.  This value is checked for empty.
901  -->
902  <xsl:if test="count(@method|@field)=0">
903    <xsl:text>k_mirror</xsl:text>
904  </xsl:if>
905</xsl:template>
906
907<xsl:template match="nullok" mode="HotSpotName">
908</xsl:template>
909
910<xsl:template match="jobject|jvalue|jthreadGroup|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|varargs|struct|outptr|outbuf|allocfieldbuf|ptrtype|inptr|inbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="HotSpotName">
911  <xsl:param name="name"/>
912  <xsl:value-of select="$name"/>
913</xsl:template>
914
915<!-- ======== HotSpotValue ======== -->
916
917
918<xsl:template match="parameters" mode="HotSpotValue">
919  <xsl:variable name="length" select="count(param)"/>
920  <xsl:for-each select="param">
921    <xsl:variable name="separator">
922        <xsl:choose>
923          <xsl:when test="position()=$length">
924            <xsl:text></xsl:text>
925          </xsl:when>
926          <xsl:otherwise>
927            <xsl:text>, </xsl:text>
928          </xsl:otherwise>
929        </xsl:choose>
930    </xsl:variable>
931    <xsl:apply-templates select="." mode="HotSpotValue">
932      <xsl:with-param name="comma" select="$separator"/>
933    </xsl:apply-templates>
934  </xsl:for-each>
935</xsl:template>
936
937<xsl:template match="param" mode="HotSpotValue">
938  <xsl:param name="comma"/>
939  <xsl:variable name="result">
940    <xsl:apply-templates select="child::*[position()=1]" mode="HotSpotValue">
941      <xsl:with-param name="name" select="@id"/>
942    </xsl:apply-templates>
943  </xsl:variable>
944  <xsl:if test="string-length($result)!=0">
945    <xsl:value-of select="$result"/>
946    <xsl:value-of select="$comma"/>    
947  </xsl:if>
948</xsl:template>
949
950<xsl:template match="jframeID|jmethodID|jrawMonitorID|jthread|jclass|nullok" mode="HotSpotValue">
951  <xsl:param name="name"/>
952  <xsl:apply-templates select="." mode="HotSpotName">
953    <xsl:with-param name="name" select="$name"/>
954  </xsl:apply-templates>
955</xsl:template>
956
957<xsl:template match="jfieldID" mode="HotSpotValue">
958  <xsl:text>&amp;fdesc</xsl:text>
959</xsl:template>
960
961<xsl:template match="jobject|jvalue|jthreadGroup|enum|jint|jchar|jlong|jfloat|jdouble|jlocation|jboolean|char|uchar|size_t|void|struct|outptr|outbuf|allocfieldbuf|ptrtype|inptr|inbuf|vmbuf|allocbuf|agentbuf|allocallocbuf" mode="HotSpotValue">
962  <xsl:param name="name"/>
963  <xsl:value-of select="$name"/>
964</xsl:template>
965
966<xsl:template match="varargs" mode="HotSpotValue">
967  <xsl:text>NULL</xsl:text>
968</xsl:template>
969
970</xsl:stylesheet>
971
972