1 <?xml version="1.0" encoding="utf-8"?> 2 <!-- 3 Copyright (c) 2002, 2020, 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 55 typedef 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="include_GPL_CP_Header"/> 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 108 extern "C" { 109 #endif 110 111 enum { 112 JVMTI_VERSION_1 = 0x30010000, 113 JVMTI_VERSION_1_0 = 0x30010000, 114 JVMTI_VERSION_1_1 = 0x30010100, 115 JVMTI_VERSION_1_2 = 0x30010200, 116 JVMTI_VERSION_9 = 0x30090000, 117 JVMTI_VERSION_11 = 0x300B0000, 118 JVMTI_VERSION_19 = 0x30130000, 119 120 JVMTI_VERSION = 0x30000000 + (</xsl:text> 121 <xsl:value-of select="$majorversion"/> 122 <xsl:text> * 0x10000) + (</xsl:text> 123 <!-- Now minorversion is always 0 --> 124 <xsl:text> 0 * 0x100)</xsl:text> 125 <xsl:variable name="micro"> 126 <xsl:call-template name="microversion"/> 127 </xsl:variable> 128 <xsl:choose> 129 <xsl:when test="string($micro)='dev'"> 130 <xsl:text> /* checked out - </xsl:text> 131 </xsl:when> 132 <xsl:otherwise> 133 <xsl:text> + </xsl:text> 134 <xsl:value-of select="$micro"/> 135 <xsl:text> /* </xsl:text> 136 </xsl:otherwise> 137 </xsl:choose> 138 <xsl:text>version: </xsl:text> 139 <xsl:call-template name="showversion"/> 140 <xsl:text> */ 141 }; 142 143 JNIEXPORT jint JNICALL 144 Agent_OnLoad(JavaVM *vm, char *options, void *reserved); 145 146 JNIEXPORT jint JNICALL 147 Agent_OnAttach(JavaVM* vm, char* options, void* reserved); 148 149 JNIEXPORT void JNICALL 150 Agent_OnUnload(JavaVM *vm); 151 152 /* Forward declaration of the environment */ 153 154 struct _jvmtiEnv; 155 156 struct jvmtiInterface_1_; 157 158 #ifdef __cplusplus 159 typedef _jvmtiEnv jvmtiEnv; 160 #else 161 typedef const struct jvmtiInterface_1_ *jvmtiEnv; 162 #endif /* __cplusplus */ 163 164 </xsl:text> 165 </xsl:template> 166 167 <xsl:template name="outro"> 168 <xsl:text> 169 170 #ifdef __cplusplus 171 } /* extern "C" */ 172 #endif /* __cplusplus */ 173 174 #endif /* !_JAVA_JVMTI_H_ */ 175 </xsl:text> 176 </xsl:template> 177 178 <xsl:template match="eventsection" mode="enum"> 179 <xsl:text> 180 /* Event IDs */ 181 182 typedef enum { 183 </xsl:text> 184 <xsl:for-each select="event"> 185 <xsl:sort select="@num" data-type="number"/> 186 <xsl:if test="position()=1"> 187 <xsl:text> JVMTI_MIN_EVENT_TYPE_VAL = </xsl:text> 188 <xsl:value-of select="@num"/> 189 <xsl:text>, 190 </xsl:text> 191 </xsl:if> 192 <xsl:apply-templates select="." mode="enum"/> 193 <xsl:text>, 194 </xsl:text> 195 <xsl:if test="position()=last()"> 196 <xsl:text> JVMTI_MAX_EVENT_TYPE_VAL = </xsl:text> 197 <xsl:value-of select="@num"/> 198 </xsl:if> 199 </xsl:for-each> 200 <xsl:text> 201 } jvmtiEvent; 202 203 </xsl:text> 204 </xsl:template> 205 206 <xsl:template match="eventsection" mode="body"> 207 <xsl:text> 208 209 /* Event Definitions */ 210 211 typedef void (JNICALL *jvmtiEventReserved)(void); 212 213 </xsl:text> 214 <xsl:apply-templates select="event" mode="definition"> 215 <xsl:sort select="@id"/> 216 </xsl:apply-templates> 217 218 <xsl:text> 219 /* Event Callback Structure */ 220 221 typedef struct { 222 </xsl:text> 223 <xsl:call-template name="eventStruct"> 224 <xsl:with-param name="events" select="event"/> 225 <xsl:with-param name="index" select="0"/> 226 <xsl:with-param name="started" select="false"/> 227 <xsl:with-param name="comment" select="'Yes'"/> 228 </xsl:call-template> 229 <xsl:text>} jvmtiEventCallbacks; 230 </xsl:text> 231 232 </xsl:template> 233 234 235 <xsl:template match="event" mode="definition"> 236 <xsl:text> 237 typedef void (JNICALL *jvmtiEvent</xsl:text> 238 <xsl:value-of select="@id"/> 239 <xsl:text>) 240 (jvmtiEnv *jvmti_env</xsl:text> 241 <xsl:apply-templates select="parameters" mode="signature"> 242 <xsl:with-param name="comma"> 243 <xsl:text>, 244 </xsl:text> 245 </xsl:with-param> 246 </xsl:apply-templates> 247 <xsl:text>); 248 </xsl:text> 249 </xsl:template> 250 251 <xsl:template match="functionsection"> 252 <xsl:text> 253 254 /* Function Interface */ 255 256 typedef struct jvmtiInterface_1_ { 257 258 </xsl:text> 259 <xsl:call-template name="funcStruct"> 260 <xsl:with-param name="funcs" select="category/function[count(@hide)=0]"/> 261 <xsl:with-param name="index" select="1"/> 262 </xsl:call-template> 263 264 <xsl:text>} jvmtiInterface_1; 265 266 struct _jvmtiEnv { 267 const struct jvmtiInterface_1_ *functions; 268 #ifdef __cplusplus 269 270 </xsl:text> 271 <xsl:apply-templates select="category" mode="cppinline"/> 272 <xsl:text> 273 #endif /* __cplusplus */ 274 }; 275 </xsl:text> 276 277 </xsl:template> 278 279 <xsl:template name="funcStruct"> 280 <xsl:param name="funcs"/> 281 <xsl:param name="index"/> 282 <xsl:variable name="thisFunction" select="$funcs[@num=$index]"/> 283 <xsl:text> /* </xsl:text> 284 <xsl:number value="$index" format=" 1"/> 285 <xsl:text> : </xsl:text> 286 <xsl:choose> 287 <xsl:when test="count($thisFunction)=1"> 288 <xsl:value-of select="$thisFunction/synopsis"/> 289 <xsl:text> */ 290 jvmtiError (JNICALL *</xsl:text> 291 <xsl:value-of select="$thisFunction/@id"/> 292 <xsl:text>) (jvmtiEnv* env</xsl:text> 293 <xsl:apply-templates select="$thisFunction/parameters" mode="signature"> 294 <xsl:with-param name="comma"> 295 <xsl:text>, 296 </xsl:text> 297 </xsl:with-param> 298 </xsl:apply-templates> 299 <xsl:text>)</xsl:text> 300 </xsl:when> 301 <xsl:otherwise> 302 <xsl:text> RESERVED */ 303 void *reserved</xsl:text> 304 <xsl:value-of select="$index"/> 305 </xsl:otherwise> 306 </xsl:choose> 307 <xsl:text>; 308 309 </xsl:text> 310 <xsl:if test="count($funcs[@num > $index]) > 0"> 311 <xsl:call-template name="funcStruct"> 312 <xsl:with-param name="funcs" select="$funcs"/> 313 <xsl:with-param name="index" select="1+$index"/> 314 </xsl:call-template> 315 </xsl:if> 316 </xsl:template> 317 318 319 <xsl:template match="function"> 320 <xsl:text> jvmtiError (JNICALL *</xsl:text> 321 <xsl:value-of select="@id"/> 322 <xsl:text>) (jvmtiEnv* env</xsl:text> 323 <xsl:apply-templates select="parameters" mode="signature"/> 324 <xsl:text>); 325 326 </xsl:text> 327 </xsl:template> 328 329 <xsl:template match="category" mode="cppinline"> 330 <xsl:apply-templates select="function[count(@hide)=0]" mode="cppinline"/> 331 </xsl:template> 332 333 <xsl:template match="function" mode="cppinline"> 334 <xsl:text> 335 jvmtiError </xsl:text> 336 <xsl:value-of select="@id"/> 337 <xsl:text>(</xsl:text> 338 <xsl:apply-templates select="parameters" mode="signaturenoleadcomma"/> 339 <xsl:text>) { 340 return functions-></xsl:text> 341 <xsl:value-of select="@id"/> 342 <xsl:text>(this</xsl:text> 343 <xsl:for-each select="parameters"> 344 <xsl:for-each select="param"> 345 <xsl:if test="@id != '...' and count(jclass/@method) = 0"> 346 <xsl:text>, </xsl:text> 347 <xsl:value-of select="@id"/> 348 </xsl:if> 349 </xsl:for-each> 350 </xsl:for-each> 351 <xsl:text>); 352 } 353 </xsl:text> 354 </xsl:template> 355 356 357 <xsl:template match="basetype"> 358 <xsl:if test="count(definition)!=0"> 359 <xsl:text> 360 </xsl:text> 361 <xsl:apply-templates select="definition"/> 362 </xsl:if> 363 </xsl:template> 364 365 <xsl:template match="constants"> 366 <xsl:text> 367 368 /* </xsl:text> 369 <xsl:value-of select="@label"/> 370 <xsl:text> */ 371 </xsl:text> 372 <xsl:choose> 373 <xsl:when test="@kind='enum'"> 374 <xsl:apply-templates select="." mode="enum"/> 375 </xsl:when> 376 <xsl:otherwise> 377 <xsl:apply-templates select="." mode="constants"/> 378 </xsl:otherwise> 379 </xsl:choose> 380 </xsl:template> 381 382 <xsl:template match="callback"> 383 <xsl:text> 384 typedef </xsl:text> 385 <xsl:apply-templates select="child::*[position()=1]" mode="signature"/> 386 <xsl:text> (JNICALL *</xsl:text> 387 <xsl:value-of select="@id"/> 388 <xsl:text>) 389 (</xsl:text> 390 <xsl:for-each select="parameters"> 391 <xsl:apply-templates select="param[position()=1]" mode="signature"/> 392 <xsl:for-each select="param[position()>1]"> 393 <xsl:text>, </xsl:text> 394 <xsl:apply-templates select="." mode="signature"/> 395 </xsl:for-each> 396 </xsl:for-each> 397 <xsl:text>); 398 </xsl:text> 399 </xsl:template> 400 401 <xsl:template match="capabilitiestypedef"> 402 <xsl:text> 403 </xsl:text> 404 <xsl:apply-templates select="." mode="genstruct"/> 405 <xsl:text> 406 </xsl:text> 407 </xsl:template> 408 409 <xsl:template match="typedef" mode="early"> 410 <xsl:text>struct </xsl:text> 411 <xsl:value-of select="@id"/> 412 <xsl:text>; 413 </xsl:text> 414 <xsl:text>typedef struct </xsl:text> 415 <xsl:value-of select="@id"/> 416 <xsl:text> </xsl:text> 417 <xsl:value-of select="@id"/> 418 <xsl:text>; 419 </xsl:text> 420 </xsl:template> 421 422 <xsl:template match="typedef" mode="body"> 423 <xsl:text>struct </xsl:text> 424 <xsl:value-of select="@id"/> 425 <xsl:text> { 426 </xsl:text> 427 <xsl:apply-templates select="field" mode="signature"/> 428 <xsl:text>}; 429 </xsl:text> 430 </xsl:template> 431 432 <xsl:template match="uniontypedef" mode="early"> 433 <xsl:text>union </xsl:text> 434 <xsl:value-of select="@id"/> 435 <xsl:text>; 436 </xsl:text> 437 <xsl:text>typedef union </xsl:text> 438 <xsl:value-of select="@id"/> 439 <xsl:text> </xsl:text> 440 <xsl:value-of select="@id"/> 441 <xsl:text>; 442 </xsl:text> 443 </xsl:template> 444 445 <xsl:template match="uniontypedef" mode="body"> 446 <xsl:text>union </xsl:text> 447 <xsl:value-of select="@id"/> 448 <xsl:text> { 449 </xsl:text> 450 <xsl:apply-templates select="field" mode="signature"/> 451 <xsl:text>}; 452 </xsl:text> 453 </xsl:template> 454 455 </xsl:stylesheet>