VirtualBox

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

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

apiwrap-server.xsl: Use xsl:key + key() to lookup interfaces and enums by @name. Since key works on current document, the super tricky stuff needed to make sure $G_root was select as current, so I took it one step further and make the interface[@name=$addifname] current as well. Pushing that a step further, and the need for $iface was eliminated. Changes save 5-6 seconds here on a 30 second run.

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