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