VirtualBox

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

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

Main: Split the wrapper source generator job into two to speed reduce the time it takes before we can start compiling wrappers. In the process, the xslt code responsible for generating vboxapiwrap.kmk was moved into apiwrap-server-filelist.xsl to prevent more clutter in the original file. Down to 6 seconds for generating wrapper sources, headers and trace points.

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