VirtualBox

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

Last change on this file since 72324 was 66274, checked in by vboxsync, 8 years ago

VBox/Main: ​bugref:3300: VBoxSVC from terminal server session is not 'visible' - added VBoxSDS implementation

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