VirtualBox

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

Last change on this file since 55883 was 55608, checked in by vboxsync, 10 years ago

apiwrap-server.xsl,VirtualBox.xidl: Added a check in the API wrapper generator for empty interface since that causes midl proxy stubs to crash. Fixed 5-6 interfaces.

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