VirtualBox

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

最後變更 在這個檔案從76084是 76084,由 vboxsync 提交於 6 年 前

VBoxSDS: Enabled the process watcher for debug builds. bugref:3300 [build fix]

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 97.3 KB
 
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.alldomusa.eu.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.alldomusa.eu.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</xsl:text>
1224 <xsl:if test="@wrap-gen-hook='yes'">
1225 <xsl:text>
1226 callHook();
1227 <xsl:text>
1228 </xsl:if>
1229<xsl:text>
1230 VirtualBoxBase::clearError();
1231
1232 HRESULT hrc;
1233
1234 try
1235 {
1236 CheckComArgOutPointerValidThrow(a</xsl:text>
1237 <xsl:value-of select="$attrbasename"/>
1238 <xsl:text>);
1239 </xsl:text>
1240 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1241 <xsl:with-param name="dir" select="'out'"/>
1242 </xsl:apply-templates>
1243 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1244 <xsl:text>
1245#ifdef VBOX_WITH_DTRACE_R3_MAIN
1246 </xsl:text>
1247 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1248 <xsl:text>this);
1249#endif</xsl:text>
1250 </xsl:if>
1251 <xsl:text>
1252 </xsl:text>
1253 <xsl:choose>
1254 <xsl:when test="$limitedAutoCaller = 'true'">
1255 <xsl:text>AutoLimitedCaller</xsl:text>
1256 </xsl:when>
1257 <xsl:otherwise>
1258 <xsl:text>AutoCaller</xsl:text>
1259 </xsl:otherwise>
1260 </xsl:choose>
1261 <xsl:text> autoCaller(this);
1262 hrc = autoCaller.rc();
1263 if (SUCCEEDED(hrc))
1264 {
1265</xsl:text>
1266 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
1267 <xsl:variable name="passAutoCaller">
1268 <xsl:call-template name="checkoption">
1269 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1270 <xsl:with-param name="option" select="'passcaller'"/>
1271 </xsl:call-template>
1272 </xsl:variable>
1273 <xsl:if test="$passAutoCaller = 'true'">
1274 <xsl:text>autoCaller, </xsl:text>
1275 </xsl:if>
1276 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1277 <xsl:with-param name="dir" select="'out'"/>
1278 </xsl:apply-templates>
1279 <xsl:text>);
1280 }</xsl:text>
1281 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1282 <xsl:text>
1283#ifdef VBOX_WITH_DTRACE_R3_MAIN
1284 </xsl:text>
1285 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1286 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1287 <xsl:call-template name="emitDTraceParamValue">
1288 <xsl:with-param name="dir">out</xsl:with-param>
1289 </xsl:call-template>
1290 <xsl:text>);
1291#endif</xsl:text>
1292 </xsl:if>
1293 <xsl:text>
1294 }
1295 catch (HRESULT hrc2)
1296 {
1297 hrc = hrc2;</xsl:text>
1298 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1299 <xsl:text>
1300#ifdef VBOX_WITH_DTRACE_R3_MAIN
1301 </xsl:text>
1302 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1303 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1304 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1305 <xsl:text>);
1306#endif</xsl:text>
1307 </xsl:if>
1308 <xsl:text>
1309 }
1310 catch (...)
1311 {
1312 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);</xsl:text>
1313 <xsl:if test="$attrbasename != 'MidlDoesNotLikeEmptyInterfaces'">
1314 <xsl:text>
1315#ifdef VBOX_WITH_DTRACE_R3_MAIN
1316 </xsl:text>
1317 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_GET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1318 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1319 <xsl:call-template name="emitDTraceParamValNoTmp-DirNotIn"/>
1320 <xsl:text>);
1321#endif</xsl:text>
1322 </xsl:if>
1323 <xsl:text>
1324 }
1325
1326 LogRelFlow(("{%p} %s: leave </xsl:text>
1327 <xsl:apply-templates select="@type" mode="logparamtext">
1328 <xsl:with-param name="dir" select="'out'"/>
1329 <xsl:with-param name="isref" select="''"/>
1330 </xsl:apply-templates>
1331 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
1332 <xsl:value-of select="concat('&quot;', $topclass, '::get', $dtraceattrname, '&quot;, ')"/>
1333 <xsl:apply-templates select="@type" mode="logparamval">
1334 <xsl:with-param name="dir" select="'out'"/>
1335 <xsl:with-param name="isref" select="''"/>
1336 </xsl:apply-templates>
1337 <xsl:text>, hrc));
1338 return hrc;</xsl:text>
1339 <xsl:if test="$attrbasename = 'MidlDoesNotLikeEmptyInterfaces'">
1340 <xsl:text>
1341#else /* dummy attribute */
1342 NOREF(aMidlDoesNotLikeEmptyInterfaces);
1343 return E_FAIL;
1344#endif /* dummy attribute */</xsl:text>
1345 </xsl:if>
1346 <xsl:text>
1347}
1348</xsl:text>
1349 <xsl:if test="not(@readonly) or @readonly!='yes'">
1350 <xsl:text>
1351</xsl:text>
1352 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
1353 <xsl:call-template name="emitPublicParameter">
1354 <xsl:with-param name="dir">in</xsl:with-param>
1355 </xsl:call-template>
1356 <!-- @todo check in parameters if possible -->
1357 <xsl:text>)
1358{
1359 LogRelFlow(("{%p} %s: enter </xsl:text>
1360 <xsl:apply-templates select="@type" mode="logparamtext">
1361 <xsl:with-param name="dir" select="'in'"/>
1362 <xsl:with-param name="isref" select="''"/>
1363 </xsl:apply-templates>
1364 <xsl:text>\n", this, </xsl:text>
1365 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1366 <xsl:apply-templates select="@type" mode="logparamval">
1367 <xsl:with-param name="dir" select="'in'"/>
1368 <xsl:with-param name="isref" select="''"/>
1369 </xsl:apply-templates>
1370 <xsl:text>));
1371
1372 VirtualBoxBase::clearError();
1373
1374 HRESULT hrc;
1375
1376 try
1377 {
1378 </xsl:text>
1379 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1380 <xsl:with-param name="dir" select="'in'"/>
1381 </xsl:apply-templates>
1382 <xsl:text>
1383
1384#ifdef VBOX_WITH_DTRACE_R3_MAIN
1385 </xsl:text>
1386 <xsl:value-of select="translate(concat('VBOXAPI_', $topclass, '_SET_', $dtraceattrname, '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1387 <xsl:text>this, </xsl:text>
1388 <xsl:call-template name="emitDTraceParamValue">
1389 <xsl:with-param name="dir">in</xsl:with-param>
1390 </xsl:call-template>
1391 <xsl:text>);
1392#endif
1393 </xsl:text>
1394 <xsl:choose>
1395 <xsl:when test="$limitedAutoCaller = 'true'">
1396 <xsl:text>AutoLimitedCaller</xsl:text>
1397 </xsl:when>
1398 <xsl:otherwise>
1399 <xsl:text>AutoCaller</xsl:text>
1400 </xsl:otherwise>
1401 </xsl:choose>
1402 <xsl:text> autoCaller(this);
1403 hrc = autoCaller.rc();
1404 if (SUCCEEDED(hrc))
1405 {
1406</xsl:text>
1407 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
1408 <xsl:if test="$passAutoCaller = 'true'">
1409 <xsl:text>autoCaller, </xsl:text>
1410 </xsl:if>
1411 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1412 <xsl:with-param name="dir" select="'in'"/>
1413 </xsl:apply-templates>
1414 <xsl:text>);
1415 }
1416#ifdef VBOX_WITH_DTRACE_R3_MAIN
1417 </xsl:text>
1418 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1419 <xsl:text>this, hrc, 0 /*normal*/,</xsl:text>
1420 <xsl:call-template name="emitDTraceParamValue">
1421 <xsl:with-param name="dir">in</xsl:with-param>
1422 </xsl:call-template>
1423 <xsl:text>);
1424#endif
1425 }
1426 catch (HRESULT hrc2)
1427 {
1428 hrc = hrc2;
1429#ifdef VBOX_WITH_DTRACE_R3_MAIN
1430 </xsl:text>
1431 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1432 <xsl:text>this, hrc, 1 /*hrc exception*/,</xsl:text>
1433 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1434 <xsl:text>);
1435#endif
1436 }
1437 catch (...)
1438 {
1439 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1440#ifdef VBOX_WITH_DTRACE_R3_MAIN
1441 </xsl:text>
1442 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_SET_', $dtraceattrname, '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1443 <xsl:text>this, hrc, 9 /*unhandled exception*/,</xsl:text>
1444 <xsl:call-template name="emitDTraceParamValNoTmp-DirIn"/>
1445 <xsl:text>);
1446#endif
1447 }
1448
1449 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1450 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1451 <xsl:text>hrc));
1452 return hrc;
1453}
1454</xsl:text>
1455 </xsl:if>
1456
1457 <xsl:call-template name="emitTargetEnd">
1458 <xsl:with-param name="target" select="$target"/>
1459 </xsl:call-template>
1460
1461 <xsl:call-template name="xsltprocNewlineOutputHack"/>
1462</xsl:template>
1463
1464<!-- - - - - - - - - - - - - - - - - - - - - - -
1465 Emit DTrace probes for the given attribute.
1466 - - - - - - - - - - - - - - - - - - - - - - -->
1467<xsl:template match="attribute" mode="dtrace-probes">
1468 <xsl:param name="topclass"/>
1469 <xsl:param name="dtracetopclass"/>
1470 <xsl:param name="target"/>
1471
1472 <xsl:variable name="dtraceattrname">
1473 <xsl:choose>
1474 <xsl:when test="@dtracename">
1475 <xsl:value-of select="@dtracename"/>
1476 </xsl:when>
1477 <xsl:otherwise>
1478 <!-- attrbasename -->
1479 <xsl:call-template name="capitalize">
1480 <xsl:with-param name="str" select="@name"/>
1481 </xsl:call-template>
1482 </xsl:otherwise>
1483 </xsl:choose>
1484 </xsl:variable>
1485
1486 <xsl:if test="@name != 'midlDoesNotLikeEmptyInterfaces'">
1487 <xsl:text> probe </xsl:text>
1488 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(struct ', $topclass)"/> -->
1489 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__enter(void')"/>
1490 <xsl:text> *a_pThis);
1491 probe </xsl:text>
1492 <!-- <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1493 <xsl:value-of select="concat($dtracetopclass, '__get__', $dtraceattrname, '__return(void *a_pThis')"/>
1494 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1495 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1496 <xsl:with-param name="dir">out</xsl:with-param>
1497 </xsl:apply-templates>
1498 <xsl:text>);
1499</xsl:text>
1500 </xsl:if>
1501 <xsl:if test="(not(@readonly) or @readonly!='yes') and @name != 'midlDoesNotLikeEmptyInterfaces'">
1502 <xsl:text> probe </xsl:text>
1503 <!-- <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(struct ', $topclass, ' *a_pThis, ')"/>-->
1504 <xsl:value-of select="concat($topclass, '__set__', $dtraceattrname, '__enter(void *a_pThis, ')"/>
1505 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1506 <xsl:with-param name="dir" select="'in'"/>
1507 </xsl:apply-templates>
1508 <xsl:text>);
1509 probe </xsl:text>
1510 <!-- <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(struct ', $topclass, ' *a_pThis')"/> -->
1511 <xsl:value-of select="concat($dtracetopclass, '__set__', $dtraceattrname, '__return(void *a_pThis')"/>
1512 <xsl:text>, uint32_t a_hrc, int32_t enmWhy, </xsl:text>
1513 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1514 <xsl:with-param name="dir">in</xsl:with-param>
1515 </xsl:apply-templates>
1516 <xsl:text>);
1517</xsl:text>
1518 </xsl:if>
1519</xsl:template>
1520
1521<!-- - - - - - - - - - - - - - - - - - - - - - -
1522 Emit all attributes of an interface (current node).
1523 - - - - - - - - - - - - - - - - - - - - - - -->
1524<xsl:template name="emitAttributes">
1525 <xsl:param name="topclass"/>
1526 <xsl:param name="dtracetopclass"/>
1527 <xsl:param name="pmode"/>
1528
1529 <xsl:variable name="name" select="@name"/>
1530 <!-- first recurse to emit all base interfaces -->
1531 <xsl:variable name="extends" select="@extends"/>
1532 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1533 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
1534 <xsl:call-template name="emitAttributes">
1535 <xsl:with-param name="topclass" select="$topclass"/>
1536 <xsl:with-param name="pmode" select="$pmode"/>
1537 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1538 </xsl:call-template>
1539 </xsl:for-each>
1540 </xsl:if>
1541
1542 <xsl:choose>
1543 <xsl:when test="$pmode='code'">
1544 <xsl:text>//
1545</xsl:text>
1546 <xsl:value-of select="concat('// ', $name, ' properties')"/>
1547 <xsl:text>
1548//
1549
1550</xsl:text>
1551 </xsl:when>
1552 <xsl:when test="$pmode != 'dtrace-probes'">
1553 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', $name, ' properties', $G_sNewLine)"/>
1554 </xsl:when>
1555 </xsl:choose>
1556 <xsl:choose>
1557 <xsl:when test="$pmode='public'">
1558 <xsl:apply-templates select="./attribute | ./if" mode="public">
1559 <xsl:with-param name="emitmode" select="'attribute'"/>
1560 </xsl:apply-templates>
1561 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1562 <xsl:if test="$reservedAttributes > 0">
1563 <!-- tricky way to do a "for" loop without recursion -->
1564 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1565 <xsl:text> STDMETHOD(COMGETTER(InternalAndReservedAttribute</xsl:text>
1566 <xsl:value-of select="concat(position(), $name)"/>
1567 <xsl:text>))(ULONG *aReserved);&#x0A;</xsl:text>
1568 </xsl:for-each>
1569 </xsl:if>
1570 </xsl:when>
1571 <xsl:when test="$pmode='wrapped'">
1572 <xsl:apply-templates select="./attribute | ./if" mode="wrapped">
1573 <xsl:with-param name="emitmode" select="'attribute'"/>
1574 </xsl:apply-templates>
1575 </xsl:when>
1576 <xsl:when test="$pmode='code'">
1577 <xsl:apply-templates select="./attribute | ./if" mode="code">
1578 <xsl:with-param name="topclass" select="$topclass"/>
1579 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1580 <xsl:with-param name="emitmode" select="'attribute'"/>
1581 </xsl:apply-templates>
1582 <xsl:variable name="reservedAttributes" select="@reservedAttributes"/>
1583 <xsl:if test="$reservedAttributes > 0">
1584 <!-- tricky way to do a "for" loop without recursion -->
1585 <xsl:for-each select="(//*)[position() &lt;= $reservedAttributes]">
1586 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(InternalAndReservedAttribute', position(), $name, ')(ULONG *aReserved)&#x0A;')"/>
1587 <xsl:text>{
1588 NOREF(aReserved);
1589 return E_NOTIMPL;
1590}
1591
1592</xsl:text>
1593 </xsl:for-each>
1594 </xsl:if>
1595 </xsl:when>
1596 <xsl:when test="$pmode = 'dtrace-probes'">
1597 <xsl:apply-templates select="./attribute | ./if" mode="dtrace-probes">
1598 <xsl:with-param name="topclass" select="$topclass"/>
1599 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
1600 <xsl:with-param name="emitmode" select="'attribute'"/>
1601 </xsl:apply-templates>
1602 </xsl:when>
1603 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitAttributes</xsl:message></xsl:otherwise>
1604 </xsl:choose>
1605</xsl:template>
1606
1607<xsl:template name="emitTargetBegin">
1608 <xsl:param name="target"/>
1609
1610 <xsl:choose>
1611 <xsl:when test="$target = ''"/>
1612 <xsl:when test="$target = 'xpidl'">
1613 <xsl:text>#ifdef VBOX_WITH_XPCOM
1614</xsl:text>
1615 </xsl:when>
1616 <xsl:when test="$target = 'midl'">
1617 <xsl:text>#ifndef VBOX_WITH_XPCOM
1618</xsl:text>
1619 </xsl:when>
1620 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetBegin: target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1621 </xsl:choose>
1622</xsl:template>
1623
1624<xsl:template name="emitTargetEnd">
1625 <xsl:param name="target"/>
1626
1627 <xsl:choose>
1628 <xsl:when test="$target = ''"/>
1629 <xsl:when test="$target = 'xpidl'">
1630 <xsl:text>#endif /* VBOX_WITH_XPCOM */
1631</xsl:text>
1632 </xsl:when>
1633 <xsl:when test="$target = 'midl'">
1634 <xsl:text>#endif /* !VBOX_WITH_XPCOM */
1635</xsl:text>
1636 </xsl:when>
1637 <xsl:otherwise><xsl:message terminate="yes">Otherwise oops in emitTargetEnd target=<xsl:value-of select="$target"/></xsl:message></xsl:otherwise>
1638 </xsl:choose>
1639</xsl:template>
1640
1641
1642<!-- - - - - - - - - - - - - - - - - - - - - - -
1643 emit method
1644 - - - - - - - - - - - - - - - - - - - - - - -->
1645
1646<xsl:template match="method" mode="public">
1647 <xsl:param name="target"/>
1648
1649 <xsl:call-template name="emitTargetBegin">
1650 <xsl:with-param name="target" select="$target"/>
1651 </xsl:call-template>
1652
1653 <xsl:variable name="methodindent">
1654 <xsl:call-template name="tospace">
1655 <xsl:with-param name="str" select="@name"/>
1656 </xsl:call-template>
1657 </xsl:variable>
1658
1659 <xsl:text> STDMETHOD(</xsl:text>
1660 <xsl:call-template name="capitalize">
1661 <xsl:with-param name="str" select="@name"/>
1662 </xsl:call-template>
1663 <xsl:text>)(</xsl:text>
1664 <xsl:for-each select="param">
1665 <xsl:call-template name="emitPublicParameter">
1666 <xsl:with-param name="dir" select="@dir"/>
1667 </xsl:call-template>
1668 <xsl:if test="not(position()=last())">
1669 <xsl:text>,
1670 </xsl:text>
1671 <xsl:value-of select="$methodindent"/>
1672 </xsl:if>
1673 </xsl:for-each>
1674 <xsl:text>);
1675</xsl:text>
1676
1677 <xsl:call-template name="emitTargetEnd">
1678 <xsl:with-param name="target" select="$target"/>
1679 </xsl:call-template>
1680</xsl:template>
1681
1682<xsl:template match="method" mode="wrapped">
1683 <xsl:param name="target"/>
1684
1685 <xsl:call-template name="emitTargetBegin">
1686 <xsl:with-param name="target" select="$target"/>
1687 </xsl:call-template>
1688
1689 <xsl:variable name="methodindent">
1690 <xsl:call-template name="tospace">
1691 <xsl:with-param name="str" select="@name"/>
1692 </xsl:call-template>
1693 </xsl:variable>
1694
1695 <xsl:text> virtual HRESULT </xsl:text>
1696 <xsl:call-template name="uncapitalize">
1697 <xsl:with-param name="str" select="@name"/>
1698 </xsl:call-template>
1699 <xsl:text>(</xsl:text>
1700 <xsl:variable name="passAutoCaller">
1701 <xsl:call-template name="checkoption">
1702 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1703 <xsl:with-param name="option" select="'passcaller'"/>
1704 </xsl:call-template>
1705 </xsl:variable>
1706 <xsl:if test="$passAutoCaller = 'true'">
1707 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1708 <xsl:if test="count(param) > 0">
1709 <xsl:text>,
1710 </xsl:text>
1711 <xsl:value-of select="$methodindent"/>
1712 </xsl:if>
1713 </xsl:if>
1714 <xsl:for-each select="param">
1715 <xsl:apply-templates select="@type" mode="wrapped">
1716 <xsl:with-param name="dir" select="@dir"/>
1717 </xsl:apply-templates>
1718 <xsl:if test="not(position()=last())">
1719 <xsl:text>,
1720 </xsl:text>
1721 <xsl:value-of select="$methodindent"/>
1722 </xsl:if>
1723 </xsl:for-each>
1724 <xsl:text>) = 0;
1725</xsl:text>
1726
1727 <xsl:call-template name="emitTargetEnd">
1728 <xsl:with-param name="target" select="$target"/>
1729 </xsl:call-template>
1730</xsl:template>
1731
1732<xsl:template match="method" mode="code">
1733 <xsl:param name="topclass"/>
1734 <xsl:param name="dtracetopclass"/>
1735 <xsl:param name="target"/>
1736
1737 <xsl:call-template name="emitTargetBegin">
1738 <xsl:with-param name="target" select="$target"/>
1739 </xsl:call-template>
1740
1741 <xsl:variable name="methodindent">
1742 <xsl:call-template name="tospace">
1743 <xsl:with-param name="str" select="@name"/>
1744 </xsl:call-template>
1745 </xsl:variable>
1746 <xsl:variable name="methodclassindent">
1747 <xsl:call-template name="tospace">
1748 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1749 </xsl:call-template>
1750 </xsl:variable>
1751 <xsl:variable name="methodbasename">
1752 <xsl:call-template name="capitalize">
1753 <xsl:with-param name="str" select="@name"/>
1754 </xsl:call-template>
1755 </xsl:variable>
1756 <xsl:variable name="limitedAutoCaller">
1757 <xsl:call-template name="checkoption">
1758 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1759 <xsl:with-param name="option" select="'limitedcaller'"/>
1760 </xsl:call-template>
1761 </xsl:variable>
1762 <xsl:variable name="dtracemethodname">
1763 <xsl:choose>
1764 <xsl:when test="@dtracename">
1765 <xsl:value-of select="@dtracename"/>
1766 </xsl:when>
1767 <xsl:otherwise>
1768 <xsl:value-of select="@name"/>
1769 </xsl:otherwise>
1770 </xsl:choose>
1771 </xsl:variable>
1772 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1773 <xsl:if test="name(..) = 'if'">
1774 <xsl:value-of select="concat('__', ../@target)"/>
1775 </xsl:if>
1776 </xsl:variable>
1777
1778 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1779 <xsl:for-each select="param">
1780 <xsl:call-template name="emitPublicParameter">
1781 <xsl:with-param name="dir" select="@dir"/>
1782 </xsl:call-template>
1783 <xsl:if test="not(position()=last())">
1784 <xsl:text>,
1785 </xsl:text>
1786 <xsl:value-of select="$methodclassindent"/>
1787 </xsl:if>
1788 </xsl:for-each>
1789 <xsl:text>)
1790{
1791 LogRelFlow(("{%p} %s:enter</xsl:text>
1792 <xsl:for-each select="param">
1793 <xsl:text> </xsl:text>
1794 <xsl:apply-templates select="@type" mode="logparamtext">
1795 <xsl:with-param name="dir" select="@dir"/>
1796 <xsl:with-param name="isref" select="'yes'"/>
1797 </xsl:apply-templates>
1798 </xsl:for-each>
1799 <xsl:text>\n", this</xsl:text>
1800 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1801 <xsl:for-each select="param">
1802 <xsl:text>, </xsl:text>
1803 <xsl:apply-templates select="@type" mode="logparamval">
1804 <xsl:with-param name="dir" select="@dir"/>
1805 <xsl:with-param name="isref" select="'yes'"/>
1806 </xsl:apply-templates>
1807 </xsl:for-each>
1808 <xsl:text>));
1809
1810 VirtualBoxBase::clearError();
1811
1812 HRESULT hrc;
1813
1814 try
1815 {
1816</xsl:text>
1817 <!-- @todo check in parameters if possible -->
1818 <xsl:for-each select="param">
1819 <xsl:if test="@dir!='in'">
1820 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1821 <xsl:call-template name="capitalize">
1822 <xsl:with-param name="str" select="@name"/>
1823 </xsl:call-template>
1824 <xsl:text>);
1825</xsl:text>
1826 </xsl:if>
1827 </xsl:for-each>
1828<xsl:text>
1829</xsl:text>
1830 <xsl:for-each select="param">
1831 <xsl:text>
1832 </xsl:text>
1833 <xsl:apply-templates select="@type" mode="paramvalconversion2tmpvar">
1834 <xsl:with-param name="dir" select="@dir"/>
1835 </xsl:apply-templates>
1836 </xsl:for-each>
1837 <xsl:text>
1838
1839#ifdef VBOX_WITH_DTRACE_R3_MAIN
1840 </xsl:text>
1841 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_ENTER('), $G_lowerCase, $G_upperCase)"/>
1842 <xsl:text>this</xsl:text>
1843 <xsl:for-each select="param[@dir='in']">
1844 <xsl:text>, </xsl:text>
1845 <xsl:call-template name="emitDTraceParamValue">
1846 <xsl:with-param name="dir" select="@dir"/>
1847 </xsl:call-template>
1848 </xsl:for-each>
1849 <xsl:text>);
1850#endif
1851 </xsl:text>
1852 <xsl:choose>
1853 <xsl:when test="$limitedAutoCaller = 'true'">
1854 <xsl:text>AutoLimitedCaller</xsl:text>
1855 </xsl:when>
1856 <xsl:otherwise>
1857 <xsl:text>AutoCaller</xsl:text>
1858 </xsl:otherwise>
1859 </xsl:choose>
1860 <xsl:text> autoCaller(this);
1861 hrc = autoCaller.rc();
1862 if (SUCCEEDED(hrc))
1863 {
1864</xsl:text>
1865 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1866 <xsl:variable name="passAutoCaller">
1867 <xsl:call-template name="checkoption">
1868 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1869 <xsl:with-param name="option" select="'passcaller'"/>
1870 </xsl:call-template>
1871 </xsl:variable>
1872 <xsl:if test="$passAutoCaller = 'true'">
1873 <xsl:text>autoCaller</xsl:text>
1874 <xsl:if test="count(param) > 0">
1875 <xsl:text>,
1876 </xsl:text>
1877 <xsl:value-of select="$methodindent"/>
1878 </xsl:if>
1879 </xsl:if>
1880 <xsl:for-each select="param">
1881 <xsl:apply-templates select="@type" mode="paramvalconversionusingtmp">
1882 <xsl:with-param name="dir" select="@dir"/>
1883 </xsl:apply-templates>
1884 <xsl:if test="not(position()=last())">
1885 <xsl:text>,
1886 </xsl:text>
1887 <xsl:value-of select="$methodindent"/>
1888 </xsl:if>
1889 </xsl:for-each>
1890 <xsl:text>);
1891 }
1892#ifdef VBOX_WITH_DTRACE_R3_MAIN
1893 </xsl:text>
1894 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1895 <xsl:text>this, hrc, 0 /*normal*/</xsl:text>
1896 <xsl:for-each select="param">
1897 <xsl:text>, </xsl:text>
1898 <xsl:call-template name="emitDTraceParamValue">
1899 <xsl:with-param name="dir" select="@dir"/>
1900 </xsl:call-template>
1901 </xsl:for-each>
1902 <xsl:text>);
1903#endif
1904 }
1905 catch (HRESULT hrc2)
1906 {
1907 hrc = hrc2;
1908#ifdef VBOX_WITH_DTRACE_R3_MAIN
1909 </xsl:text>
1910 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1911 <xsl:text>this, hrc, 1 /*hrc exception*/</xsl:text>
1912 <xsl:for-each select="param">
1913 <xsl:text>, </xsl:text>
1914 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1915 </xsl:for-each>
1916 <xsl:text>);
1917#endif
1918 }
1919 catch (...)
1920 {
1921 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1922#ifdef VBOX_WITH_DTRACE_R3_MAIN
1923 </xsl:text>
1924 <xsl:value-of select="translate(concat('VBOXAPI_', $dtracetopclass, '_', $dtracemethodname, substring($dtracenamehack, 2), '_RETURN('), $G_lowerCase, $G_upperCase)"/>
1925 <xsl:text>this, hrc, 9 /*unhandled exception*/</xsl:text>
1926 <xsl:for-each select="param">
1927 <xsl:text>, </xsl:text>
1928 <xsl:call-template name="emitDTraceParamValNoTmp"/>
1929 </xsl:for-each>
1930 <xsl:text>);
1931#endif
1932 }
1933
1934 LogRelFlow(("{%p} %s: leave</xsl:text>
1935 <xsl:for-each select="param">
1936 <xsl:if test="@dir!='in'">
1937 <xsl:text> </xsl:text>
1938 <xsl:apply-templates select="@type" mode="logparamtext">
1939 <xsl:with-param name="dir" select="@dir"/>
1940 <xsl:with-param name="isref" select="''"/>
1941 </xsl:apply-templates>
1942 </xsl:if>
1943 </xsl:for-each>
1944 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1945 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1946 <xsl:for-each select="param">
1947 <xsl:if test="@dir!='in'">
1948 <xsl:text>, </xsl:text>
1949 <xsl:apply-templates select="@type" mode="logparamval">
1950 <xsl:with-param name="dir" select="@dir"/>
1951 <xsl:with-param name="isref" select="''"/>
1952 </xsl:apply-templates>
1953 </xsl:if>
1954 </xsl:for-each>
1955 <xsl:text>, hrc));
1956 return hrc;
1957}
1958</xsl:text>
1959
1960 <xsl:call-template name="emitTargetEnd">
1961 <xsl:with-param name="target" select="$target"/>
1962 </xsl:call-template>
1963
1964 <xsl:text>
1965</xsl:text>
1966</xsl:template>
1967
1968<!-- - - - - - - - - - - - - - - - - - - - - - -
1969 Emits the DTrace probes for a method.
1970 - - - - - - - - - - - - - - - - - - - - - - -->
1971<xsl:template match="method" mode="dtrace-probes">
1972 <xsl:param name="topclass"/>
1973 <xsl:param name="dtracetopclass"/>
1974 <xsl:param name="target"/>
1975
1976 <xsl:variable name="dtracemethodname">
1977 <xsl:choose>
1978 <xsl:when test="@dtracename">
1979 <xsl:value-of select="@dtracename"/>
1980 </xsl:when>
1981 <xsl:otherwise>
1982 <xsl:value-of select="@name"/>
1983 </xsl:otherwise>
1984 </xsl:choose>
1985 </xsl:variable>
1986 <xsl:variable name="dtracenamehack"> <!-- Ugly hack to deal with Session::assignMachine and similar. -->
1987 <xsl:if test="name(..) = 'if'">
1988 <xsl:value-of select="concat('__', ../@target)"/>
1989 </xsl:if>
1990 </xsl:variable>
1991
1992 <xsl:text> probe </xsl:text>
1993 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(struct ', $dtracetopclass, ' *a_pThis')"/> -->
1994 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__enter(void *a_pThis')"/>
1995 <xsl:for-each select="param[@dir='in']">
1996 <xsl:text>, </xsl:text>
1997 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
1998 <xsl:with-param name="dir" select="'@dir'"/>
1999 </xsl:apply-templates>
2000 </xsl:for-each>
2001 <xsl:text>);
2002 probe </xsl:text>
2003 <!-- <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, '__return(struct ', $dtracetopclass, ' *a_pThis')"/> -->
2004 <xsl:value-of select="concat($dtracetopclass, '__', $dtracemethodname, $dtracenamehack, '__return(void *a_pThis')"/>
2005 <xsl:text>, uint32_t a_hrc, int32_t enmWhy</xsl:text>
2006 <xsl:for-each select="param">
2007 <xsl:text>, </xsl:text>
2008 <xsl:apply-templates select="@type" mode="dtraceparamdecl">
2009 <xsl:with-param name="dir" select="'@dir'"/>
2010 </xsl:apply-templates>
2011 </xsl:for-each>
2012 <xsl:text>);
2013</xsl:text>
2014
2015</xsl:template>
2016
2017
2018<xsl:template name="emitIf">
2019 <xsl:param name="passmode"/>
2020 <xsl:param name="target"/>
2021 <xsl:param name="topclass"/>
2022 <xsl:param name="emitmode"/>
2023 <xsl:param name="dtracetopclass"/>
2024
2025 <xsl:if test="($target = 'xpidl') or ($target = 'midl')">
2026 <xsl:choose>
2027 <xsl:when test="$passmode='public'">
2028 <xsl:choose>
2029 <xsl:when test="$emitmode='method'">
2030 <xsl:apply-templates select="method" mode="public">
2031 <xsl:with-param name="target" select="$target"/>
2032 </xsl:apply-templates>
2033 </xsl:when>
2034 <xsl:when test="$emitmode='attribute'">
2035 <xsl:apply-templates select="attribute" mode="public">
2036 <xsl:with-param name="target" select="$target"/>
2037 </xsl:apply-templates>
2038 </xsl:when>
2039 <xsl:otherwise/>
2040 </xsl:choose>
2041 </xsl:when>
2042 <xsl:when test="$passmode='wrapped'">
2043 <xsl:choose>
2044 <xsl:when test="$emitmode='method'">
2045 <xsl:apply-templates select="method" mode="wrapped">
2046 <xsl:with-param name="target" select="$target"/>
2047 </xsl:apply-templates>
2048 </xsl:when>
2049 <xsl:when test="$emitmode='attribute'">
2050 <xsl:apply-templates select="attribute" mode="wrapped">
2051 <xsl:with-param name="target" select="$target"/>
2052 </xsl:apply-templates>
2053 </xsl:when>
2054 <xsl:otherwise/>
2055 </xsl:choose>
2056 </xsl:when>
2057 <xsl:when test="$passmode='code'">
2058 <xsl:choose>
2059 <xsl:when test="$emitmode='method'">
2060 <xsl:apply-templates select="method" 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:when test="$emitmode='attribute'">
2067 <xsl:apply-templates select="attribute" mode="code">
2068 <xsl:with-param name="target" select="$target"/>
2069 <xsl:with-param name="topclass" select="$topclass"/>
2070 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2071 </xsl:apply-templates>
2072 </xsl:when>
2073 <xsl:otherwise/>
2074 </xsl:choose>
2075 </xsl:when>
2076 <xsl:when test="$passmode = 'dtrace-probes'">
2077 <xsl:choose>
2078 <xsl:when test="$emitmode = 'method'">
2079 <xsl:apply-templates select="method" 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:when test="$emitmode = 'attribute'">
2086 <xsl:apply-templates select="attribute" mode="dtrace-probes">
2087 <xsl:with-param name="target" select="$target"/>
2088 <xsl:with-param name="topclass" select="$topclass"/>
2089 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2090 </xsl:apply-templates>
2091 </xsl:when>
2092 <xsl:otherwise/>
2093 </xsl:choose>
2094 </xsl:when>
2095 <xsl:otherwise/>
2096 </xsl:choose>
2097 </xsl:if>
2098</xsl:template>
2099
2100<xsl:template match="if" mode="public">
2101 <xsl:param name="emitmode"/>
2102
2103 <xsl:call-template name="emitIf">
2104 <xsl:with-param name="passmode" select="'public'"/>
2105 <xsl:with-param name="target" select="@target"/>
2106 <xsl:with-param name="emitmode" select="$emitmode"/>
2107 </xsl:call-template>
2108</xsl:template>
2109
2110<xsl:template match="if" mode="wrapped">
2111 <xsl:param name="emitmode"/>
2112
2113 <xsl:call-template name="emitIf">
2114 <xsl:with-param name="passmode" select="'wrapped'"/>
2115 <xsl:with-param name="target" select="@target"/>
2116 <xsl:with-param name="emitmode" select="$emitmode"/>
2117 </xsl:call-template>
2118</xsl:template>
2119
2120<xsl:template match="if" mode="code">
2121 <xsl:param name="topclass"/>
2122 <xsl:param name="emitmode"/>
2123 <xsl:param name="dtracetopclass"/>
2124
2125 <xsl:call-template name="emitIf">
2126 <xsl:with-param name="passmode" select="'code'"/>
2127 <xsl:with-param name="target" select="@target"/>
2128 <xsl:with-param name="emitmode" select="$emitmode"/>
2129 <xsl:with-param name="topclass" select="$topclass"/>
2130 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2131 </xsl:call-template>
2132</xsl:template>
2133
2134<xsl:template match="if" mode="dtrace-probes">
2135 <xsl:param name="topclass"/>
2136 <xsl:param name="emitmode"/>
2137 <xsl:param name="dtracetopclass"/>
2138
2139 <xsl:call-template name="emitIf">
2140 <xsl:with-param name="passmode" select="'dtrace-probes'"/>
2141 <xsl:with-param name="target" select="@target"/>
2142 <xsl:with-param name="emitmode" select="$emitmode"/>
2143 <xsl:with-param name="topclass" select="$topclass"/>
2144 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2145 </xsl:call-template>
2146</xsl:template>
2147
2148<!-- - - - - - - - - - - - - - - - - - - - - - -
2149 emit all methods of the current interface
2150 - - - - - - - - - - - - - - - - - - - - - - -->
2151<xsl:template name="emitMethods">
2152 <xsl:param name="topclass"/>
2153 <xsl:param name="pmode"/>
2154 <xsl:param name="dtracetopclass"/>
2155
2156 <xsl:variable name="name" select="@name"/>
2157 <!-- first recurse to emit all base interfaces -->
2158 <xsl:variable name="extends" select="@extends"/>
2159 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
2160 <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
2161 <xsl:call-template name="emitMethods">
2162 <xsl:with-param name="topclass" select="$topclass"/>
2163 <xsl:with-param name="pmode" select="$pmode"/>
2164 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2165 </xsl:call-template>
2166 </xsl:for-each>
2167 </xsl:if>
2168
2169 <xsl:choose>
2170 <xsl:when test="$pmode='code'">
2171 <xsl:text>//
2172</xsl:text>
2173 <xsl:value-of select="concat('// ', $name, ' methods')"/>
2174 <xsl:text>
2175//
2176
2177</xsl:text>
2178 </xsl:when>
2179 <xsl:when test="$pmode='dtrace-probes'"/>
2180 <xsl:otherwise>
2181 <xsl:value-of select="concat($G_sNewLine, ' // ', $pmode, ' ', $name, ' methods', $G_sNewLine)"/>
2182 </xsl:otherwise>
2183 </xsl:choose>
2184 <xsl:choose>
2185 <xsl:when test="$pmode='public'">
2186 <xsl:apply-templates select="./method | ./if" mode="public">
2187 <xsl:with-param name="emitmode" select="'method'"/>
2188 </xsl:apply-templates>
2189 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2190 <xsl:if test="$reservedMethods > 0">
2191 <!-- tricky way to do a "for" loop without recursion -->
2192 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2193 <xsl:text> STDMETHOD(InternalAndReservedMethod</xsl:text>
2194 <xsl:value-of select="concat(position(), $name)"/>
2195 <xsl:text>)();&#x0A;</xsl:text>
2196 </xsl:for-each>
2197 </xsl:if>
2198 </xsl:when>
2199 <xsl:when test="$pmode='wrapped'">
2200 <xsl:apply-templates select="./method | ./if" mode="wrapped">
2201 <xsl:with-param name="emitmode" select="'method'"/>
2202 </xsl:apply-templates>
2203 </xsl:when>
2204 <xsl:when test="$pmode='code'">
2205 <xsl:apply-templates select="./method | ./if" mode="code">
2206 <xsl:with-param name="topclass" select="$topclass"/>
2207 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2208 <xsl:with-param name="emitmode" select="'method'"/>
2209 </xsl:apply-templates>
2210 <xsl:variable name="reservedMethods" select="@reservedMethods"/>
2211 <xsl:if test="$reservedMethods > 0">
2212 <!-- tricky way to do a "for" loop without recursion -->
2213 <xsl:for-each select="(//*)[position() &lt;= $reservedMethods]">
2214 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::InternalAndReservedMethod', position(), $name, '()&#x0A;')"/>
2215 <xsl:text>{
2216 return E_NOTIMPL;
2217}
2218
2219</xsl:text>
2220 </xsl:for-each>
2221 </xsl:if>
2222 </xsl:when>
2223 <xsl:when test="$pmode='dtrace-probes'">
2224 <xsl:apply-templates select="./method | ./if" mode="dtrace-probes">
2225 <xsl:with-param name="topclass" select="$topclass"/>
2226 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2227 <xsl:with-param name="emitmode" select="'method'"/>
2228 </xsl:apply-templates>
2229 </xsl:when>
2230 <xsl:otherwise/>
2231 </xsl:choose>
2232</xsl:template>
2233
2234<!-- - - - - - - - - - - - - - - - - - - - - - -
2235 emit all attributes and methods declarations of the current interface
2236 - - - - - - - - - - - - - - - - - - - - - - -->
2237<xsl:template name="emitInterfaceDecls">
2238 <xsl:param name="pmode"/>
2239
2240 <!-- attributes -->
2241 <xsl:call-template name="emitAttributes">
2242 <xsl:with-param name="pmode" select="$pmode"/>
2243 </xsl:call-template>
2244
2245 <!-- methods -->
2246 <xsl:call-template name="emitMethods">
2247 <xsl:with-param name="pmode" select="$pmode"/>
2248 </xsl:call-template>
2249</xsl:template>
2250
2251<!-- - - - - - - - - - - - - - - - - - - - - - -
2252 emit auxiliary method declarations of the current interface
2253 - - - - - - - - - - - - - - - - - - - - - - -->
2254<xsl:template name="emitAuxMethodDecls">
2255 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
2256</xsl:template>
2257
2258<!-- - - - - - - - - - - - - - - - - - - - - - -
2259 emit the header file of the current interface
2260 - - - - - - - - - - - - - - - - - - - - - - -->
2261<xsl:template name="emitHeader">
2262 <xsl:param name="addinterfaces"/>
2263
2264 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
2265
2266 <xsl:apply-templates select="." mode="startfile">
2267 <xsl:with-param name="file" select="$filename"/>
2268 </xsl:apply-templates>
2269 <xsl:call-template name="fileheader">
2270 <xsl:with-param name="name" select="$filename"/>
2271 <xsl:with-param name="class" select="substring(@name, 2)"/>
2272 <xsl:with-param name="type" select="'header'"/>
2273 </xsl:call-template>
2274 <xsl:apply-templates select="." mode="classheader">
2275 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2276 </xsl:apply-templates>
2277
2278 <!-- interface attributes/methods (public) -->
2279 <xsl:call-template name="emitInterfaceDecls">
2280 <xsl:with-param name="pmode" select="'public'"/>
2281 </xsl:call-template>
2282
2283 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2284 <!-- This is super tricky, as the for-each switches to the node set,
2285 which means the normal document isn't available any more. We get
2286 the data we need, uses a for-each to switch document and then a
2287 key() to look up the interface by name. -->
2288 <xsl:variable name="addifname">
2289 <xsl:value-of select="string(.)"/>
2290 </xsl:variable>
2291 <xsl:for-each select="$G_root">
2292 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2293 <xsl:call-template name="emitInterfaceDecls">
2294 <xsl:with-param name="pmode" select="'public'"/>
2295 </xsl:call-template>
2296 </xsl:for-each>
2297 </xsl:for-each>
2298 </xsl:for-each>
2299
2300 <!-- auxiliary methods (public) -->
2301 <xsl:call-template name="emitAuxMethodDecls"/>
2302
2303 <!-- switch to private -->
2304 <xsl:text>
2305private:</xsl:text>
2306
2307 <!-- wrapped interface attributes/methods (private) -->
2308 <xsl:call-template name="emitInterfaceDecls">
2309 <xsl:with-param name="pmode" select="'wrapped'"/>
2310 </xsl:call-template>
2311
2312 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2313 <!-- This is super tricky, as the for-each switches to the node set,
2314 which means the normal document isn't available any more. We get
2315 the data we need, uses a for-each to switch document and then a
2316 key() to look up the interface by name. -->
2317 <xsl:variable name="addifname">
2318 <xsl:value-of select="string(.)"/>
2319 </xsl:variable>
2320 <xsl:for-each select="$G_root">
2321 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2322 <xsl:call-template name="emitInterfaceDecls">
2323 <xsl:with-param name="pmode" select="'wrapped'"/>
2324 </xsl:call-template>
2325 </xsl:for-each>
2326 </xsl:for-each>
2327 </xsl:for-each>
2328
2329 <xsl:apply-templates select="." mode="classfooter"/>
2330 <xsl:apply-templates select="." mode="endfile">
2331 <xsl:with-param name="file" select="$filename"/>
2332 </xsl:apply-templates>
2333</xsl:template>
2334
2335<!-- - - - - - - - - - - - - - - - - - - - - - -
2336 emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of the current interface
2337 - - - - - - - - - - - - - - - - - - - - - - -->
2338<xsl:template name="emitInterfaceDefs">
2339 <xsl:param name="addinterfaces"/>
2340 <xsl:param name="pmode" select="'code'"/>
2341
2342 <xsl:variable name="topclass" select="substring(@name, 2)"/>
2343 <xsl:variable name="dtracetopclass">
2344 <xsl:choose>
2345 <xsl:when test="@dtracename"><xsl:value-of select="@dtracename"/></xsl:when>
2346 <xsl:otherwise><xsl:value-of select="$topclass"/></xsl:otherwise>
2347 </xsl:choose>
2348 </xsl:variable>
2349
2350 <xsl:if test="$pmode = 'code'">
2351 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', $topclass, 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
2352 </xsl:if>
2353
2354 <!-- attributes -->
2355 <xsl:call-template name="emitAttributes">
2356 <xsl:with-param name="topclass" select="$topclass"/>
2357 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2358 <xsl:with-param name="pmode" select="$pmode"/>
2359 </xsl:call-template>
2360
2361 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2362 <!-- This is super tricky, as the for-each switches to the node set,
2363 which means the normal document isn't available any more. We get
2364 the data we need, uses a for-each to switch document and then a
2365 key() to look up the interface by name. -->
2366 <xsl:variable name="addifname">
2367 <xsl:value-of select="string(.)"/>
2368 </xsl:variable>
2369 <xsl:for-each select="$G_root">
2370 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2371 <xsl:call-template name="emitAttributes">
2372 <xsl:with-param name="topclass" select="$topclass"/>
2373 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2374 <xsl:with-param name="pmode" select="$pmode"/>
2375 </xsl:call-template>
2376 </xsl:for-each>
2377 </xsl:for-each>
2378 </xsl:for-each>
2379
2380 <!-- methods -->
2381 <xsl:call-template name="xsltprocNewlineOutputHack"/>
2382 <xsl:call-template name="emitMethods">
2383 <xsl:with-param name="topclass" select="$topclass"/>
2384 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2385 <xsl:with-param name="pmode" select="$pmode"/>
2386 </xsl:call-template>
2387
2388 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
2389 <!-- This is super tricky, as the for-each switches to the node set,
2390 which means the normal document isn't available any more. We get
2391 the data we need, uses a for-each to switch document and then a
2392 key() to look up the interface by name. -->
2393 <xsl:variable name="addifname">
2394 <xsl:value-of select="string(.)"/>
2395 </xsl:variable>
2396 <xsl:for-each select="$G_root">
2397 <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
2398 <xsl:call-template name="emitMethods">
2399 <xsl:with-param name="topclass" select="$topclass"/>
2400 <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
2401 <xsl:with-param name="pmode" select="$pmode"/>
2402 </xsl:call-template>
2403 </xsl:for-each>
2404 </xsl:for-each>
2405 </xsl:for-each>
2406</xsl:template>
2407
2408<!-- - - - - - - - - - - - - - - - - - - - - - -
2409 emit auxiliary method declarations of the current interface
2410 - - - - - - - - - - - - - - - - - - - - - - -->
2411<xsl:template name="emitAuxMethodDefs">
2412 <xsl:param name="pmode" select="'code'"/>
2413 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
2414</xsl:template>
2415
2416
2417<!-- - - - - - - - - - - - - - - - - - - - - - -
2418 emit the code file of the current interface
2419 - - - - - - - - - - - - - - - - - - - - - - -->
2420<xsl:template name="emitCode">
2421 <xsl:param name="addinterfaces"/>
2422
2423 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
2424
2425 <xsl:apply-templates select="." mode="startfile">
2426 <xsl:with-param name="file" select="$filename"/>
2427 </xsl:apply-templates>
2428 <xsl:call-template name="fileheader">
2429 <xsl:with-param name="name" select="$filename"/>
2430 <xsl:with-param name="class" select="substring(@name, 2)"/>
2431 <xsl:with-param name="type" select="'code'"/>
2432 </xsl:call-template>
2433 <xsl:apply-templates select="." mode="codeheader">
2434 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2435 </xsl:apply-templates>
2436
2437 <!-- interface attributes/methods (public) -->
2438 <xsl:call-template name="emitInterfaceDefs">
2439 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2440 </xsl:call-template>
2441
2442 <!-- auxiliary methods (public) -->
2443 <xsl:call-template name="emitAuxMethodDefs"/>
2444
2445 <xsl:apply-templates select="." mode="codefooter">
2446 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2447 </xsl:apply-templates>
2448 <xsl:apply-templates select="." mode="endfile">
2449 <xsl:with-param name="file" select="$filename"/>
2450 </xsl:apply-templates>
2451</xsl:template>
2452
2453<!-- - - - - - - - - - - - - - - - - - - - - - -
2454 emit the DTrace probes for the current interface
2455 - - - - - - - - - - - - - - - - - - - - - - -->
2456<xsl:template name="emitDTraceProbes">
2457 <xsl:param name="addinterfaces"/>
2458
2459 <!-- interface attributes/methods (public) -->
2460 <xsl:call-template name="emitInterfaceDefs">
2461 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
2462 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2463 </xsl:call-template>
2464
2465 <!-- auxiliary methods (public) -->
2466 <xsl:call-template name="emitAuxMethodDefs">
2467 <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
2468 </xsl:call-template>
2469
2470</xsl:template>
2471
2472<!-- - - - - - - - - - - - - - - - - - - - - - -
2473 wildcard match, ignore everything which has no explicit match
2474 - - - - - - - - - - - - - - - - - - - - - - -->
2475
2476<xsl:template match="*"/>
2477
2478<!-- - - - - - - - - - - - - - - - - - - - - - -
2479 ignore all if tags except those for XPIDL or MIDL target
2480 - - - - - - - - - - - - - - - - - - - - - - -->
2481
2482<xsl:template match="if">
2483 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
2484 <xsl:apply-templates/>
2485 </xsl:if>
2486</xsl:template>
2487
2488<!-- - - - - - - - - - - - - - - - - - - - - - -
2489 interface match
2490 - - - - - - - - - - - - - - - - - - - - - - -->
2491
2492<xsl:template match="interface">
2493 <xsl:if test="not(@internal='yes') and not(@supportsErrorInfo='no')">
2494 <xsl:call-template name="emitInterface"/>
2495 </xsl:if>
2496</xsl:template>
2497
2498<!-- - - - - - - - - - - - - - - - - - - - - - -
2499 application match
2500 - - - - - - - - - - - - - - - - - - - - - - -->
2501
2502<xsl:template match="application">
2503 <xsl:apply-templates/>
2504</xsl:template>
2505
2506<!-- - - - - - - - - - - - - - - - - - - - - - -
2507 library match
2508 - - - - - - - - - - - - - - - - - - - - - - -->
2509
2510<xsl:template match="library">
2511 <xsl:apply-templates/>
2512</xsl:template>
2513
2514<!-- - - - - - - - - - - - - - - - - - - - - - -
2515 root match
2516 - - - - - - - - - - - - - - - - - - - - - - -->
2517
2518<xsl:template match="/idl">
2519 <xsl:choose>
2520 <xsl:when test="$generating = 'headers'">
2521 <xsl:apply-templates/>
2522 </xsl:when>
2523 <xsl:when test="$generating = 'sources'">
2524 <xsl:apply-templates/>
2525 </xsl:when>
2526 <xsl:when test="$generating = 'dtrace-probes'">
2527 <xsl:apply-templates/>
2528 </xsl:when>
2529 <xsl:otherwise>
2530 <xsl:message terminate="yes">
2531 Unknown string parameter value: generating='<xsl:value-of select="$generating"/>'
2532 </xsl:message>
2533 </xsl:otherwise>
2534 </xsl:choose>
2535</xsl:template>
2536
2537</xsl:stylesheet>
2538<!-- vi: set tabstop=4 shiftwidth=4 expandtab: -->
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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