VirtualBox

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

Last change on this file since 76210 was 76091, checked in by vboxsync, 6 years ago

VBoxSVC: Hook all IVirtualBox calls to catch new client processes so we can watch them for termination. Work in progress. bugref:3300

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

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