VirtualBox

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

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

Moved G_sNewLine to typemap-shared.inc.xsl.

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