jvmtiH.xsl revision 1472:c18cbe5936b8
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
4 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License version 2 only, as
8 published by the Free Software Foundation.
9
10 This code is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 version 2 for more details (a copy is included in the LICENSE file that
14 accompanied this code).
15
16 You should have received a copy of the GNU General Public License version
17 2 along with this work; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
20 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 or visit www.oracle.com if you need additional information or have any
22 questions.
23  
24-->
25
26<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27                version="1.0">
28
29  <xsl:import href="jvmtiLib.xsl"/>
30
31  <xsl:output method="text" omit-xml-declaration="yes"/>
32
33  <xsl:template match="/">
34    <xsl:apply-templates select="specification"/>
35  </xsl:template>
36
37  <xsl:template match="specification">
38
39    <xsl:call-template name="intro"/>
40
41    <xsl:text>/* Derived Base Types */
42</xsl:text>
43    <xsl:apply-templates select="//basetype"/>
44
45    <xsl:text>
46
47    /* Constants */
48</xsl:text>
49    <xsl:apply-templates select="//constants"/>
50    
51    <xsl:text>
52
53    /* Errors */
54
55typedef enum {
56</xsl:text>
57     <xsl:for-each select="//errorid">
58       <xsl:sort select="@num" data-type="number"/>
59         <xsl:apply-templates select="." mode="enum"/>
60         <xsl:text>,
61</xsl:text>
62         <xsl:if test="position() = last()">
63           <xsl:text>    JVMTI_ERROR_MAX = </xsl:text>
64           <xsl:value-of select="@num"/>
65         </xsl:if>
66     </xsl:for-each>
67    <xsl:text>
68} jvmtiError;
69</xsl:text>
70    <xsl:apply-templates select="eventsection" mode="enum"/>
71
72    <xsl:text>
73    /* Pre-Declarations */
74</xsl:text>
75<xsl:apply-templates select="//typedef|//uniontypedef" mode="early"/>
76
77    <xsl:text>
78    /* Function Types */
79</xsl:text>
80    <xsl:apply-templates select="//callback"/>
81
82    <xsl:text>
83
84    /* Structure Types */
85</xsl:text>
86    <xsl:apply-templates select="//typedef|//uniontypedef" mode="body"/>
87    <xsl:apply-templates select="//capabilitiestypedef"/>
88
89    <xsl:apply-templates select="eventsection" mode="body"/>
90
91    <xsl:apply-templates select="functionsection"/>
92
93    <xsl:call-template name="outro"/>
94      
95  </xsl:template>
96
97  <xsl:template name="intro">
98  <xsl:call-template name="includeHeader"/>
99  <xsl:text>
100    /* Include file for the Java(tm) Virtual Machine Tool Interface */
101
102#ifndef _JAVA_JVMTI_H_
103#define _JAVA_JVMTI_H_
104
105#include "jni.h"
106
107#ifdef __cplusplus
108extern "C" {
109#endif
110
111enum {
112    JVMTI_VERSION_1   = 0x30010000,
113    JVMTI_VERSION_1_0 = 0x30010000,
114    JVMTI_VERSION_1_1 = 0x30010100,
115
116    JVMTI_VERSION = 0x30000000 + (</xsl:text>
117  <xsl:value-of select="//specification/@majorversion"/>
118  <xsl:text> * 0x10000) + (</xsl:text>
119  <xsl:value-of select="//specification/@minorversion"/>
120  <xsl:text> * 0x100)</xsl:text>
121  <xsl:variable name="micro">
122    <xsl:call-template name="microversion"/>
123  </xsl:variable>
124  <xsl:choose>
125    <xsl:when test="string($micro)='dev'">
126      <xsl:text>  /* checked out - </xsl:text>
127    </xsl:when>
128    <xsl:otherwise>
129      <xsl:text> + </xsl:text>
130      <xsl:value-of select="$micro"/>
131      <xsl:text>  /* </xsl:text>
132    </xsl:otherwise>
133  </xsl:choose>
134  <xsl:text>version: </xsl:text>
135  <xsl:call-template name="showversion"/>
136  <xsl:text> */
137};
138
139JNIEXPORT jint JNICALL 
140Agent_OnLoad(JavaVM *vm, char *options, void *reserved);
141
142JNIEXPORT jint JNICALL
143Agent_OnAttach(JavaVM* vm, char* options, void* reserved);
144
145JNIEXPORT void JNICALL 
146Agent_OnUnload(JavaVM *vm);
147
148    /* Forward declaration of the environment */
149        
150struct _jvmtiEnv;
151
152struct jvmtiInterface_1_;
153  
154#ifdef __cplusplus
155typedef _jvmtiEnv jvmtiEnv;
156#else
157typedef const struct jvmtiInterface_1_ *jvmtiEnv;
158#endif /* __cplusplus */
159
160</xsl:text>
161  </xsl:template>
162
163  <xsl:template name="outro">
164  <xsl:text>
165
166#ifdef __cplusplus
167} /* extern "C" */
168#endif /* __cplusplus */
169
170#endif /* !_JAVA_JVMTI_H_ */
171
172</xsl:text>
173</xsl:template>
174
175<xsl:template match="eventsection" mode="enum">
176  <xsl:text>
177    /* Event IDs */
178
179typedef enum {
180</xsl:text>
181     <xsl:for-each select="event">
182       <xsl:sort select="@num" data-type="number"/>
183       <xsl:if test="position()=1">
184         <xsl:text>    JVMTI_MIN_EVENT_TYPE_VAL = </xsl:text>
185         <xsl:value-of select="@num"/>
186         <xsl:text>,
187</xsl:text>
188       </xsl:if>
189       <xsl:apply-templates select="." mode="enum"/>
190       <xsl:text>,
191</xsl:text>
192       <xsl:if test="position()=last()">
193         <xsl:text>    JVMTI_MAX_EVENT_TYPE_VAL = </xsl:text>
194         <xsl:value-of select="@num"/>
195       </xsl:if>
196     </xsl:for-each>
197    <xsl:text>
198} jvmtiEvent;
199
200</xsl:text>
201</xsl:template>
202
203<xsl:template match="eventsection" mode="body">
204  <xsl:text>
205
206    /* Event Definitions */
207
208typedef void (JNICALL *jvmtiEventReserved)(void);
209
210</xsl:text>
211  <xsl:apply-templates select="event" mode="definition">
212    <xsl:sort select="@id"/>
213  </xsl:apply-templates>
214
215  <xsl:text>
216    /* Event Callback Structure */
217
218typedef struct {
219</xsl:text>
220  <xsl:call-template name="eventStruct">
221    <xsl:with-param name="events" select="event"/>
222    <xsl:with-param name="index" select="0"/>
223    <xsl:with-param name="started" select="false"/>
224    <xsl:with-param name="comment" select="'Yes'"/>
225  </xsl:call-template>
226  <xsl:text>} jvmtiEventCallbacks;
227</xsl:text>
228
229</xsl:template>
230
231
232<xsl:template match="event" mode="definition">
233  <xsl:text>
234typedef void (JNICALL *jvmtiEvent</xsl:text>
235  <xsl:value-of select="@id"/>
236  <xsl:text>)
237    (jvmtiEnv *jvmti_env</xsl:text>
238  <xsl:apply-templates select="parameters" mode="signature">
239    <xsl:with-param name="comma">
240      <xsl:text>, 
241     </xsl:text>
242    </xsl:with-param>
243   </xsl:apply-templates>
244 <xsl:text>);
245</xsl:text>
246</xsl:template>
247
248<xsl:template match="functionsection">
249   <xsl:text>
250
251    /* Function Interface */
252    
253typedef struct jvmtiInterface_1_ {
254
255</xsl:text>
256  <xsl:call-template name="funcStruct">
257    <xsl:with-param name="funcs" select="category/function[count(@hide)=0]"/>
258    <xsl:with-param name="index" select="1"/>
259  </xsl:call-template>
260
261  <xsl:text>} jvmtiInterface_1;
262
263struct _jvmtiEnv {
264    const struct jvmtiInterface_1_ *functions;
265#ifdef __cplusplus
266
267</xsl:text>
268  <xsl:apply-templates select="category" mode="cppinline"/>
269  <xsl:text>
270#endif /* __cplusplus */
271};
272</xsl:text>
273
274</xsl:template>
275
276<xsl:template name="funcStruct">
277  <xsl:param name="funcs"/>
278  <xsl:param name="index"/>
279  <xsl:variable name="thisFunction" select="$funcs[@num=$index]"/>
280  <xsl:text>  /* </xsl:text>
281  <xsl:number value="$index" format="  1"/>
282  <xsl:text> : </xsl:text>
283  <xsl:choose>
284    <xsl:when test="count($thisFunction)=1">
285      <xsl:value-of select="$thisFunction/synopsis"/>
286      <xsl:text> */
287  jvmtiError (JNICALL *</xsl:text>
288      <xsl:value-of select="$thisFunction/@id"/>
289      <xsl:text>) (jvmtiEnv* env</xsl:text>
290      <xsl:apply-templates select="$thisFunction/parameters" mode="signature">
291        <xsl:with-param name="comma">
292          <xsl:text>, 
293    </xsl:text>
294        </xsl:with-param>
295      </xsl:apply-templates>
296      <xsl:text>)</xsl:text>
297    </xsl:when>
298    <xsl:otherwise>
299      <xsl:text> RESERVED */
300  void *reserved</xsl:text>        
301      <xsl:value-of select="$index"/>
302    </xsl:otherwise>
303  </xsl:choose>
304  <xsl:text>;
305
306</xsl:text>
307  <xsl:if test="count($funcs[@num &gt; $index]) &gt; 0">
308    <xsl:call-template name="funcStruct">
309      <xsl:with-param name="funcs" select="$funcs"/>
310      <xsl:with-param name="index" select="1+$index"/>
311    </xsl:call-template>
312  </xsl:if>
313</xsl:template>
314
315
316<xsl:template match="function">
317  <xsl:text>  jvmtiError (JNICALL *</xsl:text>
318  <xsl:value-of select="@id"/>
319  <xsl:text>) (jvmtiEnv* env</xsl:text>
320  <xsl:apply-templates select="parameters" mode="signature"/>
321  <xsl:text>);
322
323</xsl:text>
324</xsl:template>
325
326<xsl:template match="category" mode="cppinline">
327    <xsl:apply-templates select="function[count(@hide)=0]" mode="cppinline"/>
328</xsl:template>
329
330<xsl:template match="function" mode="cppinline">
331  <xsl:text>
332  jvmtiError </xsl:text>
333  <xsl:value-of select="@id"/>
334  <xsl:text>(</xsl:text>
335  <xsl:apply-templates select="parameters" mode="signaturenoleadcomma"/>
336  <xsl:text>) {
337    return functions-></xsl:text>
338  <xsl:value-of select="@id"/>
339  <xsl:text>(this</xsl:text>
340  <xsl:for-each select="parameters">
341    <xsl:for-each select="param">
342      <xsl:if test="@id != '...' and count(jclass/@method) = 0">
343        <xsl:text>, </xsl:text>
344        <xsl:value-of select="@id"/>
345      </xsl:if>
346    </xsl:for-each>
347  </xsl:for-each>
348  <xsl:text>);
349  }
350</xsl:text>
351</xsl:template>
352
353
354  <xsl:template match="basetype">
355    <xsl:if test="count(definition)!=0">
356      <xsl:text>
357</xsl:text>
358      <xsl:apply-templates select="definition"/>
359    </xsl:if>
360  </xsl:template>
361
362  <xsl:template match="constants">
363    <xsl:text>
364
365    /* </xsl:text>
366    <xsl:value-of select="@label"/>
367    <xsl:text> */ 
368</xsl:text>
369    <xsl:choose>
370      <xsl:when test="@kind='enum'">
371        <xsl:apply-templates select="." mode="enum"/>
372      </xsl:when>
373      <xsl:otherwise>
374        <xsl:apply-templates select="." mode="constants"/>
375      </xsl:otherwise>
376    </xsl:choose>
377  </xsl:template>
378
379<xsl:template match="callback">
380      <xsl:text>
381typedef </xsl:text>
382      <xsl:apply-templates select="child::*[position()=1]" mode="signature"/>
383      <xsl:text> (JNICALL *</xsl:text>
384      <xsl:value-of select="@id"/>
385      <xsl:text>)
386    (</xsl:text>
387      <xsl:for-each select="parameters">
388        <xsl:apply-templates select="param[position()=1]" mode="signature"/>
389        <xsl:for-each select="param[position()>1]">
390          <xsl:text>, </xsl:text>
391          <xsl:apply-templates select="." mode="signature"/>
392        </xsl:for-each>
393      </xsl:for-each>
394      <xsl:text>);
395</xsl:text>
396</xsl:template>
397
398<xsl:template match="capabilitiestypedef">
399  <xsl:text>
400</xsl:text>
401  <xsl:apply-templates select="." mode="genstruct"/>
402  <xsl:text>
403</xsl:text>
404</xsl:template>
405
406<xsl:template match="typedef" mode="early">
407  <xsl:text>struct _</xsl:text>
408  <xsl:value-of select="@id"/>
409  <xsl:text>;
410</xsl:text>
411  <xsl:text>typedef struct _</xsl:text>
412  <xsl:value-of select="@id"/>
413  <xsl:text> </xsl:text>
414  <xsl:value-of select="@id"/>
415  <xsl:text>;
416</xsl:text>
417</xsl:template>
418
419<xsl:template match="typedef" mode="body">
420  <xsl:text>struct _</xsl:text>
421  <xsl:value-of select="@id"/>
422  <xsl:text> {
423</xsl:text>
424<xsl:apply-templates select="field" mode="signature"/>
425  <xsl:text>};
426</xsl:text>
427</xsl:template>
428
429<xsl:template match="uniontypedef" mode="early">
430  <xsl:text>union _</xsl:text>
431  <xsl:value-of select="@id"/>
432  <xsl:text>;
433</xsl:text>
434  <xsl:text>typedef union _</xsl:text>
435  <xsl:value-of select="@id"/>
436  <xsl:text> </xsl:text>
437  <xsl:value-of select="@id"/>
438  <xsl:text>;
439</xsl:text>
440</xsl:template>
441
442<xsl:template match="uniontypedef" mode="body">
443  <xsl:text>union _</xsl:text>
444  <xsl:value-of select="@id"/>
445  <xsl:text> {
446</xsl:text>
447<xsl:apply-templates select="field" mode="signature"/>
448  <xsl:text>};
449</xsl:text>
450</xsl:template>
451
452</xsl:stylesheet>
453