VirtualBox

source: vbox/trunk/src/VBox/Main/idl/apiwrap-server.xsl@ 79610

Last change on this file since 79610 was 79049, checked in by vboxsync, 5 years ago

Main/apiwrap-server*.xsl: Don't generate wrappers for event interfaces marked with autogen='VBoxEvent' as these have a different code generator and shouldn't be used. Should save a little build time and more importantly VBox/log.h updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 97.8 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 apiwrap-server.xsl:
5 XSLT stylesheet that generates C++ API wrappers (server side) from
6 VirtualBox.xidl.
7
8 Copyright (C) 2010-2016 Oracle Corporation
9
10 This file is part of VirtualBox Open Source Edition (OSE), as
11 available from http://www.virtualbox.org. This file is free software;
12 you can redistribute it and/or modify it under the terms of the GNU
13 General Public License (GPL) as published by the Free Software
14 Foundation, in version 2 as it comes in the "COPYING" file of the
15 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17-->
18
19<xsl:stylesheet
20 version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:exsl="http://exslt.org/common"
23 extension-element-prefixes="exsl">
24
25<xsl:output method="text"/>
26
27<xsl:strip-space elements="*"/>
28
29<!-- - - - - - - - - - - - - - - - - - - - - - -
30 global XSLT variables
31 - - - - - - - - - - - - - - - - - - - - - - -->
32
33<xsl:variable name="G_xsltFilename" select="'apiwrap-server.xsl'"/>
34
35<xsl:variable name="G_root" select="/"/>
36
37<xsl:include href="typemap-shared.inc.xsl"/>
38
39<!-- - - - - - - - - - - - - - - - - - - - - - -
40 Keys for more efficiently looking up of types.
41 - - - - - - - - - - - - - - - - - - - - - - -->
42
43<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
44<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
45
46<!-- - - - - - - - - - - - - - - - - - - - - - -
47templates for file separation
48 - - - - - - - - - - - - - - - - - - - - - - -->
49
50<xsl:template match="interface" mode="startfile">
51 <xsl:param name="file"/>
52
53 <xsl:call-template name="xsltprocNewlineOutputHack"/>
54 <xsl:value-of select="concat($G_sNewLine, '// ##### BEGINFILE &quot;', $file, '&quot;', $G_sNewLine)"/>
55</xsl:template>
56
57<xsl:template match="interface" mode="endfile">
58 <xsl:param name="file"/>
59
60 <xsl:value-of select="concat($G_sNewLine, '// ##### ENDFILE &quot;', $file, '&quot;', $G_sNewLine)"/>
61</xsl:template>
62
63<!-- - - - - - - - - - - - - - - - - - - - - - -
64templates for file headers/footers
65 - - - - - - - - - - - - - - - - - - - - - - -->
66
67<xsl:template name="fileheader">
68 <xsl:param name="class"/>
69 <xsl:param name="name"/>
70 <xsl:param name="type"/>
71
72 <xsl:text>/** @file
73</xsl:text>
74 <xsl:value-of select="concat(' * VirtualBox API class wrapper ', $type, ' for I', $class, '.')"/>
75 <xsl:text>
76 *
77 * DO NOT EDIT! This is a generated file.
78 * Generated from: src/VBox/Main/idl/VirtualBox.xidl
79 * Generator: src/VBox/Main/idl/apiwrap-server.xsl
80 */
81
82/**
83 * Copyright (C) 2010-2016 Oracle Corporation
84 *
85 * This file is part of VirtualBox Open Source Edition (OSE), as
86 * available from http://www.virtualbox.org. This file is free software;
87 * you can redistribute it and/or modify it under the terms of the GNU
88 * General Public License (GPL) as published by the Free Software
89 * Foundation, in version 2 as it comes in the "COPYING" file of the
90 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
91 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
92 */
93
94</xsl:text>
95</xsl:template>
96
97<!-- Emits COM_INTERFACE_ENTRY statements for the current interface node and whatever it inherits from. -->
98<xsl:template name="emitCOMInterfaces">
99 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', @name, ')' , $G_sNewLine)"/>
100 <!-- now recurse to emit all base interfaces -->
101 <xsl:variable name="extends" select="@extends"/>
102 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
103 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
104 <xsl:call-template name="emitCOMInterfaces"/>
105 </xsl:for-each>
106 </xsl:if>
107</xsl:template>
108
109<xsl:template match="interface" mode="classheader">
110 <xsl:param name="addinterfaces"/>
111 <xsl:value-of select="concat('#ifndef ', substring(@name, 2), 'Wrap_H_', $G_sNewLine)"/>
112 <xsl:value-of select="concat('#define ', substring(@name, 2), 'Wrap_H_')"/>
113 <xsl:text>
114#ifndef RT_WITHOUT_PRAGMA_ONCE
115# pragma once
116#endif
117
118#include "VirtualBoxBase.h"
119#include "Wrapper.h"
120
121</xsl:text>
122 <xsl:value-of select="concat('class ATL_NO_VTABLE ', substring(@name, 2), 'Wrap:')"/>
123 <xsl:text>
124 public VirtualBoxBase,
125</xsl:text>
126 <xsl:value-of select="concat(' VBOX_SCRIPTABLE_IMPL(', @name, ')')"/>
127 <xsl:if test="count(exsl:node-set($addinterfaces)/token) > 0">
128 <xsl:text>,</xsl:text>
129 </xsl:if>
130 <xsl:value-of select="$G_sNewLine"/>
131 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
132 <xsl:value-of select="concat(' VBOX_SCRIPTABLE_IMPL(', text(), ')')"/>
133 <xsl:if test="not(position()=last())">
134 <xsl:text>,</xsl:text>
135 </xsl:if>
136 <xsl:value-of select="$G_sNewLine"/>
137 </xsl:for-each>
138 <xsl:text>{
139 Q_OBJECT
140
141public:
142</xsl:text>
143 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', substring(@name, 2), 'Wrap, ', @name, ')', $G_sNewLine)"/>
144 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
145 <xsl:text> DECLARE_PROTECT_FINAL_CONSTRUCT()
146
147</xsl:text>
148 <xsl:value-of select="concat(' BEGIN_COM_MAP(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
149 <xsl:text> COM_INTERFACE_ENTRY(ISupportErrorInfo)
150</xsl:text>
151 <xsl:call-template name="emitCOMInterfaces"/>
152 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')', $G_sNewLine)"/>
153 <xsl:variable name="manualAddInterfaces">
154 <xsl:call-template name="checkoption">
155 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
156 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
157 </xsl:call-template>
158 </xsl:variable>
159 <xsl:if test="not($manualAddInterfaces = 'true')">
160 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
161 <!-- This is super tricky, as the for-each switches to the node set,
162 which means the normal document isn't available any more. We get
163 the data we need, uses a for-each to switch document and then a
164 key() to look up the interface by name. -->
165 <xsl:variable name="addifname">
166 <xsl:value-of select="string(.)"/>
167 </xsl:variable>
168 <xsl:for-each select="$G_root">
169 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
170 <xsl:call-template name="emitCOMInterfaces"/>
171 </xsl:for-each>
172 </xsl:for-each>
173 </xsl:for-each>
174 </xsl:if>
175 <xsl:value-of select="concat(' VBOX_TWEAK_INTERFACE_ENTRY(', @name, ')', $G_sNewLine)"/>
176 <xsl:text> END_COM_MAP()
177
178</xsl:text>
179 <xsl:value-of select="concat(' DECLARE_EMPTY_CTOR_DTOR(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
180</xsl:template>
181
182<xsl:template match="interface" mode="classfooter">
183 <xsl:param name="addinterfaces"/>
184 <xsl:if test="@wrap-gen-hook = 'yes'">
185 <xsl:text>
186public:
187 virtual void i_callHook(const char *a_pszFunction) { RT_NOREF_PV(a_pszFunction); }
188</xsl:text>
189 </xsl:if>
190 <xsl:text>
191private:
192 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(</xsl:text>
193 <xsl:value-of select="concat(substring(@name, 2),'Wrap')"/>
194 <xsl:text>); /* Shuts up MSC warning C4625. */
195
196};
197
198</xsl:text>
199 <xsl:value-of select="concat('#endif // !', substring(@name, 2), 'Wrap_H_', $G_sNewLine)"/>
200</xsl:template>
201
202<xsl:template match="interface" mode="codeheader">
203 <xsl:param name="addinterfaces"/>
204 <xsl:value-of select="concat('#define LOG_GROUP LOG_GROUP_MAIN_', translate(substring(@name, 2), $G_lowerCase, $G_upperCase), $G_sNewLine, $G_sNewLine)"/>
205 <xsl:value-of select="concat('#include &quot;', substring(@name, 2), 'Wrap.h&quot;', $G_sNewLine)"/>
206 <xsl:text>#include "LoggingNew.h"
207#ifdef VBOX_WITH_DTRACE_R3_MAIN
208# include "dtrace/VBoxAPI.h"
209#endif
210
211</xsl:text>
212</xsl:template>
213
214<xsl:template name="emitISupports">
215 <xsl:param name="classname"/>
216 <xsl:param name="extends"/>
217 <xsl:param name="addinterfaces"/>
218 <xsl:param name="depth"/>
219 <xsl:param name="interfacelist"/>
220
221 <xsl:choose>
222 <xsl:when test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
223 <xsl:variable name="newextends" select="key('G_keyInterfacesByName', $extends)/@extends"/>
224 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $extends)"/>
225 <xsl:call-template name="emitISupports">
226 <xsl:with-param name="classname" select="$classname"/>
227 <xsl:with-param name="extends" select="$newextends"/>
228 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
229 <xsl:with-param name="depth" select="$depth + 1"/>
230 <xsl:with-param name="interfacelist" select="$newiflist"/>
231 </xsl:call-template>
232 </xsl:when>
233 <xsl:otherwise>
234 <xsl:variable name="addinterfaces_ns" select="exsl:node-set($addinterfaces)"/>
235 <xsl:choose>
236 <xsl:when test="count($addinterfaces_ns/token) > 0">
237 <xsl:variable name="addifname" select="$addinterfaces_ns/token[1]"/>
238 <xsl:variable name="addif" select="key('G_keyInterfacesByName', $addifname)/@extends"/>
239 <xsl:variable name="newextends" select="$addif/@extends"/>
240 <xsl:variable name="newaddinterfaces" select="$addinterfaces_ns/token[position() > 1]"/>
241 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $addifname)"/>
242 <xsl:call-template name="emitISupports">
243 <xsl:with-param name="classname" select="$classname"/>
244 <xsl:with-param name="extends" select="$newextends"/>
245 <xsl:with-param name="addinterfaces" select="$newaddinterfaces"/>
246 <xsl:with-param name="depth" select="$depth + 1"/>
247 <xsl:with-param name="interfacelist" select="$newiflist"/>
248 </xsl:call-template>
249 </xsl:when>
250 <xsl:otherwise>
251 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS', $depth, '_CI(', $classname, ', ', $interfacelist, ')', $G_sNewLine)"/>
252 </xsl:otherwise>
253 </xsl:choose>
254 </xsl:otherwise>
255 </xsl:choose>
256</xsl:template>
257
258<xsl:template match="interface" mode="codefooter">
259 <xsl:param name="addinterfaces"/>
260 <xsl:text>#ifdef VBOX_WITH_XPCOM
261</xsl:text>
262 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', substring(@name, 2), 'Wrap)', $G_sNewLine)"/>
263
264 <xsl:variable name="manualAddInterfaces">
265 <xsl:call-template name="checkoption">
266 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
267 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
268 </xsl:call-template>
269 </xsl:variable>
270 <xsl:choose>
271 <xsl:when test="$manualAddInterfaces = 'true'">
272 <xsl:variable name="nulladdinterfaces"></xsl:variable>
273 <xsl:call-template name="emitISupports">
274 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
275 <xsl:with-param name="extends" select="@extends"/>
276 <xsl:with-param name="addinterfaces" select="$nulladdinterfaces"/>
277 <xsl:with-param name="depth" select="1"/>
278 <xsl:with-param name="interfacelist" select="@name"/>
279 </xsl:call-template>
280 </xsl:when>
281 <xsl:otherwise>
282 <xsl:call-template name="emitISupports">
283 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
284 <xsl:with-param name="extends" select="@extends"/>
285 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
286 <xsl:with-param name="depth" select="1"/>
287 <xsl:with-param name="interfacelist" select="@name"/>
288 </xsl:call-template>
289 </xsl:otherwise>
290 </xsl:choose>
291 <xsl:text>#endif // VBOX_WITH_XPCOM
292</xsl:text>
293</xsl:template>
294
295
296<!-- - - - - - - - - - - - - - - - - - - - - - -
297 templates for dealing with names and parameters
298 - - - - - - - - - - - - - - - - - - - - - - -->
299
300<xsl:template name="tospace">
301 <xsl:param name="str"/>
302 <xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_', ' ')"/>
303</xsl:template>
304
305<xsl:template name="checkoption">
306 <xsl:param name="optionlist"/>
307 <xsl:param name="option"/>
308 <xsl:value-of select="string-length($option) > 0 and contains(concat(',', translate($optionlist, ' ', ''), ','), concat(',', $option, ','))"/>
309</xsl:template>
310
311<xsl:template name="getattrlist">
312 <xsl:param name="val"/>
313 <xsl:param name="separator" select="','"/>
314
315 <xsl:if test="$val and $val != ''">
316 <xsl:choose>
317 <xsl:when test="contains($val,$separator)">
318 <token>
319 <xsl:value-of select="substring-before($val,$separator)"/>
320 </token>
321 <xsl:call-template name="getattrlist">
322 <xsl:with-param name="val" select="substring-after($val,$separator)"/>
323 <xsl:with-param name="separator" select="$separator"/>
324 </xsl:call-template>
325 </xsl:when>
326 <xsl:otherwise>
327 <token><xsl:value-of select="$val"/></token>
328 </xsl:otherwise>
329 </xsl:choose>
330 </xsl:if>
331</xsl:template>
332
333<xsl:template name="translatepublictype">
334 <xsl:param name="type"/>
335 <xsl:param name="dir"/>
336 <xsl:param name="mod"/>
337
338 <xsl:choose>
339 <xsl:when test="$type='wstring' or $type='uuid'">
340 <xsl:if test="$dir='in'">
341 <xsl:text>IN_</xsl:text>
342 </xsl:if>
343 <xsl:text>BSTR</xsl:text>
344 </xsl:when>
345
346 <xsl:when test="$type='$unknown'">
347 <xsl:text>IUnknown *</xsl:text>
348 </xsl:when>
349
350 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
351 <xsl:value-of select="concat($type, ' *')"/>
352 </xsl:when>
353
354 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
355 <xsl:value-of select="concat($type, '_T')"/>
356 </xsl:when>
357
358 <!-- Micro optimizations: Put off wraptypefield calculation as long as possible; Check interfaces before enums. -->
359 <xsl:otherwise>
360 <!-- get C++ glue type from IDL type from table in typemap-shared.inc.xsl -->
361 <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
362 <xsl:choose>
363 <xsl:when test="string-length($gluetypefield)">
364 <xsl:value-of select="$gluetypefield"/>
365 </xsl:when>
366
367 <xsl:otherwise>
368 <xsl:call-template name="fatalError">
369 <xsl:with-param name="msg" select="concat('translatepublictype: Type &quot;', $type, '&quot; is not supported.')"/>
370 </xsl:call-template>
371 </xsl:otherwise>
372 </xsl:choose>
373 </xsl:otherwise>
374 </xsl:choose>
375 <xsl:if test="$mod='ptr'">
376 <xsl:text> *</xsl:text>
377 </xsl:if>
378</xsl:template>
379
380<xsl:template name="translatewrappedtype">
381 <xsl:param name="type"/>
382 <xsl:param name="dir"/>
383 <xsl:param name="mod"/>
384 <xsl:param name="safearray"/>
385
386 <xsl:choose>
387 <xsl:when test="$type='wstring'">
388 <xsl:if test="$dir='in' and not($safearray='yes')">
389 <xsl:text>const </xsl:text>
390 </xsl:if>
391 <xsl:text>com::Utf8Str &amp;</xsl:text>
392 </xsl:when>
393
394 <xsl:when test="$type='uuid'">
395 <xsl:if test="$dir='in'">
396 <xsl:text>const </xsl:text>
397 </xsl:if>
398 <xsl:text>com::Guid &amp;</xsl:text>
399 </xsl:when>
400
401 <xsl:when test="$type='$unknown'">
402 <xsl:if test="$dir='in' and not($safearray='yes')">
403 <xsl:text>const </xsl:text>
404 </xsl:if>
405 <xsl:text>ComPtr&lt;IUnknown&gt; &amp;</xsl:text>
406 </xsl:when>
407
408 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
409 <xsl:if test="$dir='in' and not($safearray='yes')">
410 <xsl:text>const </xsl:text>
411 </xsl:if>
412 <xsl:value-of select="concat('ComPtr&lt;', $type, '&gt; &amp;')"/>
413 </xsl:when>
414
415 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
416 <xsl:value-of select="concat($type, '_T')"/>
417 </xsl:when>
418
419 <!-- Micro optimizations: Put off wraptypefield calculation as long as possible; Check interfaces before enums. -->
420 <xsl:otherwise>
421 <!-- get C++ wrap type from IDL type from table in typemap-shared.inc.xsl -->
422 <xsl:variable name="wraptypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
423 <xsl:choose>
424 <xsl:when test="string-length($wraptypefield)">
425 <xsl:value-of select="$wraptypefield"/>
426 </xsl:when>
427
428 <xsl:otherwise>
429 <xsl:call-template name="fatalError">
430 <xsl:with-param name="msg" select="concat('translatewrappedtype: Type &quot;', $type, '&quot; is not supported.')"/>
431 </xsl:call-template>
432 </xsl:otherwise>
433 </xsl:choose>
434 </xsl:otherwise>
435 </xsl:choose>
436 <xsl:if test="$mod='ptr'">
437 <xsl:text> *</xsl:text>
438 </xsl:if>
439</xsl:template>
440
441<xsl:template name="translatefmtspectype">
442 <xsl:param name="type"/>
443 <xsl:param name="dir"/>
444 <xsl:param name="mod"/>
445 <xsl:param name="safearray"/>
446 <xsl:param name="isref"/>
447
448 <!-- get C format string for IDL type from table in typemap-shared.inc.xsl -->
449 <xsl:variable name="wrapfmt" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluefmt"/>
450 <xsl:choose>
451 <xsl:when test="$mod='ptr' or ($isref='yes' and $dir!='in')">
452 <xsl:text>%p</xsl:text>
453 </xsl:when>
454 <xsl:when test="$safearray='yes'">
455 <xsl:text>%zu</xsl:text>
456 </xsl:when>
457 <xsl:when test="string-length($wrapfmt)">
458 <xsl:value-of select="$wrapfmt"/>
459 </xsl:when>
460 <xsl:when test="$type='$unknown'">
461 <xsl:text>%p</xsl:text>
462 </xsl:when>
463 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
464 <xsl:text>%RU32</xsl:text>
465 </xsl:when>
466 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
467 <xsl:text>%p</xsl:text>
468 </xsl:when>
469 <xsl:otherwise>
470 <xsl:call-template name="fatalError">
471 <xsl:with-param name="msg" select="concat('translatefmtcpectype: Type &quot;', $type, '&quot; is not supported.')"/>
472 </xsl:call-template>
473 </xsl:otherwise>
474 </xsl:choose>
475</xsl:template>
476
477<xsl:template name="translatedtracetype">
478 <xsl:param name="type"/>
479 <xsl:param name="dir"/>
480 <xsl:param name="mod"/>
481
482 <!-- get dtrace probe type from IDL type from table in typemap-shared.inc.xsl -->
483 <xsl:variable name="dtracetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@dtracename"/>
484 <xsl:choose>
485 <xsl:when test="string-length($dtracetypefield)">
486 <xsl:value-of select="$dtracetypefield"/>
487 </xsl:when>
488 <xsl:when test="$type='$unknown'">
489 <!-- <xsl:text>struct IUnknown *</xsl:text> -->
490 <xsl:text>void *</xsl:text>
491 </xsl:when>
492 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
493 <!-- <xsl:value-of select="concat($type, '_T')"/> - later we can emit enums into dtrace the library -->
494 <xsl:text>int</xsl:text>
495 </xsl:when>
496 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
497 <!--
498 <xsl:value-of select="concat('struct ', $type, ' *')"/>
499 -->
500 <xsl:text>void *</xsl:text>
501 </xsl:when>
502 <xsl:otherwise>
503 <xsl:call-template name="fatalError">
504 <xsl:with-param name="msg" select="concat('translatedtracetype Type &quot;', $type, '&quot; is not supported.')"/>
505 </xsl:call-template>
506 </xsl:otherwise>
507 </xsl:choose>
508 <xsl:if test="$mod='ptr'">
509 <xsl:text> *</xsl:text>
510 </xsl:if>
511</xsl:template>
512
513
514<!-- - - - - - - - - - - - - - - - - - - - - - -
515 templates for handling entire interfaces and their contents
516 - - - - - - - - - - - - - - - - - - - - - - -->
517
518<!-- Called on interface node. -->
519<xsl:template name="emitInterface">
520 <!-- sources, headers and dtrace-probes all needs attribute lists -->
521 <xsl:variable name="addinterfaces">
522 <xsl:call-template name="getattrlist">
523 <xsl:with-param name="val" select="@wrap-hint-server-addinterfaces"/>
524 </xsl:call-template>
525 </xsl:variable>
526
527 <!-- interface santiy check, prevents crashes -->
528 <xsl:if test="(count(attribute) + count(method)) = 0">
529 <xsl:message terminate="yes">
530 Interface <xsl:value-of select="@name"/> is empty which causes midl generated proxy
531 stubs to crash. Please add a dummy:<xsl:value-of select="$G_sNewLine"/>
532 &lt;attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/&gt;
533 </xsl:message>
534 </xsl:if>
535
536 <xsl:choose>
537 <xsl:when test="$generating = 'sources'">
538 <xsl:if test="(position() mod 2) = $reminder">
539 <xsl:call-template name="emitCode">
540 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
541 </xsl:call-template>
542 </xsl:if>
543 </xsl:when>
544 <xsl:when test="$generating = 'headers'">
545 <xsl:call-template name="emitHeader">
546 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
547 </xsl:call-template>
548 </xsl:when>
549 <xsl:when test="$generating = 'dtrace-probes'">
550 <xsl:call-template name="emitDTraceProbes">
551 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
552 </xsl:call-template>
553 </xsl:when>
554 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitInterface</xsl:message></xsl:otherwise>
555 </xsl:choose>
556</xsl:template>
557
558<!-- Called on a method param or attribute node. -->
559<xsl:template name="emitPublicParameter">
560 <xsl:param name="dir"/>
561
562 <xsl:variable name="gluetype">
563 <xsl:call-template name="translatepublictype">
564 <xsl:with-param name="type" select="@type"/>
565 <xsl:with-param name="dir" select="$dir"/>
566 <xsl:with-param name="mod" select="@mod"/>
567 </xsl:call-template>
568 </xsl:variable>
569
570 <xsl:choose>
571 <xsl:when test="@safearray='yes'">
572 <xsl:choose>
573 <xsl:when test="$dir='in'">
574 <xsl:text>ComSafeArrayIn(</xsl:text>
575 </xsl:when>
576 <xsl:otherwise>
577 <xsl:text>ComSafeArrayOut(</xsl:text>
578 </xsl:otherwise>
579 </xsl:choose>
580 <xsl:value-of select="$gluetype"/>
581 <xsl:text>, a</xsl:text>
582 <xsl:call-template name="capitalize">
583 <xsl:with-param name="str" select="@name"/>
584 </xsl:call-template>
585 <xsl:text>)</xsl:text>
586 </xsl:when>
587 <xsl:otherwise>
588 <xsl:value-of select="$gluetype"/>
589 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
590 <xsl:text> </xsl:text>
591 </xsl:if>
592 <xsl:if test="$dir != 'in'">
593 <xsl:text>*</xsl:text>
594 </xsl:if>
595 <xsl:text>a</xsl:text>
596 <xsl:call-template name="capitalize">
597 <xsl:with-param name="str" select="@name"/>
598 </xsl:call-template>
599 </xsl:otherwise>
600 </xsl:choose>
601</xsl:template>
602
603<xsl:template match="attribute/@type | param/@type" mode="wrapped">
604 <xsl:param name="dir"/>
605
606 <xsl:variable name="wraptype">
607 <xsl:call-template name="translatewrappedtype">
608 <xsl:with-param name="type" select="."/>
609 <xsl:with-param name="dir" select="$dir"/>
610 <xsl:with-param name="mod" select="../@mod"/>
611 <xsl:with-param name="safearray" select="../@safearray"/>
612 </xsl:call-template>
613 </xsl:variable>
614 <xsl:variable name="lastchar">
615 <xsl:value-of select="substring($wraptype, string-length($wraptype))"/>
616 </xsl:variable>
617
618 <xsl:choose>
619 <xsl:when test="../@safearray='yes'">
620 <xsl:if test="$dir='in'">
621 <xsl:text>const </xsl:text>
622 </xsl:if>
623 <xsl:text>std::vector&lt;</xsl:text>
624 <xsl:choose>
625 <xsl:when test="$lastchar = '&amp;'">
626 <xsl:variable name="wraptype2">
627 <xsl:value-of select="substring($wraptype, 1, string-length($wraptype)-2)"/>
628 </xsl:variable>
629 <xsl:value-of select="$wraptype2"/>
630 <xsl:if test="substring($wraptype2,string-length($wraptype2)) = '&gt;'">
631 <xsl:text> </xsl:text>
632 </xsl:if>
633 </xsl:when>
634 <xsl:when test="lastchar = '&gt;'">
635 <xsl:value-of select="concat($wraptype, ' ')"/>
636 </xsl:when>
637 <xsl:otherwise>
638 <xsl:value-of select="$wraptype"/>
639 </xsl:otherwise>
640 </xsl:choose>
641 <xsl:text>&gt; &amp;</xsl:text>
642 </xsl:when>
643 <xsl:otherwise>
644 <xsl:value-of select="$wraptype"/>
645 <xsl:if test="$lastchar != '&amp;'">
646 <xsl:if test="$lastchar != '*'">
647 <xsl:text> </xsl:text>
648 </xsl:if>
649 <xsl:if test="$dir != 'in'">
650 <xsl:text>*</xsl:text>
651 </xsl:if>
652 </xsl:if>
653 </xsl:otherwise>
654 </xsl:choose>
655 <xsl:text>a</xsl:text>
656 <xsl:call-template name="capitalize">
657 <xsl:with-param name="str" select="../@name"/>
658 </xsl:call-template>
659</xsl:template>
660
661<xsl:template match="attribute/@type | param/@type" mode="logparamtext">
662 <xsl:param name="dir"/>
663 <xsl:param name="isref"/>
664
665 <xsl:if test="$isref!='yes' and ($dir='out' or $dir='ret')">
666 <xsl:text>*</xsl:text>
667 </xsl:if>
668 <xsl:text>a</xsl:text>
669 <xsl:call-template name="capitalize">
670 <xsl:with-param name="str" select="../@name"/>
671 </xsl:call-template>
672 <xsl:text>=</xsl:text>
673 <xsl:call-template name="translatefmtspectype">
674 <xsl:with-param name="type" select="."/>
675 <xsl:with-param name="dir" select="$dir"/>
676 <xsl:with-param name="mod" select="../@mod"/>
677 <xsl:with-param name="safearray" select="../@safearray"/>
678 <xsl:with-param name="isref" select="$isref"/>
679 </xsl:call-template>
680</xsl:template>
681
682<xsl:template match="attribute/@type | param/@type" mode="logparamval">
683 <xsl:param name="dir"/>
684 <xsl:param name="isref"/>
685
686 <xsl:choose>
687 <xsl:when test="../@safearray='yes' and $isref!='yes'">
688 <xsl:text>ComSafeArraySize(</xsl:text>
689 <xsl:if test="$isref!='yes' and $dir!='in'">
690 <xsl:text>*</xsl:text>
691 </xsl:if>
692 </xsl:when>
693 <xsl:when test="$isref!='yes' and $dir!='in'">
694 <xsl:text>*</xsl:text>
695 </xsl:when>
696 </xsl:choose>
697 <xsl:text>a</xsl:text>
698 <xsl:call-template name="capitalize">
699 <xsl:with-param name="str" select="../@name"/>
700 </xsl:call-template>
701 <xsl:choose>
702 <xsl:when test="../@safearray='yes' and $isref!='yes'">
703 <xsl:text>)</xsl:text>
704 </xsl:when>
705 </xsl:choose>
706</xsl:template>
707
708<!-- Emits the DTrace probe parameter value (using tmps), invoked on param or attribute node. -->
709<xsl:template name="emitDTraceParamValue">
710 <xsl:param name="dir"/>
711
712 <xsl:variable name="viatmpvar">
713 <xsl:for-each select="@type">
714 <xsl:call-template name="paramconversionviatmp">
715 <xsl:with-param name="dir" select="$dir"/>
716 </xsl:call-template>
717 </xsl:for-each>
718 </xsl:variable>
719
720 <xsl:variable name="type" select="@type"/>
721 <xsl:choose>
722 <!-- Doesn't help to inline paramconversionviatmp: <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or @safearray = 'yes' or count(key('G_keyInterfacesByName', $type)) > 0"> -->
723 <xsl:when test="$viatmpvar = 'yes'">
724 <xsl:variable name="tmpname">
725 <xsl:text>Tmp</xsl:text>
726 <xsl:call-template name="capitalize">
727 <xsl:with-param name="str" select="@name"/>
728 </xsl:call-template>
729 </xsl:variable>
730
731 <xsl:choose>
732 <xsl:when test="@safearray = 'yes'">
733 <xsl:text>(uint32_t)</xsl:text>
734 <xsl:value-of select="$tmpname"/>
735 <xsl:text>.array().size(), </xsl:text>
736 <!-- Later:
737 <xsl:value-of select="concat($tmpname, '.array().data(), ')"/>
738 -->
739 <xsl:text>NULL /*for now*/</xsl:text>
740 </xsl:when>
741 <xsl:when test="$type = 'wstring'">
742 <xsl:value-of select="$tmpname"/>
743 <xsl:text>.str().c_str()</xsl:text>
744 </xsl:when>
745 <xsl:when test="$type = 'uuid'">
746 <xsl:value-of select="$tmpname"/>
747 <xsl:text>.uuid().toStringCurly().c_str()</xsl:text>
748 </xsl:when>
749 <xsl:when test="$type = '$unknown'">
750 <xsl:text>(void *)</xsl:text>
751 <xsl:value-of select="$tmpname"/>
752 <xsl:text>.ptr()</xsl:text>
753 </xsl:when>
754 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
755 <xsl:text>(void *)</xsl:text>
756 <xsl:value-of select="$tmpname"/>
757 <xsl:text>.ptr()</xsl:text>
758 </xsl:when>
759 <xsl:otherwise>
760 <xsl:value-of select="$tmpname"/>
761 </xsl:otherwise>
762 </xsl:choose>
763 </xsl:when>
764
765 <xsl:otherwise>
766 <xsl:if test="$dir != 'in'">
767 <xsl:text>*</xsl:text>
768 </xsl:if>
769 <xsl:text>a</xsl:text>
770 <xsl:call-template name="capitalize">
771 <xsl:with-param name="str" select="@name"/>
772 </xsl:call-template>
773
774 <xsl:if test="$type = 'boolean'">
775 <xsl:text> != FALSE</xsl:text>
776 </xsl:if>
777 </xsl:otherwise>
778 </xsl:choose>
779</xsl:template>
780
781<!--
782Same as emitDTraceParamValue except no temporary variables are used (they are out of scope).
783Note! There are two other instances of this code with different @dir values, see below.
784-->
785<xsl:template name="emitDTraceParamValNoTmp">
786 <!-- To speed this up, the logic of paramconversionviatmp has been duplicated/inlined here. -->
787 <xsl:variable name="type" select="@type"/>
788 <xsl:choose>
789 <xsl:when test="@safearray = 'yes'">
790 <xsl:text>0, 0</xsl:text>
791 </xsl:when>
792 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
793 <xsl:text>0</xsl:text>
794 </xsl:when>
795 <xsl:otherwise>
796 <xsl:if test="@dir != 'in'">
797 <xsl:text>*</xsl:text>
798 </xsl:if>
799 <xsl:text>a</xsl:text>
800 <xsl:call-template name="capitalize">
801 <xsl:with-param name="str" select="@name"/>
802 </xsl:call-template>
803 <xsl:if test="$type = 'boolean'">
804 <xsl:text> != FALSE</xsl:text>
805 </xsl:if>
806 </xsl:otherwise>
807 </xsl:choose>
808</xsl:template>
809
810<!-- Copy of emitDTraceParamValNoTmp with @dir = 'in' for speeding up the code (noticable difference). -->
811<xsl:template name="emitDTraceParamValNoTmp-DirIn">
812 <xsl:variable name="type" select="@type"/>
813 <xsl:choose>
814 <xsl:when test="@safearray = 'yes'">
815 <xsl:text>0, 0</xsl:text>
816 </xsl:when>
817 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
818 <xsl:text>0</xsl:text>
819 </xsl:when>
820 <xsl:otherwise>
821 <xsl:text>a</xsl:text>
822 <xsl:call-template name="capitalize">
823 <xsl:with-param name="str" select="@name"/>
824 </xsl:call-template>
825 <xsl:if test="$type = 'boolean'">
826 <xsl:text> != FALSE</xsl:text>
827 </xsl:if>
828 </xsl:otherwise>
829 </xsl:choose>
830</xsl:template>
831
832<!-- Copy of emitDTraceParamValNoTmp with @dir != 'in' for speeding up attributes (noticable difference). -->
833<xsl:template name="emitDTraceParamValNoTmp-DirNotIn">
834 <xsl:variable name="type" select="@type"/>
835 <xsl:choose>
836 <xsl:when test="@safearray = 'yes'">
837 <xsl:text>0, 0</xsl:text>
838 </xsl:when>
839 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid' or count(key('G_keyInterfacesByName', $type)) > 0">
840 <xsl:text>0</xsl:text>
841 </xsl:when>
842 <xsl:otherwise>
843 <xsl:text>*a</xsl:text>
844 <xsl:call-template name="capitalize">
845 <xsl:with-param name="str" select="@name"/>
846 </xsl:call-template>
847 <xsl:if test="$type = 'boolean'">
848 <xsl:text> != FALSE</xsl:text>
849 </xsl:if>
850 </xsl:otherwise>
851 </xsl:choose>
852</xsl:template>
853
854<xsl:template match="attribute/@type | param/@type" mode="dtraceparamdecl">
855 <xsl:param name="dir"/>
856
857 <xsl:variable name="gluetype">
858 <xsl:call-template name="translatedtracetype">
859 <xsl:with-param name="type" select="."/>
860 <xsl:with-param name="dir" select="$dir"/>
861 <xsl:with-param name="mod" select="../@mod"/>
862 </xsl:call-template>
863 </xsl:variable>
864
865 <!-- Safe arrays get an extra size parameter. -->
866 <xsl:if test="../@safearray='yes'">
867 <xsl:text>uint32_t a_c</xsl:text>
868 <xsl:call-template name="capitalize">
869 <xsl:with-param name="str" select="../@name"/>
870 </xsl:call-template>
871 <xsl:text>, </xsl:text>
872 </xsl:if>
873
874 <xsl:value-of select="$gluetype"/>
875 <xsl:choose>
876 <xsl:when test="../@safearray='yes'">
877 <xsl:text> *a_pa</xsl:text>
878 </xsl:when>
879 <xsl:otherwise>
880 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
881 <xsl:text> </xsl:text>
882 </xsl:if>
883 <xsl:text>a_</xsl:text>
884 </xsl:otherwise>
885 </xsl:choose>
886
887 <xsl:call-template name="capitalize">
888 <xsl:with-param name="str" select="../@name"/>
889 </xsl:call-template>
890</xsl:template>
891
892<!-- Call this to determine whether a temporary conversion variable is used for the current parameter.
893Returns empty if not needed, non-empty ('yes') if needed. -->
894<xsl:template name="paramconversionviatmp">
895 <xsl:param name="dir"/>
896 <xsl:variable name="type" select="."/>
897 <xsl:choose>
898 <xsl:when test="$type = 'wstring' or $type = '$unknown' or $type = 'uuid'">
899 <xsl:text>yes</xsl:text>
900 </xsl:when>
901 <xsl:when test="../@safearray = 'yes'">
902 <xsl:text>yes</xsl:text>
903 </xsl:when>
904 <xsl:when test="$type = 'boolean' or $type = 'long' or $type = 'long' or $type = 'long long'"/> <!-- XXX: drop this? -->
905 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
906 <xsl:text>yes</xsl:text>
907 </xsl:when>
908 </xsl:choose>
909</xsl:template>
910
911<!-- Call this to get the argument conversion class, if any is needed. -->
912<xsl:template name="paramconversionclass">
913 <xsl:param name="dir"/>
914
915 <xsl:variable name="type" select="."/>
916 <xsl:choose>
917 <xsl:when test="$type='$unknown'">
918 <xsl:if test="../@safearray='yes'">
919 <xsl:text>Array</xsl:text>
920 </xsl:if>
921 <xsl:choose>
922 <xsl:when test="$dir='in'">
923 <xsl:text>ComTypeInConverter&lt;IUnknown&gt;</xsl:text>
924 </xsl:when>
925 <xsl:otherwise>
926 <xsl:text>ComTypeOutConverter&lt;IUnknown&gt;</xsl:text>
927 </xsl:otherwise>
928 </xsl:choose>
929 </xsl:when>
930
931 <xsl:when test="$type='wstring'">
932 <xsl:if test="../@safearray='yes'">
933 <xsl:text>Array</xsl:text>
934 </xsl:if>
935 <xsl:choose>
936 <xsl:when test="$dir='in'">
937 <xsl:text>BSTRInConverter</xsl:text>
938 </xsl:when>
939 <xsl:otherwise>
940 <xsl:text>BSTROutConverter</xsl:text>
941 </xsl:otherwise>
942 </xsl:choose>
943 </xsl:when>
944
945 <xsl:when test="$type='uuid'">
946 <xsl:if test="../@safearray='yes'">
947 <xsl:text>Array</xsl:text>
948 </xsl:if>
949 <xsl:choose>
950 <xsl:when test="$dir='in'">
951 <xsl:text>UuidInConverter</xsl:text>
952 </xsl:when>
953 <xsl:otherwise>
954 <xsl:text>UuidOutConverter</xsl:text>
955 </xsl:otherwise>
956 </xsl:choose>
957 </xsl:when>
958
959 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
960 <xsl:if test="../@safearray='yes'">
961 <xsl:text>Array</xsl:text>
962 </xsl:if>
963 <xsl:choose>
964 <xsl:when test="$dir='in'">
965 <xsl:text>ComTypeInConverter</xsl:text>
966 </xsl:when>
967 <xsl:otherwise>
968 <xsl:text>ComTypeOutConverter</xsl:text>
969 </xsl:otherwise>
970 </xsl:choose>
971 <xsl:value-of select="concat('&lt;', $type, '&gt;')"/>
972 </xsl:when>
973
974 <xsl:when test="../@safearray='yes'">
975 <xsl:text>Array</xsl:text>
976 <xsl:choose>
977 <xsl:when test="$dir='in'">
978 <xsl:text>InConverter</xsl:text>
979 </xsl:when>
980 <xsl:otherwise>
981 <xsl:text>OutConverter</xsl:text>
982 </xsl:otherwise>
983 </xsl:choose>
984 <xsl:variable name="gluetype">
985 <xsl:call-template name="translatepublictype">
986 <xsl:with-param name="type" select="."/>
987 <xsl:with-param name="dir" select="$dir"/>
988 <xsl:with-param name="mod" select="../@mod"/>
989 </xsl:call-template>
990 </xsl:variable>
991 <xsl:value-of select="concat('&lt;', $gluetype, '&gt;')"/>
992 </xsl:when>
993 </xsl:choose>
994</xsl:template>
995
996<!-- Emits code for converting the parameter to a temporary variable. -->
997<xsl:template match="attribute/@type | param/@type" mode="paramvalconversion2tmpvar">
998 <xsl:param name="dir"/>
999
1000 <xsl:variable name="conversionclass">
1001 <xsl:call-template name="paramconversionclass">
1002 <xsl:with-param name="dir" select="$dir"/>
1003 </xsl:call-template>
1004 </xsl:variable>
1005
1006 <xsl:if test="$conversionclass != ''">
1007 <xsl:value-of select="$conversionclass"/>
1008 <xsl:text> Tmp</xsl:text>
1009 <xsl:call-template name="capitalize">
1010 <xsl:with-param name="str" select="../@name"/>
1011 </xsl:call-template>
1012 <xsl:text>(</xsl:text>
1013 <xsl:if test="../@safearray = 'yes'">
1014 <xsl:choose>
1015 <xsl:when test="$dir = 'in'">
1016 <xsl:text>ComSafeArrayInArg(</xsl:text>
1017 </xsl:when>
1018 <xsl:otherwise>
1019 <xsl:text>ComSafeArrayOutArg(</xsl:text>
1020 </xsl:otherwise>
1021 </xsl:choose>
1022 </xsl:if>
1023 <xsl:text>a</xsl:text>
1024 <xsl:call-template name="capitalize">
1025 <xsl:with-param name="str" select="../@name"/>
1026 </xsl:call-template>
1027 <xsl:if test="../@safearray = 'yes'">
1028 <xsl:text>)</xsl:text>
1029 </xsl:if>
1030 <xsl:text>);</xsl:text>
1031 </xsl:if>
1032
1033</xsl:template>
1034
1035<!-- Partner to paramvalconversion2tmpvar that emits the parameter when calling call the internal worker method. -->
1036<xsl:template match="attribute/@type | param/@type" mode="paramvalconversionusingtmp">
1037 <xsl:param name="dir"/>
1038
1039 <xsl:variable name="viatmpvar">
1040 <xsl:call-template name="paramconversionviatmp">
1041 <xsl:with-param name="dir" select="$dir"/>
1042 </xsl:call-template>
1043 </xsl:variable>
1044 <xsl:variable name="type" select="."/>
1045
1046 <xsl:choose>
1047 <xsl:when test="$viatmpvar = 'yes'">
1048 <xsl:text>Tmp</xsl:text>
1049 <xsl:call-template name="capitalize">
1050 <xsl:with-param name="str" select="../@name"/>
1051 </xsl:call-template>
1052
1053 <xsl:choose>
1054 <xsl:when test="../@safearray='yes'">
1055 <xsl:text>.array()</xsl:text>
1056 </xsl:when>
1057 <xsl:when test="$type = 'wstring'">
1058 <xsl:text>.str()</xsl:text>
1059 </xsl:when>
1060 <xsl:when test="$type = 'uuid'">
1061 <xsl:text>.uuid()</xsl:text>
1062 </xsl:when>
1063 <xsl:when test="$type = '$unknown'">
1064 <xsl:text>.ptr()</xsl:text>
1065 </xsl:when>
1066 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
1067 <xsl:text>.ptr()</xsl:text>
1068 </xsl:when>
1069 <xsl:otherwise><xsl:message terminate="yes">Oops #1</xsl:message></xsl:otherwise>
1070 </xsl:choose>
1071 </xsl:when>
1072
1073 <xsl:otherwise>
1074 <xsl:text>a</xsl:text>
1075 <xsl:call-template name="capitalize">
1076 <xsl:with-param name="str" select="../@name"/>
1077 </xsl:call-template>
1078
1079 <!-- Make sure BOOL values we pass down are either TRUE or FALSE. -->
1080 <xsl:if test="$type = 'boolean' and $dir = 'in'">
1081 <xsl:text> != FALSE</xsl:text>
1082 </xsl:if>
1083 </xsl:otherwise>
1084 </xsl:choose>
1085
1086</xsl:template>
1087
1088<!-- - - - - - - - - - - - - - - - - - - - - - -
1089 emit attribute
1090 - - - - - - - - - - - - - - - - - - - - - - -->
1091
1092<xsl:template match="attribute" mode="public">
1093 <xsl:param name="target"/>
1094
1095 <xsl:call-template name="emitTargetBegin">
1096 <xsl:with-param name="target" select="$target"/>
1097 </xsl:call-template>
1098
1099 <xsl:variable name="attrbasename">
1100 <xsl:call-template name="capitalize">
1101 <xsl:with-param name="str" select="@name"/>
1102 </xsl:call-template>
1103 </xsl:variable>
1104
1105 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $attrbasename, '))(')"/>
1106 <xsl:call-template name="emitPublicParameter">
1107 <xsl:with-param name="dir">out</xsl:with-param>
1108 </xsl:call-template>
1109 <xsl:text>);
1110</xsl:text>
1111
1112 <xsl:if test="not(@readonly) or @readonly!='yes'">
1113 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $attrbasename, '))(')"/>
1114 <xsl:call-template name="emitPublicParameter">
1115 <xsl:with-param name="dir">in</xsl:with-param>
1116 </xsl:call-template>
1117 <xsl:text>);
1118</xsl:text>
1119 </xsl:if>
1120
1121 <xsl:call-template name="emitTargetEnd">
1122 <xsl:with-param name="target" select="$target"/>
1123 </xsl:call-template>
1124</xsl:template>
1125
1126<xsl:template match="attribute" mode="wrapped">
1127 <xsl:param name="target"/>
1128
1129 <xsl:call-template name="emitTargetBegin">
1130 <xsl:with-param name="target" select="$target"/>
1131 </xsl:call-template>
1132
1133 <xsl:variable name="attrbasename">
1134 <xsl:call-template name="capitalize">
1135 <xsl:with-param name="str" select="@name"/>
1136 </xsl:call-template>
1137 </xsl:variable>
1138
1139 <xsl:if test="$attrbasename = 'MidlDoesNotLikeEmptyInterfaces'">
1140 <xsl:text> //</xsl:text>
1141 </xsl:if>
1142
1143 <xsl:value-of select="concat(' virtual HRESULT get', $attrbasename, '(')"/>
1144 <xsl:variable name="passAutoCaller">
1145 <xsl:call-template name="checkoption">
1146 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1147 <xsl:with-param name="option" select="'passcaller'"/>
1148 </xsl:call-template>
1149 </xsl:variable>
1150 <xsl:if test="$passAutoCaller = 'true'">
1151 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
1152 </xsl:if>
1153 <xsl:apply-templates select="@type" mode="wrapped">
1154 <xsl:with-param name="dir" select="'out'"/>
1155 </xsl:apply-templates>
1156 <xsl:text>) = 0;
1157</xsl:text>
1158
1159 <xsl:if test="not(@readonly) or @readonly!='yes'">
1160 <xsl:value-of select="concat(' virtual HRESULT set', $attrbasename, '(')"/>
1161 <xsl:if test="$passAutoCaller = 'true'">
1162 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
1163 </xsl:if>
1164 <xsl:apply-templates select="@type" mode="wrapped">
1165 <xsl:with-param name="dir" select="'in'"/>
1166 </xsl:apply-templates>
1167 <xsl:text>) = 0;
1168</xsl:text>
1169 </xsl:if>
1170
1171 <xsl:call-template name="emitTargetEnd">
1172 <xsl:with-param name="target" select="$target"/>
1173 </xsl:call-template>
1174</xsl:template>
1175
1176<xsl:template match="attribute" mode="code">
1177 <xsl:param name="topclass"/>
1178 <xsl:param name="dtracetopclass"/>
1179 <xsl:param name="target"/>
1180
1181 <xsl:call-template name="emitTargetBegin">
1182 <xsl:with-param name="target" select="$target"/>
1183 </xsl:call-template>
1184
1185 <xsl:variable name="attrbasename">
1186 <xsl:call-template name="capitalize">
1187 <xsl:with-param name="str" select="@name"/>
1188 </xsl:call-template>
1189 </xsl:variable>
1190 <xsl:variable name="limitedAutoCaller">
1191 <xsl:call-template name="checkoption">
1192 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1193 <xsl:with-param name="option" select="'limitedcaller'"/>
1194 </xsl:call-template>
1195 </xsl:variable>
1196
1197 <xsl:variable name="dtraceattrname">
1198 <xsl:choose>
1199 <xsl:when test="@dtracename">
1200 <xsl:value-of select="@dtracename"/>
1201 </xsl:when>
1202 <xsl:otherwise>
1203 <xsl:value-of select="$attrbasename"/>
1204 </xsl:otherwise>
1205 </xsl:choose>
1206 </xsl:variable>
1207
1208 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(', $attrbasename, ')(')"/>
1209 <xsl:call-template name="emitPublicParameter">
1210 <xsl:with-param name="dir">out</xsl:with-param>
1211 </xsl:call-template>
1212 <xsl:text>)
1213{</xsl:text>
1214 <xsl:if test="$attrbasename = 'MidlDoesNotLikeEmptyInterfaces'">
1215 <xsl:text>
1216#if 0 /* This is a dummy attribute */</xsl:text>
1217 </xsl:if>
1218 <xsl:text>
1219 LogRelFlow(("{%p} %s: enter </xsl:text>
1220 <xsl:apply-templates select="@type" mode="logparamtext">
1221 <xsl:with-param name="dir" select="'out'"/>
1222 <xsl:with-param name="isref" select="'yes'"/>
1223 </xsl:apply-templates>
1224 <xsl:text>\n", this, </xsl:text>
1225 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
1226 <xsl:apply-templates select="@type" mode="logparamval">
1227 <xsl:with-param name="dir" select="'out'"/>
1228 <xsl:with-param name="isref" select="'yes'"/>
1229 </xsl:apply-templates>
1230 <xsl:text>));
1231</xsl:text>
1232 <xsl:if test="ancestor::interface[@wrap-gen-hook = 'yes']">
1233 <xsl:text>
1234 i_callHook(__FUNCTION__);</xsl:text>
1235 </xsl:if>
1236<xsl:text>
1237 VirtualBoxBase::clearError();
1238
1239 HRESULT hrc;
1240
1241 try
1242 {
1243 CheckComArgOutPointerValidThrow(a</xsl:text>
1244 <xsl:value-of select="$attrbasename"/>
1245 <xsl:text>);
1246 </xsl:text>
1247 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1248 <xsl:with-param name="dir" select="'out'"/>
1249 </xsl:apply-templates>
1250 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1251 <xsl:text>
1252#ifdef VBOX_WITH_DTRACE_R3_MAIN
1253 </xsl:text>
1254 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1255 <xsl:text>this);
1256#endif</xsl:text>
1257 </xsl:if>
1258 <xsl:text>
1259 </xsl:text>
1260 <xsl:choose>
1261 <xsl:when test="$limitedAutoCaller = 'true'">
1262 <xsl:text>AutoLimitedCaller</xsl:text>
1263 </xsl:when>
1264 <xsl:otherwise>
1265 <xsl:text>AutoCaller</xsl:text>
1266 </xsl:otherwise>
1267 </xsl:choose>
1268 <xsl:text> autoCaller(this);
1269 hrc = autoCaller.rc();
1270 if (SUCCEEDED(hrc))
1271 {
1272</xsl:text>
1273 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
1274 <xsl:variable name="passAutoCaller">
1275 <xsl:call-template name="checkoption">
1276 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1277 <xsl:with-param name="option" select="'passcaller'"/>
1278 </xsl:call-template>
1279 </xsl:variable>
1280 <xsl:if test="$passAutoCaller = 'true'">
1281 <xsl:text>autoCaller, </xsl:text>
1282 </xsl:if>
1283 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1284 <xsl:with-param name="dir" select="'out'"/>
1285 </xsl:apply-templates>
1286 <xsl:text>);
1287 }</xsl:text>
1288 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1289 <xsl:text>
1290#ifdef VBOX_WITH_DTRACE_R3_MAIN
1291 </xsl:text>
1292 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1293 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1294 <xsl:call-template name="emitDTraceParamValue">
1295 <xsl:with-param name="dir">out</xsl:with-param>
1296 </xsl:call-template>
1297 <xsl:text>);
1298#endif</xsl:text>
1299 </xsl:if>
1300 <xsl:text>
1301 }
1302 catch (HRESULT hrc2)
1303 {
1304 hrc = hrc2;</xsl:text>
1305 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1306 <xsl:text>
1307#ifdef VBOX_WITH_DTRACE_R3_MAIN
1308 </xsl:text>
1309 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1310 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1311 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1312 <xsl:text>);
1313#endif</xsl:text>
1314 </xsl:if>
1315 <xsl:text>
1316 }
1317 catch (...)
1318 {
1319 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);</xsl:text>
1320 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1321 <xsl:text>
1322#ifdef VBOX_WITH_DTRACE_R3_MAIN
1323 </xsl:text>
1324 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1325 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1326 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1327 <xsl:text>);
1328#endif</xsl:text>
1329 </xsl:if>
1330 <xsl:text>
1331 }
1332
1333 LogRelFlow(("{%p} %s: leave </xsl:text>
1334 <xsl:apply-templates select="@type" mode="logparamtext">
1335 <xsl:with-param name="dir" select="'out'"/>
1336 <xsl:with-param name="isref" select="''"/>
1337 </xsl:apply-templates>
1338 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
1339 <xsl:value-of select="concat('&quot;', $topclass, '::get', $dtraceattrname, '&quot;, ')"/>
1340 <xsl:apply-templates select="@type" mode="logparamval">
1341 <xsl:with-param name="dir" select="'out'"/>
1342 <xsl:with-param name="isref" select="''"/>
1343 </xsl:apply-templates>
1344 <xsl:text>, hrc));
1345 return hrc;</xsl:text>
1346 <xsl:if test="$attrbasename = 'MidlDoesNotLikeEmptyInterfaces'">
1347 <xsl:text>
1348#else /* dummy attribute */
1349 NOREF(aMidlDoesNotLikeEmptyInterfaces);
1350 return E_FAIL;
1351#endif /* dummy attribute */</xsl:text>
1352 </xsl:if>
1353 <xsl:text>
1354}
1355</xsl:text>
1356 <xsl:if test="not(@readonly) or @readonly!='yes'">
1357 <xsl:text>
1358</xsl:text>
1359 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
1360 <xsl:call-template name="emitPublicParameter">
1361 <xsl:with-param name="dir">in</xsl:with-param>
1362 </xsl:call-template>
1363 <!-- @todo check in parameters if possible -->
1364 <xsl:text>)
1365{
1366 LogRelFlow(("{%p} %s: enter </xsl:text>
1367 <xsl:apply-templates select="@type" mode="logparamtext">
1368 <xsl:with-param name="dir" select="'in'"/>
1369 <xsl:with-param name="isref" select="''"/>
1370 </xsl:apply-templates>
1371 <xsl:text>\n", this, </xsl:text>
1372 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1373 <xsl:apply-templates select="@type" mode="logparamval">
1374 <xsl:with-param name="dir" select="'in'"/>
1375 <xsl:with-param name="isref" select="''"/>
1376 </xsl:apply-templates>
1377 <xsl:text>));
1378</xsl:text>
1379 <xsl:if test="ancestor::interface[@wrap-gen-hook = 'yes']">
1380 <xsl:text>
1381 i_callHook(__FUNCTION__);</xsl:text>
1382 </xsl:if>
1383<xsl:text>
1384 VirtualBoxBase::clearError();
1385
1386 HRESULT hrc;
1387
1388 try
1389 {
1390 </xsl:text>
1391 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1392 <xsl:with-param name="dir" select="'in'"/>
1393 </xsl:apply-templates>
1394 <xsl:text>
1395
1396#ifdef VBOX_WITH_DTRACE_R3_MAIN
1397 </xsl:text>
1398 <xsl:value-of select="translate(concat('VBOXAPI_', $topclass, '_SET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1399 <xsl:text>this, </xsl:text>
1400 <xsl:call-template name="emitDTraceParamValue">
1401 <xsl:with-param name="dir">in</xsl:with-param>
1402 </xsl:call-template>
1403 <xsl:text>);
1404#endif
1405 </xsl:text>
1406 <xsl:choose>
1407 <xsl:when test="$limitedAutoCaller = 'true'">
1408 <xsl:text>AutoLimitedCaller</xsl:text>
1409 </xsl:when>
1410 <xsl:otherwise>
1411 <xsl:text>AutoCaller</xsl:text>
1412 </xsl:otherwise>
1413 </xsl:choose>
1414 <xsl:text> autoCaller(this);
1415 hrc = autoCaller.rc();
1416 if (SUCCEEDED(hrc))
1417 {
1418</xsl:text>
1419 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
1420 <xsl:if test="$passAutoCaller = 'true'">
1421 <xsl:text>autoCaller, </xsl:text>
1422 </xsl:if>
1423 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1424 <xsl:with-param name="dir" select="'in'"/>
1425 </xsl:apply-templates>
1426 <xsl:text>);
1427 }
1428#ifdef VBOX_WITH_DTRACE_R3_MAIN
1429 </xsl:text>
1430 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1431 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1432 <xsl:call-template name="emitDTraceParamValue">
1433 <xsl:with-param name="dir">in</xsl:with-param>
1434 </xsl:call-template>
1435 <xsl:text>);
1436#endif
1437 }
1438 catch (HRESULT hrc2)
1439 {
1440 hrc = hrc2;
1441#ifdef VBOX_WITH_DTRACE_R3_MAIN
1442 </xsl:text>
1443 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1444 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1445 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1446 <xsl:text>);
1447#endif
1448 }
1449 catch (...)
1450 {
1451 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1452#ifdef VBOX_WITH_DTRACE_R3_MAIN
1453 </xsl:text>
1454 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1455 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1456 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1457 <xsl:text>);
1458#endif
1459 }
1460
1461 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1462 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1463 <xsl:text>hrc));
1464 return hrc;
1465}
1466</xsl:text>
1467 </xsl:if>
1468
1469 <xsl:call-template name="emitTargetEnd">
1470 <xsl:with-param name="target" select="$target"/>
1471 </xsl:call-template>
1472
1473 <xsl:call-template name="xsltprocNewlineOutputHack"/>
1474</xsl:template>
1475
1476<!-- - - - - - - - - - - - - - - - - - - - - - -
1477 Emit DTrace probes for the given attribute.
1478 - - - - - - - - - - - - - - - - - - - - - - -->
1479<xsl:template match="attribute" mode="dtrace-probes">
1480 <xsl:param name="topclass"/>
1481 <xsl:param name="dtracetopclass"/>
1482 <xsl:param name="target"/>
1483
1484 <xsl:variable name="dtraceattrname">
1485 <xsl:choose>
1486 <xsl:when test="@dtracename">
1487 <xsl:value-of select="@dtracename"/>
1488 </xsl:when>
1489 <xsl:otherwise>
1490 <!-- attrbasename -->
1491 <xsl:call-template name="capitalize">
1492 <xsl:with-param name="str" select="@name"/>
1493 </xsl:call-template>
1494 </xsl:otherwise>
1495 </xsl:choose>
1496 </xsl:variable>
1497
1498 <xsl:if test="@name != 'midlDoesNotLikeEmptyInterfaces'">
1499 <xsl:text> probe </xsl:text>
1500 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(struct ', $topclass)"/> -->
1501 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(void')"/>
1502 <xsl:text> *a_pThis);
1503 probe </xsl:text>
1504 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1505 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(void *a_pThis')"/>
1506 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1507 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1508 <xsl:with-param name="dir">out</xsl:with-param>
1509 </xsl:apply-templates>
1510 <xsl:text>);
1511</xsl:text>
1512 </xsl:if>
1513 <xsl:if test="(not(@readonly) or @readonly!='yes') and @name != 'midlDoesNotLikeEmptyInterfaces'">
1514 <xsl:text> probe </xsl:text>
1515 <!-- <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(struct ', $topclass, ' *a_pThis, ')"/>-->
1516 <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(void *a_pThis, ')"/>
1517 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1518 <xsl:with-param name="dir" select="'in'"/>
1519 </xsl:apply-templates>
1520 <xsl:text>);
1521 probe </xsl:text>
1522 <!-- <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1523 <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(void *a_pThis')"/>
1524 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1525 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1526 <xsl:with-param name="dir">in</xsl:with-param>
1527 </xsl:apply-templates>
1528 <xsl:text>);
1529</xsl:text>
1530 </xsl:if>
1531</xsl:template>
1532
1533<!-- - - - - - - - - - - - - - - - - - - - - - -
1534 Emit all attributes of an interface (current node).
1535 - - - - - - - - - - - - - - - - - - - - - - -->
1536<xsl:template name="emitAttributes">
1537 <xsl:param name="topclass"/>
1538 <xsl:param name="dtracetopclass"/>
1539 <xsl:param name="pmode"/>
1540
1541 <xsl:variable name="name" select="@name"/>
1542 <!-- first recurse to emit all base interfaces -->
1543 <xsl:variable name="extends" select="@extends"/>
1544 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1545 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
1546 <xsl:call-template name="emitAttributes">
1547 <xsl:with-param name="topclass" select="$topclass"/>
1548 <xsl:with-param name="pmode" select="$pmode"/>
1549 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1550 </xsl:call-template>
1551 </xsl:for-each>
1552 </xsl:if>
1553
1554 <xsl:choose>
1555 <xsl:when test="$pmode='code'">
1556 <xsl:text>//
1557</xsl:text>
1558 <xsl:value-of select="concat('// ', $name, ' properties')"/>
1559 <xsl:text>
1560//
1561
1562</xsl:text>
1563 </xsl:when>
1564 <xsl:when test="$pmode != 'dtrace-probes'">
1565 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', $name, ' properties', $G_sNewLine)"/>
1566 </xsl:when>
1567 </xsl:choose>
1568 <xsl:choose>
1569 <xsl:when test="$pmode='public'">
1570 <xsl:apply-templates select="./attribute | ./if" mode="public">
1571 <xsl:with-param name="emitmode" select="'attribute'"/>
1572 </xsl:apply-templates>
1573 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1574 <xsl:if test="$reservedAttributes > 0">
1575 <!-- tricky way to do a "for" loop without recursion -->
1576 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1577 <xsl:text> STDMETHOD(COMGETTER(InternalAndReservedAttribute</xsl:text>
1578 <xsl:value-of select="concat(position(), $name)"/>
1579 <xsl:text>))(ULONG *aReserved);&#x0A;</xsl:text>
1580 </xsl:for-each>
1581 </xsl:if>
1582 </xsl:when>
1583 <xsl:when test="$pmode='wrapped'">
1584 <xsl:apply-templates select="./attribute | ./if" mode="wrapped">
1585 <xsl:with-param name="emitmode" select="'attribute'"/>
1586 </xsl:apply-templates>
1587 </xsl:when>
1588 <xsl:when test="$pmode='code'">
1589 <xsl:apply-templates select="./attribute | ./if" mode="code">
1590 <xsl:with-param name="topclass" select="$topclass"/>
1591 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1592 <xsl:with-param name="emitmode" select="'attribute'"/>
1593 </xsl:apply-templates>
1594 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1595 <xsl:if test="$reservedAttributes > 0">
1596 <!-- tricky way to do a "for" loop without recursion -->
1597 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1598 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(InternalAndReservedAttribute', position(), $name, ')(ULONG *aReserved)&#x0A;')"/>
1599 <xsl:text>{
1600 NOREF(aReserved);
1601 return E_NOTIMPL;
1602}
1603
1604</xsl:text>
1605 </xsl:for-each>
1606 </xsl:if>
1607 </xsl:when>
1608 <xsl:when test="$pmode = 'dtrace-probes'">
1609 <xsl:apply-templates select="./attribute | ./if" mode="dtrace-probes">
1610 <xsl:with-param name="topclass" select="$topclass"/>
1611 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1612 <xsl:with-param name="emitmode" select="'attribute'"/>
1613 </xsl:apply-templates>
1614 </xsl:when>
1615 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitAttributes</xsl:message></xsl:otherwise>
1616 </xsl:choose>
1617</xsl:template>
1618
1619<xsl:template name="emitTargetBegin">
1620 <xsl:param name="target"/>
1621
1622 <xsl:choose>
1623 <xsl:when test="$target = ''"/>
1624 <xsl:when test="$target = 'xpidl'">
1625 <xsl:text>#ifdef VBOX_WITH_XPCOM
1626</xsl:text>
1627 </xsl:when>
1628 <xsl:when test="$target = 'midl'">
1629 <xsl:text>#ifndef VBOX_WITH_XPCOM
1630</xsl:text>
1631 </xsl:when>
1632 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetBegin: target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1633 </xsl:choose>
1634</xsl:template>
1635
1636<xsl:template name="emitTargetEnd">
1637 <xsl:param name="target"/>
1638
1639 <xsl:choose>
1640 <xsl:when test="$target = ''"/>
1641 <xsl:when test="$target = 'xpidl'">
1642 <xsl:text>#endif /* VBOX_WITH_XPCOM */
1643</xsl:text>
1644 </xsl:when>
1645 <xsl:when test="$target = 'midl'">
1646 <xsl:text>#endif /* !VBOX_WITH_XPCOM */
1647</xsl:text>
1648 </xsl:when>
1649 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetEnd target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1650 </xsl:choose>
1651</xsl:template>
1652
1653
1654<!-- - - - - - - - - - - - - - - - - - - - - - -
1655 emit method
1656 - - - - - - - - - - - - - - - - - - - - - - -->
1657
1658<xsl:template match="method" mode="public">
1659 <xsl:param name="target"/>
1660
1661 <xsl:call-template name="emitTargetBegin">
1662 <xsl:with-param name="target" select="$target"/>
1663 </xsl:call-template>
1664
1665 <xsl:variable name="methodindent">
1666 <xsl:call-template name="tospace">
1667 <xsl:with-param name="str" select="@name"/>
1668 </xsl:call-template>
1669 </xsl:variable>
1670
1671 <xsl:text> STDMETHOD(</xsl:text>
1672 <xsl:call-template name="capitalize">
1673 <xsl:with-param name="str" select="@name"/>
1674 </xsl:call-template>
1675 <xsl:text>)(</xsl:text>
1676 <xsl:for-each select="param">
1677 <xsl:call-template name="emitPublicParameter">
1678 <xsl:with-param name="dir" select="@dir"/>
1679 </xsl:call-template>
1680 <xsl:if test="not(position()=last())">
1681 <xsl:text>,
1682 </xsl:text>
1683 <xsl:value-of select="$methodindent"/>
1684 </xsl:if>
1685 </xsl:for-each>
1686 <xsl:text>);
1687</xsl:text>
1688
1689 <xsl:call-template name="emitTargetEnd">
1690 <xsl:with-param name="target" select="$target"/>
1691 </xsl:call-template>
1692</xsl:template>
1693
1694<xsl:template match="method" mode="wrapped">
1695 <xsl:param name="target"/>
1696
1697 <xsl:call-template name="emitTargetBegin">
1698 <xsl:with-param name="target" select="$target"/>
1699 </xsl:call-template>
1700
1701 <xsl:variable name="methodindent">
1702 <xsl:call-template name="tospace">
1703 <xsl:with-param name="str" select="@name"/>
1704 </xsl:call-template>
1705 </xsl:variable>
1706
1707 <xsl:text> virtual HRESULT </xsl:text>
1708 <xsl:call-template name="uncapitalize">
1709 <xsl:with-param name="str" select="@name"/>
1710 </xsl:call-template>
1711 <xsl:text>(</xsl:text>
1712 <xsl:variable name="passAutoCaller">
1713 <xsl:call-template name="checkoption">
1714 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1715 <xsl:with-param name="option" select="'passcaller'"/>
1716 </xsl:call-template>
1717 </xsl:variable>
1718 <xsl:if test="$passAutoCaller = 'true'">
1719 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1720 <xsl:if test="count(param) > 0">
1721 <xsl:text>,
1722 </xsl:text>
1723 <xsl:value-of select="$methodindent"/>
1724 </xsl:if>
1725 </xsl:if>
1726 <xsl:for-each select="param">
1727 <xsl:apply-templates select="@type" mode="wrapped">
1728 <xsl:with-param name="dir" select="@dir"/>
1729 </xsl:apply-templates>
1730 <xsl:if test="not(position()=last())">
1731 <xsl:text>,
1732 </xsl:text>
1733 <xsl:value-of select="$methodindent"/>
1734 </xsl:if>
1735 </xsl:for-each>
1736 <xsl:text>) = 0;
1737</xsl:text>
1738
1739 <xsl:call-template name="emitTargetEnd">
1740 <xsl:with-param name="target" select="$target"/>
1741 </xsl:call-template>
1742</xsl:template>
1743
1744<xsl:template match="method" mode="code">
1745 <xsl:param name="topclass"/>
1746 <xsl:param name="dtracetopclass"/>
1747 <xsl:param name="target"/>
1748
1749 <xsl:call-template name="emitTargetBegin">
1750 <xsl:with-param name="target" select="$target"/>
1751 </xsl:call-template>
1752
1753 <xsl:variable name="methodindent">
1754 <xsl:call-template name="tospace">
1755 <xsl:with-param name="str" select="@name"/>
1756 </xsl:call-template>
1757 </xsl:variable>
1758 <xsl:variable name="methodclassindent">
1759 <xsl:call-template name="tospace">
1760 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1761 </xsl:call-template>
1762 </xsl:variable>
1763 <xsl:variable name="methodbasename">
1764 <xsl:call-template name="capitalize">
1765 <xsl:with-param name="str" select="@name"/>
1766 </xsl:call-template>
1767 </xsl:variable>
1768 <xsl:variable name="limitedAutoCaller">
1769 <xsl:call-template name="checkoption">
1770 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1771 <xsl:with-param name="option" select="'limitedcaller'"/>
1772 </xsl:call-template>
1773 </xsl:variable>
1774 <xsl:variable name="dtracemethodname">
1775 <xsl:choose>
1776 <xsl:when test="@dtracename">
1777 <xsl:value-of select="@dtracename"/>
1778 </xsl:when>
1779 <xsl:otherwise>
1780 <xsl:value-of select="@name"/>
1781 </xsl:otherwise>
1782 </xsl:choose>
1783 </xsl:variable>
1784 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1785 <xsl:if test="name(..) = 'if'">
1786 <xsl:value-of select="concat('__', ../@target)"/>
1787 </xsl:if>
1788 </xsl:variable>
1789
1790 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1791 <xsl:for-each select="param">
1792 <xsl:call-template name="emitPublicParameter">
1793 <xsl:with-param name="dir" select="@dir"/>
1794 </xsl:call-template>
1795 <xsl:if test="not(position()=last())">
1796 <xsl:text>,
1797 </xsl:text>
1798 <xsl:value-of select="$methodclassindent"/>
1799 </xsl:if>
1800 </xsl:for-each>
1801 <xsl:text>)
1802{
1803 LogRelFlow(("{%p} %s:enter</xsl:text>
1804 <xsl:for-each select="param">
1805 <xsl:text> </xsl:text>
1806 <xsl:apply-templates select="@type" mode="logparamtext">
1807 <xsl:with-param name="dir" select="@dir"/>
1808 <xsl:with-param name="isref" select="'yes'"/>
1809 </xsl:apply-templates>
1810 </xsl:for-each>
1811 <xsl:text>\n", this</xsl:text>
1812 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1813 <xsl:for-each select="param">
1814 <xsl:text>, </xsl:text>
1815 <xsl:apply-templates select="@type" mode="logparamval">
1816 <xsl:with-param name="dir" select="@dir"/>
1817 <xsl:with-param name="isref" select="'yes'"/>
1818 </xsl:apply-templates>
1819 </xsl:for-each>
1820 <xsl:text>));
1821</xsl:text>
1822 <xsl:if test="ancestor::interface[@wrap-gen-hook = 'yes']">
1823 <xsl:text>
1824 i_callHook(__FUNCTION__);</xsl:text>
1825 </xsl:if>
1826<xsl:text>
1827 VirtualBoxBase::clearError();
1828
1829 HRESULT hrc;
1830
1831 try
1832 {
1833</xsl:text>
1834 <!-- @todo check in parameters if possible -->
1835 <xsl:for-each select="param">
1836 <xsl:if test="@dir!='in'">
1837 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1838 <xsl:call-template name="capitalize">
1839 <xsl:with-param name="str" select="@name"/>
1840 </xsl:call-template>
1841 <xsl:text>);
1842</xsl:text>
1843 </xsl:if>
1844 </xsl:for-each>
1845<xsl:text>
1846</xsl:text>
1847 <xsl:for-each select="param">
1848 <xsl:text>
1849 </xsl:text>
1850 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1851 <xsl:with-param name="dir" select="@dir"/>
1852 </xsl:apply-templates>
1853 </xsl:for-each>
1854 <xsl:text>
1855
1856#ifdef VBOX_WITH_DTRACE_R3_MAIN
1857 </xsl:text>
1858 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1859 <xsl:text>this</xsl:text>
1860 <xsl:for-each select="param[@dir='in']">
1861 <xsl:text>, </xsl:text>
1862 <xsl:call-template name="emitDTraceParamValue">
1863 <xsl:with-param name="dir" select="@dir"/>
1864 </xsl:call-template>
1865 </xsl:for-each>
1866 <xsl:text>);
1867#endif
1868 </xsl:text>
1869 <xsl:choose>
1870 <xsl:when test="$limitedAutoCaller = 'true'">
1871 <xsl:text>AutoLimitedCaller</xsl:text>
1872 </xsl:when>
1873 <xsl:otherwise>
1874 <xsl:text>AutoCaller</xsl:text>
1875 </xsl:otherwise>
1876 </xsl:choose>
1877 <xsl:text> autoCaller(this);
1878 hrc = autoCaller.rc();
1879 if (SUCCEEDED(hrc))
1880 {
1881</xsl:text>
1882 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1883 <xsl:variable name="passAutoCaller">
1884 <xsl:call-template name="checkoption">
1885 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1886 <xsl:with-param name="option" select="'passcaller'"/>
1887 </xsl:call-template>
1888 </xsl:variable>
1889 <xsl:if test="$passAutoCaller = 'true'">
1890 <xsl:text>autoCaller</xsl:text>
1891 <xsl:if test="count(param) > 0">
1892 <xsl:text>,
1893 </xsl:text>
1894 <xsl:value-of select="$methodindent"/>
1895 </xsl:if>
1896 </xsl:if>
1897 <xsl:for-each select="param">
1898 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1899 <xsl:with-param name="dir" select="@dir"/>
1900 </xsl:apply-templates>
1901 <xsl:if test="not(position()=last())">
1902 <xsl:text>,
1903 </xsl:text>
1904 <xsl:value-of select="$methodindent"/>
1905 </xsl:if>
1906 </xsl:for-each>
1907 <xsl:text>);
1908 }
1909#ifdef VBOX_WITH_DTRACE_R3_MAIN
1910 </xsl:text>
1911 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1912 <xsl:text>this, hrc, 0 /*normal*/</xsl:text>
1913 <xsl:for-each select="param">
1914 <xsl:text>, </xsl:text>
1915 <xsl:call-template name="emitDTraceParamValue">
1916 <xsl:with-param name="dir" select="@dir"/>
1917 </xsl:call-template>
1918 </xsl:for-each>
1919 <xsl:text>);
1920#endif
1921 }
1922 catch (HRESULT hrc2)
1923 {
1924 hrc = hrc2;
1925#ifdef VBOX_WITH_DTRACE_R3_MAIN
1926 </xsl:text>
1927 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1928 <xsl:text>this, hrc, 1 /*hrc exception*/</xsl:text>
1929 <xsl:for-each select="param">
1930 <xsl:text>, </xsl:text>
1931 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1932 </xsl:for-each>
1933 <xsl:text>);
1934#endif
1935 }
1936 catch (...)
1937 {
1938 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1939#ifdef VBOX_WITH_DTRACE_R3_MAIN
1940 </xsl:text>
1941 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1942 <xsl:text>this, hrc, 9 /*unhandled exception*/</xsl:text>
1943 <xsl:for-each select="param">
1944 <xsl:text>, </xsl:text>
1945 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1946 </xsl:for-each>
1947 <xsl:text>);
1948#endif
1949 }
1950
1951 LogRelFlow(("{%p} %s: leave</xsl:text>
1952 <xsl:for-each select="param">
1953 <xsl:if test="@dir!='in'">
1954 <xsl:text> </xsl:text>
1955 <xsl:apply-templates select="@type" mode="logparamtext">
1956 <xsl:with-param name="dir" select="@dir"/>
1957 <xsl:with-param name="isref" select="''"/>
1958 </xsl:apply-templates>
1959 </xsl:if>
1960 </xsl:for-each>
1961 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1962 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1963 <xsl:for-each select="param">
1964 <xsl:if test="@dir!='in'">
1965 <xsl:text>, </xsl:text>
1966 <xsl:apply-templates select="@type" mode="logparamval">
1967 <xsl:with-param name="dir" select="@dir"/>
1968 <xsl:with-param name="isref" select="''"/>
1969 </xsl:apply-templates>
1970 </xsl:if>
1971 </xsl:for-each>
1972 <xsl:text>, hrc));
1973 return hrc;
1974}
1975</xsl:text>
1976
1977 <xsl:call-template name="emitTargetEnd">
1978 <xsl:with-param name="target" select="$target"/>
1979 </xsl:call-template>
1980
1981 <xsl:text>
1982</xsl:text>
1983</xsl:template>
1984
1985<!-- - - - - - - - - - - - - - - - - - - - - - -
1986 Emits the DTrace probes for a method.
1987 - - - - - - - - - - - - - - - - - - - - - - -->
1988<xsl:template match="method" mode="dtrace-probes">
1989 <xsl:param name="topclass"/>
1990 <xsl:param name="dtracetopclass"/>
1991 <xsl:param name="target"/>
1992
1993 <xsl:variable name="dtracemethodname">
1994 <xsl:choose>
1995 <xsl:when test="@dtracename">
1996 <xsl:value-of select="@dtracename"/>
1997 </xsl:when>
1998 <xsl:otherwise>
1999 <xsl:value-of select="@name"/>
2000 </xsl:otherwise>
2001 </xsl:choose>
2002 </xsl:variable>
2003 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
2004 <xsl:if test="name(..) = 'if'">
2005 <xsl:value-of select="concat('__', ../@target)"/>
2006 </xsl:if>
2007 </xsl:variable>
2008
2009 <xsl:text> probe </xsl:text>
2010 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(struct ', $dtracetopclass, ' *a_pThis')"/> -->
2011 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(void *a_pThis')"/>
2012 <xsl:for-each select="param[@dir='in']">
2013 <xsl:text>, </xsl:text>
2014 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
2015 <xsl:with-param name="dir" select="'@dir'"/>
2016 </xsl:apply-templates>
2017 </xsl:for-each>
2018 <xsl:text>);
2019 probe </xsl:text>
2020 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, '__return(struct ', $dtracetopclass, ' *a_pThis')"/> -->
2021 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__return(void *a_pThis')"/>
2022 <xsl:text>, uint32_t a_hrc, int32_t enmWhy</xsl:text>
2023 <xsl:for-each select="param">
2024 <xsl:text>, </xsl:text>
2025 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
2026 <xsl:with-param name="dir" select="'@dir'"/>
2027 </xsl:apply-templates>
2028 </xsl:for-each>
2029 <xsl:text>);
2030</xsl:text>
2031
2032</xsl:template>
2033
2034
2035<xsl:template name="emitIf">
2036 <xsl:param name="passmode"/>
2037 <xsl:param name="target"/>
2038 <xsl:param name="topclass"/>
2039 <xsl:param name="emitmode"/>
2040 <xsl:param name="dtracetopclass"/>
2041
2042 <xsl:if test="($target = 'xpidl') or ($target = 'midl')">
2043 <xsl:choose>
2044 <xsl:when test="$passmode='public'">
2045 <xsl:choose>
2046 <xsl:when test="$emitmode='method'">
2047 <xsl:apply-templates select="method" mode="public">
2048 <xsl:with-param name="target" select="$target"/>
2049 </xsl:apply-templates>
2050 </xsl:when>
2051 <xsl:when test="$emitmode='attribute'">
2052 <xsl:apply-templates select="attribute" mode="public">
2053 <xsl:with-param name="target" select="$target"/>
2054 </xsl:apply-templates>
2055 </xsl:when>
2056 <xsl:otherwise/>
2057 </xsl:choose>
2058 </xsl:when>
2059 <xsl:when test="$passmode='wrapped'">
2060 <xsl:choose>
2061 <xsl:when test="$emitmode='method'">
2062 <xsl:apply-templates select="method" mode="wrapped">
2063 <xsl:with-param name="target" select="$target"/>
2064 </xsl:apply-templates>
2065 </xsl:when>
2066 <xsl:when test="$emitmode='attribute'">
2067 <xsl:apply-templates select="attribute" mode="wrapped">
2068 <xsl:with-param name="target" select="$target"/>
2069 </xsl:apply-templates>
2070 </xsl:when>
2071 <xsl:otherwise/>
2072 </xsl:choose>
2073 </xsl:when>
2074 <xsl:when test="$passmode='code'">
2075 <xsl:choose>
2076 <xsl:when test="$emitmode='method'">
2077 <xsl:apply-templates select="method" mode="code">
2078 <xsl:with-param name="target" select="$target"/>
2079 <xsl:with-param name="topclass" select="$topclass"/>
2080 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2081 </xsl:apply-templates>
2082 </xsl:when>
2083 <xsl:when test="$emitmode='attribute'">
2084 <xsl:apply-templates select="attribute" mode="code">
2085 <xsl:with-param name="target" select="$target"/>
2086 <xsl:with-param name="topclass" select="$topclass"/>
2087 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2088 </xsl:apply-templates>
2089 </xsl:when>
2090 <xsl:otherwise/>
2091 </xsl:choose>
2092 </xsl:when>
2093 <xsl:when test="$passmode = 'dtrace-probes'">
2094 <xsl:choose>
2095 <xsl:when test="$emitmode = 'method'">
2096 <xsl:apply-templates select="method" mode="dtrace-probes">
2097 <xsl:with-param name="target" select="$target"/>
2098 <xsl:with-param name="topclass" select="$topclass"/>
2099 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2100 </xsl:apply-templates>
2101 </xsl:when>
2102 <xsl:when test="$emitmode = 'attribute'">
2103 <xsl:apply-templates select="attribute" mode="dtrace-probes">
2104 <xsl:with-param name="target" select="$target"/>
2105 <xsl:with-param name="topclass" select="$topclass"/>
2106 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2107 </xsl:apply-templates>
2108 </xsl:when>
2109 <xsl:otherwise/>
2110 </xsl:choose>
2111 </xsl:when>
2112 <xsl:otherwise/>
2113 </xsl:choose>
2114 </xsl:if>
2115</xsl:template>
2116
2117<xsl:template match="if" mode="public">
2118 <xsl:param name="emitmode"/>
2119
2120 <xsl:call-template name="emitIf">
2121 <xsl:with-param name="passmode" select="'public'"/>
2122 <xsl:with-param name="target" select="@target"/>
2123 <xsl:with-param name="emitmode" select="$emitmode"/>
2124 </xsl:call-template>
2125</xsl:template>
2126
2127<xsl:template match="if" mode="wrapped">
2128 <xsl:param name="emitmode"/>
2129
2130 <xsl:call-template name="emitIf">
2131 <xsl:with-param name="passmode" select="'wrapped'"/>
2132 <xsl:with-param name="target" select="@target"/>
2133 <xsl:with-param name="emitmode" select="$emitmode"/>
2134 </xsl:call-template>
2135</xsl:template>
2136
2137<xsl:template match="if" mode="code">
2138 <xsl:param name="topclass"/>
2139 <xsl:param name="emitmode"/>
2140 <xsl:param name="dtracetopclass"/>
2141
2142 <xsl:call-template name="emitIf">
2143 <xsl:with-param name="passmode" select="'code'"/>
2144 <xsl:with-param name="target" select="@target"/>
2145 <xsl:with-param name="emitmode" select="$emitmode"/>
2146 <xsl:with-param name="topclass" select="$topclass"/>
2147 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2148 </xsl:call-template>
2149</xsl:template>
2150
2151<xsl:template match="if" mode="dtrace-probes">
2152 <xsl:param name="topclass"/>
2153 <xsl:param name="emitmode"/>
2154 <xsl:param name="dtracetopclass"/>
2155
2156 <xsl:call-template name="emitIf">
2157 <xsl:with-param name="passmode" select="'dtrace-probes'"/>
2158 <xsl:with-param name="target" select="@target"/>
2159 <xsl:with-param name="emitmode" select="$emitmode"/>
2160 <xsl:with-param name="topclass" select="$topclass"/>
2161 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2162 </xsl:call-template>
2163</xsl:template>
2164
2165<!-- - - - - - - - - - - - - - - - - - - - - - -
2166 emit all methods of the current interface
2167 - - - - - - - - - - - - - - - - - - - - - - -->
2168<xsl:template name="emitMethods">
2169 <xsl:param name="topclass"/>
2170 <xsl:param name="pmode"/>
2171 <xsl:param name="dtracetopclass"/>
2172
2173 <xsl:variable name="name" select="@name"/>
2174 <!-- first recurse to emit all base interfaces -->
2175 <xsl:variable name="extends" select="@extends"/>
2176 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
2177 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
2178 <xsl:call-template name="emitMethods">
2179 <xsl:with-param name="topclass" select="$topclass"/>
2180 <xsl:with-param name="pmode" select="$pmode"/>
2181 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2182 </xsl:call-template>
2183 </xsl:for-each>
2184 </xsl:if>
2185
2186 <xsl:choose>
2187 <xsl:when test="$pmode='code'">
2188 <xsl:text>//
2189</xsl:text>
2190 <xsl:value-of select="concat('// ', $name, ' methods')"/>
2191 <xsl:text>
2192//
2193
2194</xsl:text>
2195 </xsl:when>
2196 <xsl:when test="$pmode='dtrace-probes'"/>
2197 <xsl:otherwise>
2198 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', $name, ' methods', $G_sNewLine)"/>
2199 </xsl:otherwise>
2200 </xsl:choose>
2201 <xsl:choose>
2202 <xsl:when test="$pmode='public'">
2203 <xsl:apply-templates select="./method | ./if" mode="public">
2204 <xsl:with-param name="emitmode" select="'method'"/>
2205 </xsl:apply-templates>
2206 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2207 <xsl:if test="$reservedMethods > 0">
2208 <!-- tricky way to do a "for" loop without recursion -->
2209 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2210 <xsl:text> STDMETHOD(InternalAndReservedMethod</xsl:text>
2211 <xsl:value-of select="concat(position(), $name)"/>
2212 <xsl:text>)();&#x0A;</xsl:text>
2213 </xsl:for-each>
2214 </xsl:if>
2215 </xsl:when>
2216 <xsl:when test="$pmode='wrapped'">
2217 <xsl:apply-templates select="./method | ./if" mode="wrapped">
2218 <xsl:with-param name="emitmode" select="'method'"/>
2219 </xsl:apply-templates>
2220 </xsl:when>
2221 <xsl:when test="$pmode='code'">
2222 <xsl:apply-templates select="./method | ./if" mode="code">
2223 <xsl:with-param name="topclass" select="$topclass"/>
2224 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2225 <xsl:with-param name="emitmode" select="'method'"/>
2226 </xsl:apply-templates>
2227 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2228 <xsl:if test="$reservedMethods > 0">
2229 <!-- tricky way to do a "for" loop without recursion -->
2230 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2231 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::InternalAndReservedMethod', position(), $name, '()&#x0A;')"/>
2232 <xsl:text>{
2233 return E_NOTIMPL;
2234}
2235
2236</xsl:text>
2237 </xsl:for-each>
2238 </xsl:if>
2239 </xsl:when>
2240 <xsl:when test="$pmode='dtrace-probes'">
2241 <xsl:apply-templates select="./method | ./if" mode="dtrace-probes">
2242 <xsl:with-param name="topclass" select="$topclass"/>
2243 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2244 <xsl:with-param name="emitmode" select="'method'"/>
2245 </xsl:apply-templates>
2246 </xsl:when>
2247 <xsl:otherwise/>
2248 </xsl:choose>
2249</xsl:template>
2250
2251<!-- - - - - - - - - - - - - - - - - - - - - - -
2252 emit all attributes and methods declarations of the current interface
2253 - - - - - - - - - - - - - - - - - - - - - - -->
2254<xsl:template name="emitInterfaceDecls">
2255 <xsl:param name="pmode"/>
2256
2257 <!-- attributes -->
2258 <xsl:call-template name="emitAttributes">
2259 <xsl:with-param name="pmode" select="$pmode"/>
2260 </xsl:call-template>
2261
2262 <!-- methods -->
2263 <xsl:call-template name="emitMethods">
2264 <xsl:with-param name="pmode" select="$pmode"/>
2265 </xsl:call-template>
2266</xsl:template>
2267
2268<!-- - - - - - - - - - - - - - - - - - - - - - -
2269 emit auxiliary method declarations of the current interface
2270 - - - - - - - - - - - - - - - - - - - - - - -->
2271<xsl:template name="emitAuxMethodDecls">
2272 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
2273</xsl:template>
2274
2275<!-- - - - - - - - - - - - - - - - - - - - - - -
2276 emit the header file of the current interface
2277 - - - - - - - - - - - - - - - - - - - - - - -->
2278<xsl:template name="emitHeader">
2279 <xsl:param name="addinterfaces"/>
2280
2281 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
2282
2283 <xsl:apply-templates select="." mode="startfile">
2284 <xsl:with-param name="file" select="$filename"/>
2285 </xsl:apply-templates>
2286 <xsl:call-template name="fileheader">
2287 <xsl:with-param name="name" select="$filename"/>
2288 <xsl:with-param name="class" select="substring(@name, 2)"/>
2289 <xsl:with-param name="type" select="'header'"/>
2290 </xsl:call-template>
2291 <xsl:apply-templates select="." mode="classheader">
2292 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2293 </xsl:apply-templates>
2294
2295 <!-- interface attributes/methods (public) -->
2296 <xsl:call-template name="emitInterfaceDecls">
2297 <xsl:with-param name="pmode" select="'public'"/>
2298 </xsl:call-template>
2299
2300 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2301 <!-- This is super tricky, as the for-each switches to the node set,
2302 which means the normal document isn't available any more. We get
2303 the data we need, uses a for-each to switch document and then a
2304 key() to look up the interface by name. -->
2305 <xsl:variable name="addifname">
2306 <xsl:value-of select="string(.)"/>
2307 </xsl:variable>
2308 <xsl:for-each select="$G_root">
2309 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2310 <xsl:call-template name="emitInterfaceDecls">
2311 <xsl:with-param name="pmode" select="'public'"/>
2312 </xsl:call-template>
2313 </xsl:for-each>
2314 </xsl:for-each>
2315 </xsl:for-each>
2316
2317 <!-- auxiliary methods (public) -->
2318 <xsl:call-template name="emitAuxMethodDecls"/>
2319
2320 <!-- switch to private -->
2321 <xsl:text>
2322private:</xsl:text>
2323
2324 <!-- wrapped interface attributes/methods (private) -->
2325 <xsl:call-template name="emitInterfaceDecls">
2326 <xsl:with-param name="pmode" select="'wrapped'"/>
2327 </xsl:call-template>
2328
2329 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2330 <!-- This is super tricky, as the for-each switches to the node set,
2331 which means the normal document isn't available any more. We get
2332 the data we need, uses a for-each to switch document and then a
2333 key() to look up the interface by name. -->
2334 <xsl:variable name="addifname">
2335 <xsl:value-of select="string(.)"/>
2336 </xsl:variable>
2337 <xsl:for-each select="$G_root">
2338 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2339 <xsl:call-template name="emitInterfaceDecls">
2340 <xsl:with-param name="pmode" select="'wrapped'"/>
2341 </xsl:call-template>
2342 </xsl:for-each>
2343 </xsl:for-each>
2344 </xsl:for-each>
2345
2346 <xsl:apply-templates select="." mode="classfooter"/>
2347 <xsl:apply-templates select="." mode="endfile">
2348 <xsl:with-param name="file" select="$filename"/>
2349 </xsl:apply-templates>
2350</xsl:template>
2351
2352<!-- - - - - - - - - - - - - - - - - - - - - - -
2353 emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of the current interface
2354 - - - - - - - - - - - - - - - - - - - - - - -->
2355<xsl:template name="emitInterfaceDefs">
2356 <xsl:param name="addinterfaces"/>
2357 <xsl:param name="pmode" select="'code'"/>
2358
2359 <xsl:variable name="topclass" select="substring(@name, 2)"/>
2360 <xsl:variable name="dtracetopclass">
2361 <xsl:choose>
2362 <xsl:when test="@dtracename"><xsl:value-of select="@dtracename"/></xsl:when>
2363 <xsl:otherwise><xsl:value-of select="$topclass"/></xsl:otherwise>
2364 </xsl:choose>
2365 </xsl:variable>
2366
2367 <xsl:if test="$pmode = 'code'">
2368 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', $topclass, 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
2369 </xsl:if>
2370
2371 <!-- attributes -->
2372 <xsl:call-template name="emitAttributes">
2373 <xsl:with-param name="topclass" select="$topclass"/>
2374 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2375 <xsl:with-param name="pmode" select="$pmode"/>
2376 </xsl:call-template>
2377
2378 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2379 <!-- This is super tricky, as the for-each switches to the node set,
2380 which means the normal document isn't available any more. We get
2381 the data we need, uses a for-each to switch document and then a
2382 key() to look up the interface by name. -->
2383 <xsl:variable name="addifname">
2384 <xsl:value-of select="string(.)"/>
2385 </xsl:variable>
2386 <xsl:for-each select="$G_root">
2387 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2388 <xsl:call-template name="emitAttributes">
2389 <xsl:with-param name="topclass" select="$topclass"/>
2390 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2391 <xsl:with-param name="pmode" select="$pmode"/>
2392 </xsl:call-template>
2393 </xsl:for-each>
2394 </xsl:for-each>
2395 </xsl:for-each>
2396
2397 <!-- methods -->
2398 <xsl:call-template name="xsltprocNewlineOutputHack"/>
2399 <xsl:call-template name="emitMethods">
2400 <xsl:with-param name="topclass" select="$topclass"/>
2401 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2402 <xsl:with-param name="pmode" select="$pmode"/>
2403 </xsl:call-template>
2404
2405 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2406 <!-- This is super tricky, as the for-each switches to the node set,
2407 which means the normal document isn't available any more. We get
2408 the data we need, uses a for-each to switch document and then a
2409 key() to look up the interface by name. -->
2410 <xsl:variable name="addifname">
2411 <xsl:value-of select="string(.)"/>
2412 </xsl:variable>
2413 <xsl:for-each select="$G_root">
2414 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2415 <xsl:call-template name="emitMethods">
2416 <xsl:with-param name="topclass" select="$topclass"/>
2417 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2418 <xsl:with-param name="pmode" select="$pmode"/>
2419 </xsl:call-template>
2420 </xsl:for-each>
2421 </xsl:for-each>
2422 </xsl:for-each>
2423</xsl:template>
2424
2425<!-- - - - - - - - - - - - - - - - - - - - - - -
2426 emit auxiliary method declarations of the current interface
2427 - - - - - - - - - - - - - - - - - - - - - - -->
2428<xsl:template name="emitAuxMethodDefs">
2429 <xsl:param name="pmode" select="'code'"/>
2430 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
2431</xsl:template>
2432
2433
2434<!-- - - - - - - - - - - - - - - - - - - - - - -
2435 emit the code file of the current interface
2436 - - - - - - - - - - - - - - - - - - - - - - -->
2437<xsl:template name="emitCode">
2438 <xsl:param name="addinterfaces"/>
2439
2440 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
2441
2442 <xsl:apply-templates select="." mode="startfile">
2443 <xsl:with-param name="file" select="$filename"/>
2444 </xsl:apply-templates>
2445 <xsl:call-template name="fileheader">
2446 <xsl:with-param name="name" select="$filename"/>
2447 <xsl:with-param name="class" select="substring(@name, 2)"/>
2448 <xsl:with-param name="type" select="'code'"/>
2449 </xsl:call-template>
2450 <xsl:apply-templates select="." mode="codeheader">
2451 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2452 </xsl:apply-templates>
2453
2454 <!-- interface attributes/methods (public) -->
2455 <xsl:call-template name="emitInterfaceDefs">
2456 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2457 </xsl:call-template>
2458
2459 <!-- auxiliary methods (public) -->
2460 <xsl:call-template name="emitAuxMethodDefs"/>
2461
2462 <xsl:apply-templates select="." mode="codefooter">
2463 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2464 </xsl:apply-templates>
2465 <xsl:apply-templates select="." mode="endfile">
2466 <xsl:with-param name="file" select="$filename"/>
2467 </xsl:apply-templates>
2468</xsl:template>
2469
2470<!-- - - - - - - - - - - - - - - - - - - - - - -
2471 emit the DTrace probes for the current interface
2472 - - - - - - - - - - - - - - - - - - - - - - -->
2473<xsl:template name="emitDTraceProbes">
2474 <xsl:param name="addinterfaces"/>
2475
2476 <!-- interface attributes/methods (public) -->
2477 <xsl:call-template name="emitInterfaceDefs">
2478 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2479 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2480 </xsl:call-template>
2481
2482 <!-- auxiliary methods (public) -->
2483 <xsl:call-template name="emitAuxMethodDefs">
2484 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2485 </xsl:call-template>
2486
2487</xsl:template>
2488
2489<!-- - - - - - - - - - - - - - - - - - - - - - -
2490 wildcard match, ignore everything which has no explicit match
2491 - - - - - - - - - - - - - - - - - - - - - - -->
2492
2493<xsl:template match="*"/>
2494
2495<!-- - - - - - - - - - - - - - - - - - - - - - -
2496 ignore all if tags except those for XPIDL or MIDL target
2497 - - - - - - - - - - - - - - - - - - - - - - -->
2498
2499<xsl:template match="if">
2500 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
2501 <xsl:apply-templates/>
2502 </xsl:if>
2503</xsl:template>
2504
2505<!-- - - - - - - - - - - - - - - - - - - - - - -
2506 interface match
2507 - - - - - - - - - - - - - - - - - - - - - - -->
2508
2509<xsl:template match="interface">
2510 <xsl:if test="not(@internal='yes') and not(@autogen='VBoxEvent') and not(@supportsErrorInfo='no')">
2511 <xsl:call-template name="emitInterface"/>
2512 </xsl:if>
2513</xsl:template>
2514
2515<!-- - - - - - - - - - - - - - - - - - - - - - -
2516 application match
2517 - - - - - - - - - - - - - - - - - - - - - - -->
2518
2519<xsl:template match="application">
2520 <xsl:apply-templates/>
2521</xsl:template>
2522
2523<!-- - - - - - - - - - - - - - - - - - - - - - -
2524 library match
2525 - - - - - - - - - - - - - - - - - - - - - - -->
2526
2527<xsl:template match="library">
2528 <xsl:apply-templates/>
2529</xsl:template>
2530
2531<!-- - - - - - - - - - - - - - - - - - - - - - -
2532 root match
2533 - - - - - - - - - - - - - - - - - - - - - - -->
2534
2535<xsl:template match="/idl">
2536 <xsl:choose>
2537 <xsl:when test="$generating = 'headers'">
2538 <xsl:apply-templates/>
2539 </xsl:when>
2540 <xsl:when test="$generating = 'sources'">
2541 <xsl:apply-templates/>
2542 </xsl:when>
2543 <xsl:when test="$generating = 'dtrace-probes'">
2544 <xsl:apply-templates/>
2545 </xsl:when>
2546 <xsl:otherwise>
2547 <xsl:message terminate="yes">
2548 Unknown string parameter value: generating='<xsl:value-of select="$generating"/>'
2549 </xsl:message>
2550 </xsl:otherwise>
2551 </xsl:choose>
2552</xsl:template>
2553
2554</xsl:stylesheet>
2555<!-- vi: set tabstop=4 shiftwidth=4 expandtab: -->
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette