VirtualBox

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

Last change on this file since 51955 was 51601, checked in by vboxsync, 11 years ago

Main/Machine: fix regression (lack of AutoLimitedCaller) due to missing hints/wrapper support for inaccessible VMs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 60.8 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 apiwrap-server.xsl:
5 XSLT stylesheet that generates C++ API wrappers (server side) from
6 VirtualBox.xidl.
7
8 Copyright (C) 2010-2014 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<!-- - - - - - - - - - - - - - - - - - - - - - -
40templates for file separation
41 - - - - - - - - - - - - - - - - - - - - - - -->
42
43<xsl:template match="interface" mode="listfile">
44 <xsl:param name="file"/>
45
46 <xsl:value-of select="concat('&#9;', $file, ' \&#10;')"/>
47</xsl:template>
48
49<xsl:template match="interface" mode="startfile">
50 <xsl:param name="file"/>
51
52 <xsl:value-of select="concat('&#10;// ##### BEGINFILE &quot;', $file, '&quot;&#10;')"/>
53</xsl:template>
54
55<xsl:template match="interface" mode="endfile">
56 <xsl:param name="file"/>
57
58 <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;')"/>
59</xsl:template>
60
61<!-- - - - - - - - - - - - - - - - - - - - - - -
62templates for file headers/footers
63 - - - - - - - - - - - - - - - - - - - - - - -->
64
65<xsl:template name="fileheader">
66 <xsl:param name="class"/>
67 <xsl:param name="name"/>
68 <xsl:param name="type"/>
69
70 <xsl:text>/** @file
71 *
72</xsl:text>
73 <xsl:value-of select="concat(' * VirtualBox API class wrapper ', $type, ' for I', $class, '.')"/>
74 <xsl:text>
75 *
76 * DO NOT EDIT! This is a generated file.
77 * Generated from: src/VBox/Main/idl/VirtualBox.xidl
78 * Generator: src/VBox/Main/idl/apiwrap-server.xsl
79 */
80
81/**
82 * Copyright (C) 2010-2014 Oracle Corporation
83 *
84 * This file is part of VirtualBox Open Source Edition (OSE), as
85 * available from http://www.virtualbox.org. This file is free software;
86 * you can redistribute it and/or modify it under the terms of the GNU
87 * General Public License (GPL) as published by the Free Software
88 * Foundation, in version 2 as it comes in the "COPYING" file of the
89 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
90 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
91 */
92
93</xsl:text>
94</xsl:template>
95
96<xsl:template name="emitCOMInterfaces">
97 <xsl:param name="iface"/>
98
99 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $iface/@name, ')&#10;')"/>
100 <!-- now recurse to emit all base interfaces -->
101 <xsl:variable name="extends" select="$iface/@extends"/>
102 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
103 <xsl:call-template name="emitCOMInterfaces">
104 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
105 </xsl:call-template>
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_&#10;')"/>
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:text>&#10;</xsl:text>
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:text>&#10;</xsl:text>
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, ')&#10;')"/>
141 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', substring(@name, 2), 'Wrap)&#10;')"/>
142 <xsl:text> DECLARE_PROTECT_FINAL_CONSTRUCT()
143
144</xsl:text>
145 <xsl:value-of select="concat(' BEGIN_COM_MAP(', substring(@name, 2), 'Wrap)&#10;')"/>
146 <xsl:text> COM_INTERFACE_ENTRY(ISupportErrorInfo)
147</xsl:text>
148 <xsl:call-template name="emitCOMInterfaces">
149 <xsl:with-param name="iface" select="."/>
150 </xsl:call-template>
151 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')&#10;')"/>
152 <xsl:variable name="manualAddInterfaces">
153 <xsl:call-template name="checkoption">
154 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
155 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
156 </xsl:call-template>
157 </xsl:variable>
158 <xsl:if test="not($manualAddInterfaces = 'true')">
159 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
160 <!-- This is super tricky, as the for-each switches to the node
161 set, which means the normal document isn't available any more.
162 So need to use the global root node to get back into the
163 documemt to find corresponding interface data. -->
164 <xsl:variable name="addifname">
165 <xsl:value-of select="string(.)"/>
166 </xsl:variable>
167 <xsl:call-template name="emitCOMInterfaces">
168 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
169 </xsl:call-template>
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)&#10;')"/>
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_&#10;')"/>
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), '&#10;&#10;')"/>
190 <xsl:value-of select="concat('#include &quot;', substring(@name, 2), 'Wrap.h&quot;&#10;')"/>
191 <xsl:text>#include "Logging.h"
192
193</xsl:text>
194</xsl:template>
195
196<xsl:template name="emitISupports">
197 <xsl:param name="classname"/>
198 <xsl:param name="extends"/>
199 <xsl:param name="addinterfaces"/>
200 <xsl:param name="depth"/>
201 <xsl:param name="interfacelist"/>
202
203 <xsl:choose>
204 <xsl:when test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
205 <xsl:variable name="newextends" select="//interface[@name=$extends]/@extends"/>
206 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $extends)"/>
207 <xsl:call-template name="emitISupports">
208 <xsl:with-param name="classname" select="$classname"/>
209 <xsl:with-param name="extends" select="$newextends"/>
210 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
211 <xsl:with-param name="depth" select="$depth + 1"/>
212 <xsl:with-param name="interfacelist" select="$newiflist"/>
213 </xsl:call-template>
214 </xsl:when>
215 <xsl:otherwise>
216 <xsl:variable name="addinterfaces_ns" select="exsl:node-set($addinterfaces)"/>
217 <xsl:choose>
218 <xsl:when test="count($addinterfaces_ns/token) > 0">
219 <xsl:variable name="addifname" select="$addinterfaces_ns/token[1]"/>
220 <xsl:variable name="addif" select="//interface[@name=$addifname]/@extends"/>
221 <xsl:variable name="newextends" select="$addif/@extends"/>
222 <xsl:variable name="newaddinterfaces" select="$addinterfaces_ns/token[position() > 1]"/>
223 <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $addifname)"/>
224 <xsl:call-template name="emitISupports">
225 <xsl:with-param name="classname" select="$classname"/>
226 <xsl:with-param name="extends" select="$newextends"/>
227 <xsl:with-param name="addinterfaces" select="$newaddinterfaces"/>
228 <xsl:with-param name="depth" select="$depth + 1"/>
229 <xsl:with-param name="interfacelist" select="$newiflist"/>
230 </xsl:call-template>
231 </xsl:when>
232 <xsl:otherwise>
233 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS', $depth, '_CI(', $classname, ', ', $interfacelist, ')&#10;')"/>
234 </xsl:otherwise>
235 </xsl:choose>
236 </xsl:otherwise>
237 </xsl:choose>
238</xsl:template>
239
240<xsl:template match="interface" mode="codefooter">
241 <xsl:param name="addinterfaces"/>
242 <xsl:text>#ifdef VBOX_WITH_XPCOM
243</xsl:text>
244 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', substring(@name, 2), 'Wrap)&#10;')"/>
245
246 <xsl:variable name="manualAddInterfaces">
247 <xsl:call-template name="checkoption">
248 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
249 <xsl:with-param name="option" select="'manualaddinterfaces'"/>
250 </xsl:call-template>
251 </xsl:variable>
252 <xsl:choose>
253 <xsl:when test="$manualAddInterfaces = 'true'">
254 <xsl:variable name="nulladdinterfaces"></xsl:variable>
255 <xsl:call-template name="emitISupports">
256 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
257 <xsl:with-param name="extends" select="@extends"/>
258 <xsl:with-param name="addinterfaces" select="$nulladdinterfaces"/>
259 <xsl:with-param name="depth" select="1"/>
260 <xsl:with-param name="interfacelist" select="@name"/>
261 </xsl:call-template>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:call-template name="emitISupports">
265 <xsl:with-param name="classname" select="concat(substring(@name, 2), 'Wrap')"/>
266 <xsl:with-param name="extends" select="@extends"/>
267 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
268 <xsl:with-param name="depth" select="1"/>
269 <xsl:with-param name="interfacelist" select="@name"/>
270 </xsl:call-template>
271 </xsl:otherwise>
272 </xsl:choose>
273 <xsl:text>#endif // VBOX_WITH_XPCOM
274</xsl:text>
275</xsl:template>
276
277
278<!-- - - - - - - - - - - - - - - - - - - - - - -
279 templates for dealing with names and parameters
280 - - - - - - - - - - - - - - - - - - - - - - -->
281
282<xsl:template name="tospace">
283 <xsl:param name="str"/>
284 <xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_', ' ')"/>
285</xsl:template>
286
287<xsl:template name="checkoption">
288 <xsl:param name="optionlist"/>
289 <xsl:param name="option"/>
290 <xsl:value-of select="string-length($option) > 0 and contains(concat(',', translate($optionlist, ' ', ''), ','), concat(',', $option, ','))"/>
291</xsl:template>
292
293<xsl:template name="getattrlist">
294 <xsl:param name="val"/>
295 <xsl:param name="separator" select="','"/>
296
297 <xsl:if test="$val and $val != ''">
298 <xsl:choose>
299 <xsl:when test="contains($val,$separator)">
300 <token>
301 <xsl:value-of select="substring-before($val,$separator)"/>
302 </token>
303 <xsl:call-template name="getattrlist">
304 <xsl:with-param name="val" select="substring-after($val,$separator)"/>
305 <xsl:with-param name="separator" select="$separator"/>
306 </xsl:call-template>
307 </xsl:when>
308 <xsl:otherwise>
309 <token><xsl:value-of select="$val"/></token>
310 </xsl:otherwise>
311 </xsl:choose>
312 </xsl:if>
313</xsl:template>
314
315<xsl:template name="translatepublictype">
316 <xsl:param name="type"/>
317 <xsl:param name="dir"/>
318 <xsl:param name="mod"/>
319
320 <!-- get C++ glue type from IDL type from table in typemap-shared.inc.xsl -->
321 <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
322 <xsl:choose>
323 <xsl:when test="$type='wstring' or $type='uuid'">
324 <xsl:choose>
325 <xsl:when test="$dir='in'">
326 <xsl:text>IN_BSTR</xsl:text>
327 </xsl:when>
328 <xsl:otherwise>
329 <xsl:text>BSTR</xsl:text>
330 </xsl:otherwise>
331 </xsl:choose>
332 </xsl:when>
333 <xsl:when test="string-length($gluetypefield)">
334 <xsl:value-of select="$gluetypefield"/>
335 </xsl:when>
336 <xsl:when test="//enum[@name=$type]">
337 <xsl:value-of select="concat($type, '_T')"/>
338 </xsl:when>
339 <xsl:when test="$type='$unknown'">
340 <xsl:text>IUnknown *</xsl:text>
341 </xsl:when>
342 <xsl:when test="//interface[@name=$type]">
343 <xsl:variable name="thatif" select="//interface[@name=$type]"/>
344 <xsl:variable name="thatifname" select="$thatif/@name"/>
345 <xsl:value-of select="concat($thatifname, ' *')"/>
346 </xsl:when>
347 <xsl:otherwise>
348 <xsl:call-template name="fatalError">
349 <xsl:with-param name="msg" select="concat('translatepublictype: Type &quot;', $type, '&quot; is not supported.')"/>
350 </xsl:call-template>
351 </xsl:otherwise>
352 </xsl:choose>
353 <xsl:if test="$mod='ptr'">
354 <xsl:text> *</xsl:text>
355 </xsl:if>
356</xsl:template>
357
358<xsl:template name="translatewrappedtype">
359 <xsl:param name="type"/>
360 <xsl:param name="dir"/>
361 <xsl:param name="mod"/>
362 <xsl:param name="safearray"/>
363
364 <!-- get C++ wrap type from IDL type from table in typemap-shared.inc.xsl -->
365 <xsl:variable name="wraptypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
366 <xsl:choose>
367 <xsl:when test="$type='wstring'">
368 <xsl:if test="$dir='in' and not($safearray='yes')">
369 <xsl:text>const </xsl:text>
370 </xsl:if>
371 <xsl:text>com::Utf8Str &amp;</xsl:text>
372 </xsl:when>
373 <xsl:when test="$type='uuid'">
374 <xsl:if test="$dir='in'">
375 <xsl:text>const </xsl:text>
376 </xsl:if>
377 <xsl:text>com::Guid &amp;</xsl:text>
378 </xsl:when>
379 <xsl:when test="string-length($wraptypefield)">
380 <xsl:value-of select="$wraptypefield"/>
381 </xsl:when>
382 <xsl:when test="//enum[@name=$type]">
383 <xsl:value-of select="concat($type, '_T')"/>
384 </xsl:when>
385 <xsl:when test="$type='$unknown'">
386 <xsl:if test="$dir='in' and not($safearray='yes')">
387 <xsl:text>const </xsl:text>
388 </xsl:if>
389 <xsl:text>ComPtr&lt;IUnknown&gt; &amp;</xsl:text>
390 </xsl:when>
391 <xsl:when test="//interface[@name=$type]">
392 <xsl:variable name="thatif" select="//interface[@name=$type]"/>
393 <xsl:variable name="thatifname" select="$thatif/@name"/>
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;', $thatifname, '&gt; &amp;')"/>
398 </xsl:when>
399 <xsl:otherwise>
400 <xsl:call-template name="fatalError">
401 <xsl:with-param name="msg" select="concat('translatewrappedtype: Type &quot;', $type, '&quot; is not supported.')"/>
402 </xsl:call-template>
403 </xsl:otherwise>
404 </xsl:choose>
405 <xsl:if test="$mod='ptr'">
406 <xsl:text> *</xsl:text>
407 </xsl:if>
408</xsl:template>
409
410<xsl:template name="translatefmtspectype">
411 <xsl:param name="type"/>
412 <xsl:param name="dir"/>
413 <xsl:param name="mod"/>
414 <xsl:param name="safearray"/>
415 <xsl:param name="isref"/>
416
417 <!-- get C format string for IDL type from table in typemap-shared.inc.xsl -->
418 <xsl:variable name="wrapfmt" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluefmt"/>
419 <xsl:choose>
420 <xsl:when test="$mod='ptr' or ($isref='yes' and $dir!='in')">
421 <xsl:text>%p</xsl:text>
422 </xsl:when>
423 <xsl:when test="$safearray='yes'">
424 <xsl:text>%zu</xsl:text>
425 </xsl:when>
426 <xsl:when test="string-length($wrapfmt)">
427 <xsl:value-of select="$wrapfmt"/>
428 </xsl:when>
429 <xsl:when test="//enum[@name=$type]">
430 <xsl:text>%RU32</xsl:text>
431 </xsl:when>
432 <xsl:when test="$type='$unknown'">
433 <xsl:text>%p</xsl:text>
434 </xsl:when>
435 <xsl:when test="//interface[@name=$type]">
436 <xsl:text>%p</xsl:text>
437 </xsl:when>
438 <xsl:otherwise>
439 <xsl:call-template name="fatalError">
440 <xsl:with-param name="msg" select="concat('translatefmtcpectype: Type &quot;', $type, '&quot; is not supported.')"/>
441 </xsl:call-template>
442 </xsl:otherwise>
443 </xsl:choose>
444</xsl:template>
445
446<!-- - - - - - - - - - - - - - - - - - - - - - -
447 templates for handling entire interfaces and their contents
448 - - - - - - - - - - - - - - - - - - - - - - -->
449
450<xsl:template name="emitInterface">
451 <xsl:param name="iface"/>
452
453 <xsl:variable name="addinterfaces">
454 <xsl:call-template name="getattrlist">
455 <xsl:with-param name="val" select="$iface/@wrap-hint-server-addinterfaces"/>
456 </xsl:call-template>
457 </xsl:variable>
458
459 <xsl:call-template name="emitHeader">
460 <xsl:with-param name="iface" select="$iface"/>
461 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
462 </xsl:call-template>
463
464 <xsl:call-template name="emitCode">
465 <xsl:with-param name="iface" select="$iface"/>
466 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
467 </xsl:call-template>
468</xsl:template>
469
470<xsl:template match="attribute/@type | param/@type" mode="public">
471 <xsl:param name="dir"/>
472
473 <xsl:variable name="gluetype">
474 <xsl:call-template name="translatepublictype">
475 <xsl:with-param name="type" select="."/>
476 <xsl:with-param name="dir" select="$dir"/>
477 <xsl:with-param name="mod" select="../@mod"/>
478 </xsl:call-template>
479 </xsl:variable>
480
481 <xsl:if test="../@safearray='yes'">
482 <xsl:choose>
483 <xsl:when test="$dir='in'">
484 <xsl:text>ComSafeArrayIn(</xsl:text>
485 </xsl:when>
486 <xsl:otherwise>
487 <xsl:text>ComSafeArrayOut(</xsl:text>
488 </xsl:otherwise>
489 </xsl:choose>
490 </xsl:if>
491 <xsl:value-of select="$gluetype"/>
492 <xsl:choose>
493 <xsl:when test="../@safearray='yes'">
494 <xsl:text>, </xsl:text>
495 </xsl:when>
496 <xsl:otherwise>
497 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
498 <xsl:text> </xsl:text>
499 </xsl:if>
500 <xsl:choose>
501 <xsl:when test="$dir='in'">
502 </xsl:when>
503 <xsl:otherwise>
504 <xsl:value-of select="'*'"/>
505 </xsl:otherwise>
506 </xsl:choose>
507 </xsl:otherwise>
508 </xsl:choose>
509 <xsl:text>a</xsl:text>
510 <xsl:call-template name="capitalize">
511 <xsl:with-param name="str" select="../@name"/>
512 </xsl:call-template>
513 <xsl:if test="../@safearray='yes'">
514 <xsl:value-of select="')'"/>
515 </xsl:if>
516</xsl:template>
517
518<xsl:template match="attribute/@type | param/@type" mode="wrapped">
519 <xsl:param name="dir"/>
520
521 <xsl:variable name="wraptype">
522 <xsl:call-template name="translatewrappedtype">
523 <xsl:with-param name="type" select="."/>
524 <xsl:with-param name="dir" select="$dir"/>
525 <xsl:with-param name="mod" select="../@mod"/>
526 <xsl:with-param name="safearray" select="../@safearray"/>
527 </xsl:call-template>
528 </xsl:variable>
529
530 <xsl:choose>
531 <xsl:when test="../@safearray='yes'">
532 <xsl:if test="$dir='in'">
533 <xsl:text>const </xsl:text>
534 </xsl:if>
535 <xsl:text>std::vector&lt;</xsl:text>
536 <xsl:choose>
537 <xsl:when test="substring($wraptype,string-length($wraptype))='&amp;'">
538 <xsl:variable name="wraptype2">
539 <xsl:value-of select="substring($wraptype,1,string-length($wraptype)-2)"/>
540 </xsl:variable>
541
542 <xsl:choose>
543 <xsl:when test="substring($wraptype2,string-length($wraptype2))='&gt;'">
544 <xsl:value-of select="concat($wraptype2, ' ')"/>
545 </xsl:when>
546 <xsl:otherwise>
547 <xsl:value-of select="$wraptype2"/>
548 </xsl:otherwise>
549 </xsl:choose>
550 </xsl:when>
551 <xsl:when test="substring($wraptype,string-length($wraptype))='&gt;'">
552 <xsl:value-of select="concat($wraptype, ' ')"/>
553 </xsl:when>
554 <xsl:otherwise>
555 <xsl:value-of select="$wraptype"/>
556 </xsl:otherwise>
557 </xsl:choose>
558 <xsl:text>&gt; &amp;</xsl:text>
559 </xsl:when>
560 <xsl:otherwise>
561 <xsl:value-of select="$wraptype"/>
562 <xsl:if test="substring($wraptype,string-length($wraptype))!='&amp;'">
563 <xsl:if test="substring($wraptype,string-length($wraptype))!='*'">
564 <xsl:text> </xsl:text>
565 </xsl:if>
566 <xsl:choose>
567 <xsl:when test="$dir='in'">
568 </xsl:when>
569 <xsl:otherwise>
570 <xsl:value-of select="'*'"/>
571 </xsl:otherwise>
572 </xsl:choose>
573 </xsl:if>
574 </xsl:otherwise>
575 </xsl:choose>
576 <xsl:text>a</xsl:text>
577 <xsl:call-template name="capitalize">
578 <xsl:with-param name="str" select="../@name"/>
579 </xsl:call-template>
580</xsl:template>
581
582<xsl:template match="attribute/@type | param/@type" mode="logparamtext">
583 <xsl:param name="dir"/>
584 <xsl:param name="isref"/>
585
586 <xsl:if test="$isref!='yes' and ($dir='out' or $dir='ret')">
587 <xsl:text>*</xsl:text>
588 </xsl:if>
589 <xsl:text>a</xsl:text>
590 <xsl:call-template name="capitalize">
591 <xsl:with-param name="str" select="../@name"/>
592 </xsl:call-template>
593 <xsl:text>=</xsl:text>
594 <xsl:call-template name="translatefmtspectype">
595 <xsl:with-param name="type" select="."/>
596 <xsl:with-param name="dir" select="$dir"/>
597 <xsl:with-param name="mod" select="../@mod"/>
598 <xsl:with-param name="safearray" select="../@safearray"/>
599 <xsl:with-param name="isref" select="$isref"/>
600 </xsl:call-template>
601</xsl:template>
602
603<xsl:template match="attribute/@type | param/@type" mode="logparamval">
604 <xsl:param name="dir"/>
605 <xsl:param name="isref"/>
606
607 <xsl:choose>
608 <xsl:when test="../@safearray='yes' and $isref!='yes'">
609 <xsl:text>ComSafeArraySize(</xsl:text>
610 <xsl:if test="$isref!='yes' and $dir!='in'">
611 <xsl:text>*</xsl:text>
612 </xsl:if>
613 </xsl:when>
614 <xsl:when test="$isref!='yes' and $dir!='in'">
615 <xsl:text>*</xsl:text>
616 </xsl:when>
617 </xsl:choose>
618 <xsl:text>a</xsl:text>
619 <xsl:call-template name="capitalize">
620 <xsl:with-param name="str" select="../@name"/>
621 </xsl:call-template>
622 <xsl:choose>
623 <xsl:when test="../@safearray='yes' and $isref!='yes'">
624 <xsl:text>)</xsl:text>
625 </xsl:when>
626 </xsl:choose>
627</xsl:template>
628
629<xsl:template match="attribute/@type | param/@type" mode="paramvalconversion">
630 <xsl:param name="dir"/>
631
632 <xsl:variable name="gluetype">
633 <xsl:call-template name="translatepublictype">
634 <xsl:with-param name="type" select="."/>
635 <xsl:with-param name="dir" select="$dir"/>
636 <xsl:with-param name="mod" select="../@mod"/>
637 </xsl:call-template>
638 </xsl:variable>
639 <xsl:variable name="type" select="."/>
640 <xsl:variable name="thatif" select="//interface[@name=$type]"/>
641 <xsl:choose>
642 <xsl:when test="$type='$unknown'">
643 <xsl:if test="../@safearray='yes'">
644 <xsl:text>Array</xsl:text>
645 </xsl:if>
646 <xsl:choose>
647 <xsl:when test="$dir='in'">
648 <xsl:text>ComTypeInConverter&lt;IUnknown&gt;(</xsl:text>
649 </xsl:when>
650 <xsl:otherwise>
651 <xsl:text>ComTypeOutConverter&lt;IUnknown&gt;(</xsl:text>
652 </xsl:otherwise>
653 </xsl:choose>
654 <xsl:if test="../@safearray='yes'">
655 <xsl:choose>
656 <xsl:when test="$dir='in'">
657 <xsl:text>ComSafeArrayInArg(</xsl:text>
658 </xsl:when>
659 <xsl:otherwise>
660 <xsl:text>ComSafeArrayOutArg(</xsl:text>
661 </xsl:otherwise>
662 </xsl:choose>
663 </xsl:if>
664 </xsl:when>
665 <xsl:when test="$thatif">
666 <xsl:if test="../@safearray='yes'">
667 <xsl:text>Array</xsl:text>
668 </xsl:if>
669 <xsl:variable name="thatifname" select="$thatif/@name"/>
670 <xsl:choose>
671 <xsl:when test="$dir='in'">
672 <xsl:text>ComTypeInConverter</xsl:text>
673 </xsl:when>
674 <xsl:otherwise>
675 <xsl:text>ComTypeOutConverter</xsl:text>
676 </xsl:otherwise>
677 </xsl:choose>
678 <xsl:value-of select="concat('&lt;', $thatifname, '&gt;(')"/>
679 <xsl:if test="../@safearray='yes'">
680 <xsl:choose>
681 <xsl:when test="$dir='in'">
682 <xsl:text>ComSafeArrayInArg(</xsl:text>
683 </xsl:when>
684 <xsl:otherwise>
685 <xsl:text>ComSafeArrayOutArg(</xsl:text>
686 </xsl:otherwise>
687 </xsl:choose>
688 </xsl:if>
689 </xsl:when>
690 <xsl:when test="$type='wstring'">
691 <xsl:if test="../@safearray='yes'">
692 <xsl:text>Array</xsl:text>
693 </xsl:if>
694 <xsl:choose>
695 <xsl:when test="$dir='in'">
696 <xsl:text>BSTRInConverter(</xsl:text>
697 </xsl:when>
698 <xsl:otherwise>
699 <xsl:text>BSTROutConverter(</xsl:text>
700 </xsl:otherwise>
701 </xsl:choose>
702 <xsl:if test="../@safearray='yes'">
703 <xsl:choose>
704 <xsl:when test="$dir='in'">
705 <xsl:text>ComSafeArrayInArg(</xsl:text>
706 </xsl:when>
707 <xsl:otherwise>
708 <xsl:text>ComSafeArrayOutArg(</xsl:text>
709 </xsl:otherwise>
710 </xsl:choose>
711 </xsl:if>
712 </xsl:when>
713 <xsl:when test="$type='uuid'">
714 <xsl:if test="../@safearray='yes'">
715 <xsl:text>Array</xsl:text>
716 </xsl:if>
717 <xsl:choose>
718 <xsl:when test="$dir='in'">
719 <xsl:text>UuidInConverter(</xsl:text>
720 </xsl:when>
721 <xsl:otherwise>
722 <xsl:text>UuidOutConverter(</xsl:text>
723 </xsl:otherwise>
724 </xsl:choose>
725 <xsl:if test="../@safearray='yes'">
726 <xsl:choose>
727 <xsl:when test="$dir='in'">
728 <xsl:text>ComSafeArrayInArg(</xsl:text>
729 </xsl:when>
730 <xsl:otherwise>
731 <xsl:text>ComSafeArrayOutArg(</xsl:text>
732 </xsl:otherwise>
733 </xsl:choose>
734 </xsl:if>
735 </xsl:when>
736 <xsl:otherwise>
737 <xsl:if test="../@safearray='yes'">
738 <xsl:text>Array</xsl:text>
739 <xsl:choose>
740 <xsl:when test="$dir='in'">
741 <xsl:text>InConverter</xsl:text>
742 </xsl:when>
743 <xsl:otherwise>
744 <xsl:text>OutConverter</xsl:text>
745 </xsl:otherwise>
746 </xsl:choose>
747 <xsl:value-of select="concat('&lt;', $gluetype, '&gt;(')"/>
748 <xsl:choose>
749 <xsl:when test="$dir='in'">
750 <xsl:text>ComSafeArrayInArg(</xsl:text>
751 </xsl:when>
752 <xsl:otherwise>
753 <xsl:text>ComSafeArrayOutArg(</xsl:text>
754 </xsl:otherwise>
755 </xsl:choose>
756 </xsl:if>
757 </xsl:otherwise>
758 </xsl:choose>
759 <xsl:text>a</xsl:text>
760 <xsl:call-template name="capitalize">
761 <xsl:with-param name="str" select="../@name"/>
762 </xsl:call-template>
763 <xsl:choose>
764 <xsl:when test="$type='$unknown' or $thatif">
765 <xsl:choose>
766 <xsl:when test="../@safearray='yes'">
767 <xsl:text>)).array()</xsl:text>
768 </xsl:when>
769 <xsl:otherwise>
770 <xsl:text>).ptr()</xsl:text>
771 </xsl:otherwise>
772 </xsl:choose>
773 </xsl:when>
774 <xsl:when test="$type='wstring'">
775 <xsl:choose>
776 <xsl:when test="../@safearray='yes'">
777 <xsl:text>)).array()</xsl:text>
778 </xsl:when>
779 <xsl:otherwise>
780 <xsl:text>).str()</xsl:text>
781 </xsl:otherwise>
782 </xsl:choose>
783 </xsl:when>
784 <xsl:when test="$type='uuid'">
785 <xsl:choose>
786 <xsl:when test="../@safearray='yes'">
787 <xsl:text>)).array()</xsl:text>
788 </xsl:when>
789 <xsl:otherwise>
790 <xsl:text>).uuid()</xsl:text>
791 </xsl:otherwise>
792 </xsl:choose>
793 </xsl:when>
794 <xsl:otherwise>
795 <xsl:if test="../@safearray='yes'">
796 <xsl:text>)).array()</xsl:text>
797 </xsl:if>
798 </xsl:otherwise>
799 </xsl:choose>
800</xsl:template>
801
802<!-- - - - - - - - - - - - - - - - - - - - - - -
803 emit attribute
804 - - - - - - - - - - - - - - - - - - - - - - -->
805
806<xsl:template match="attribute" mode="public">
807 <xsl:variable name="attrbasename">
808 <xsl:call-template name="capitalize">
809 <xsl:with-param name="str" select="@name"/>
810 </xsl:call-template>
811 </xsl:variable>
812
813 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $attrbasename, '))(')"/>
814 <xsl:apply-templates select="@type" mode="public">
815 <xsl:with-param name="dir" select="'out'"/>
816 </xsl:apply-templates>
817 <xsl:text>);
818</xsl:text>
819
820 <xsl:if test="not(@readonly) or @readonly!='yes'">
821 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $attrbasename, '))(')"/>
822 <xsl:apply-templates select="@type" mode="public">
823 <xsl:with-param name="dir" select="'in'"/>
824 </xsl:apply-templates>
825 <xsl:text>);
826</xsl:text>
827 </xsl:if>
828</xsl:template>
829
830<xsl:template match="attribute" mode="wrapped">
831 <xsl:variable name="attrbasename">
832 <xsl:call-template name="capitalize">
833 <xsl:with-param name="str" select="@name"/>
834 </xsl:call-template>
835 </xsl:variable>
836
837 <xsl:value-of select="concat(' virtual HRESULT get', $attrbasename, '(')"/>
838 <xsl:variable name="passAutoCaller">
839 <xsl:call-template name="checkoption">
840 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
841 <xsl:with-param name="option" select="'passcaller'"/>
842 </xsl:call-template>
843 </xsl:variable>
844 <xsl:if test="$passAutoCaller = 'true'">
845 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
846 </xsl:if>
847 <xsl:apply-templates select="@type" mode="wrapped">
848 <xsl:with-param name="dir" select="'out'"/>
849 </xsl:apply-templates>
850 <xsl:text>) = 0;
851</xsl:text>
852
853 <xsl:if test="not(@readonly) or @readonly!='yes'">
854 <xsl:value-of select="concat(' virtual HRESULT set', $attrbasename, '(')"/>
855 <xsl:if test="$passAutoCaller = 'true'">
856 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
857 </xsl:if>
858 <xsl:apply-templates select="@type" mode="wrapped">
859 <xsl:with-param name="dir" select="'in'"/>
860 </xsl:apply-templates>
861 <xsl:text>) = 0;
862</xsl:text>
863 </xsl:if>
864</xsl:template>
865
866<xsl:template match="attribute" mode="code">
867 <xsl:param name="topclass"/>
868
869 <xsl:variable name="attrbasename">
870 <xsl:call-template name="capitalize">
871 <xsl:with-param name="str" select="@name"/>
872 </xsl:call-template>
873 </xsl:variable>
874 <xsl:variable name="limitedAutoCaller">
875 <xsl:call-template name="checkoption">
876 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
877 <xsl:with-param name="option" select="'limitedcaller'"/>
878 </xsl:call-template>
879 </xsl:variable>
880
881 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(', $attrbasename, ')(')"/>
882 <xsl:apply-templates select="@type" mode="public">
883 <xsl:with-param name="dir" select="'out'"/>
884 </xsl:apply-templates>
885 <xsl:text>)
886{
887 LogRelFlow(("{%p} %s: enter </xsl:text>
888 <xsl:apply-templates select="@type" mode="logparamtext">
889 <xsl:with-param name="dir" select="'out'"/>
890 <xsl:with-param name="isref" select="'yes'"/>
891 </xsl:apply-templates>
892 <xsl:text>\n", this, </xsl:text>
893 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
894 <xsl:apply-templates select="@type" mode="logparamval">
895 <xsl:with-param name="dir" select="'out'"/>
896 <xsl:with-param name="isref" select="'yes'"/>
897 </xsl:apply-templates>
898 <xsl:text>));
899
900 VirtualBoxBase::clearError();
901
902 HRESULT hrc;
903
904 try
905 {
906 CheckComArgOutPointerValidThrow(a</xsl:text>
907 <xsl:value-of select="$attrbasename"/>
908 <xsl:text>);
909
910 </xsl:text>
911 <xsl:choose>
912 <xsl:when test="$limitedAutoCaller = 'true'">
913 <xsl:text>AutoLimitedCaller</xsl:text>
914 </xsl:when>
915 <xsl:otherwise>
916 <xsl:text>AutoCaller</xsl:text>
917 </xsl:otherwise>
918 </xsl:choose>
919 <xsl:text> autoCaller(this);
920 if (FAILED(autoCaller.rc()))
921 throw autoCaller.rc();
922
923</xsl:text>
924 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
925 <xsl:variable name="passAutoCaller">
926 <xsl:call-template name="checkoption">
927 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
928 <xsl:with-param name="option" select="'passcaller'"/>
929 </xsl:call-template>
930 </xsl:variable>
931 <xsl:if test="$passAutoCaller = 'true'">
932 <xsl:text>autoCaller, </xsl:text>
933 </xsl:if>
934 <xsl:apply-templates select="@type" mode="paramvalconversion">
935 <xsl:with-param name="dir" select="'out'"/>
936 </xsl:apply-templates>
937 <xsl:text>);
938 }
939 catch (HRESULT hrc2)
940 {
941 hrc = hrc2;
942 }
943 catch (...)
944 {
945 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
946 }
947
948 LogRelFlow(("{%p} %s: leave </xsl:text>
949 <xsl:apply-templates select="@type" mode="logparamtext">
950 <xsl:with-param name="dir" select="'out'"/>
951 <xsl:with-param name="isref" select="''"/>
952 </xsl:apply-templates>
953 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
954 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
955 <xsl:apply-templates select="@type" mode="logparamval">
956 <xsl:with-param name="dir" select="'out'"/>
957 <xsl:with-param name="isref" select="''"/>
958 </xsl:apply-templates>
959 <xsl:text>, hrc));
960 return hrc;
961}
962
963</xsl:text>
964 <xsl:if test="not(@readonly) or @readonly!='yes'">
965 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
966 <xsl:apply-templates select="@type" mode="public">
967 <xsl:with-param name="dir" select="'in'"/>
968 </xsl:apply-templates>
969 <!-- @todo check in parameters if possible -->
970 <xsl:text>)
971{
972 LogRelFlow(("{%p} %s: enter </xsl:text>
973 <xsl:apply-templates select="@type" mode="logparamtext">
974 <xsl:with-param name="dir" select="'in'"/>
975 <xsl:with-param name="isref" select="''"/>
976 </xsl:apply-templates>
977 <xsl:text>\n", this, </xsl:text>
978 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
979 <xsl:apply-templates select="@type" mode="logparamval">
980 <xsl:with-param name="dir" select="'in'"/>
981 <xsl:with-param name="isref" select="''"/>
982 </xsl:apply-templates>
983 <xsl:text>));
984
985 VirtualBoxBase::clearError();
986
987 HRESULT hrc;
988
989 try
990 {
991 </xsl:text>
992 <xsl:choose>
993 <xsl:when test="$limitedAutoCaller = 'true'">
994 <xsl:text>AutoLimitedCaller</xsl:text>
995 </xsl:when>
996 <xsl:otherwise>
997 <xsl:text>AutoCaller</xsl:text>
998 </xsl:otherwise>
999 </xsl:choose>
1000 <xsl:text> autoCaller(this);
1001 if (FAILED(autoCaller.rc()))
1002 throw autoCaller.rc();
1003
1004</xsl:text>
1005 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
1006 <xsl:if test="$passAutoCaller = 'true'">
1007 <xsl:text>autoCaller, </xsl:text>
1008 </xsl:if>
1009 <xsl:apply-templates select="@type" mode="paramvalconversion">
1010 <xsl:with-param name="dir" select="'in'"/>
1011 </xsl:apply-templates>
1012 <xsl:text>);
1013 }
1014 catch (HRESULT hrc2)
1015 {
1016 hrc = hrc2;
1017 }
1018 catch (...)
1019 {
1020 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1021 }
1022
1023 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1024 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1025 <xsl:text>hrc));
1026 return hrc;
1027}
1028
1029</xsl:text>
1030 </xsl:if>
1031</xsl:template>
1032
1033<!-- - - - - - - - - - - - - - - - - - - - - - -
1034 emit all attributes of an interface
1035 - - - - - - - - - - - - - - - - - - - - - - -->
1036<xsl:template name="emitAttributes">
1037 <xsl:param name="iface"/>
1038 <xsl:param name="topclass"/>
1039 <xsl:param name="pmode"/>
1040
1041 <!-- first recurse to emit all base interfaces -->
1042 <xsl:variable name="extends" select="$iface/@extends"/>
1043 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1044 <xsl:call-template name="emitAttributes">
1045 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
1046 <xsl:with-param name="topclass" select="$topclass"/>
1047 <xsl:with-param name="pmode" select="$pmode"/>
1048 </xsl:call-template>
1049 </xsl:if>
1050
1051 <xsl:choose>
1052 <xsl:when test="$pmode='code'">
1053 <xsl:text>//
1054</xsl:text>
1055 <xsl:value-of select="concat('// ', $iface/@name, ' properties')"/>
1056 <xsl:text>
1057//
1058
1059</xsl:text>
1060 </xsl:when>
1061 <xsl:otherwise>
1062 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' properties&#10;')"/>
1063 </xsl:otherwise>
1064 </xsl:choose>
1065 <xsl:choose>
1066 <xsl:when test="$pmode='public'">
1067 <xsl:apply-templates select="$iface/attribute" mode="public"/>
1068 </xsl:when>
1069 <xsl:when test="$pmode='wrapped'">
1070 <xsl:apply-templates select="$iface/attribute" mode="wrapped"/>
1071 </xsl:when>
1072 <xsl:when test="$pmode='code'">
1073 <xsl:apply-templates select="$iface/attribute" mode="code">
1074 <xsl:with-param name="topclass" select="$topclass"/>
1075 </xsl:apply-templates>
1076 </xsl:when>
1077 <xsl:otherwise/>
1078 </xsl:choose>
1079</xsl:template>
1080
1081<!-- - - - - - - - - - - - - - - - - - - - - - -
1082 emit method
1083 - - - - - - - - - - - - - - - - - - - - - - -->
1084
1085<xsl:template match="method" mode="public">
1086 <xsl:variable name="methodindent">
1087 <xsl:call-template name="tospace">
1088 <xsl:with-param name="str" select="@name"/>
1089 </xsl:call-template>
1090 </xsl:variable>
1091
1092 <xsl:text> STDMETHOD(</xsl:text>
1093 <xsl:call-template name="capitalize">
1094 <xsl:with-param name="str" select="@name"/>
1095 </xsl:call-template>
1096 <xsl:text>)(</xsl:text>
1097 <xsl:for-each select="param">
1098 <xsl:apply-templates select="@type" mode="public">
1099 <xsl:with-param name="dir" select="@dir"/>
1100 </xsl:apply-templates>
1101 <xsl:if test="not(position()=last())">
1102 <xsl:text>,
1103 </xsl:text>
1104 <xsl:value-of select="$methodindent"/>
1105 </xsl:if>
1106 </xsl:for-each>
1107 <xsl:text>);
1108</xsl:text>
1109</xsl:template>
1110
1111<xsl:template match="method" mode="wrapped">
1112 <xsl:variable name="methodindent">
1113 <xsl:call-template name="tospace">
1114 <xsl:with-param name="str" select="@name"/>
1115 </xsl:call-template>
1116 </xsl:variable>
1117
1118 <xsl:text> virtual HRESULT </xsl:text>
1119 <xsl:call-template name="uncapitalize">
1120 <xsl:with-param name="str" select="@name"/>
1121 </xsl:call-template>
1122 <xsl:text>(</xsl:text>
1123 <xsl:variable name="passAutoCaller">
1124 <xsl:call-template name="checkoption">
1125 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1126 <xsl:with-param name="option" select="'passcaller'"/>
1127 </xsl:call-template>
1128 </xsl:variable>
1129 <xsl:if test="$passAutoCaller = 'true'">
1130 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1131 <xsl:if test="count(param) > 0">
1132 <xsl:text>,
1133 </xsl:text>
1134 <xsl:value-of select="$methodindent"/>
1135 </xsl:if>
1136 </xsl:if>
1137 <xsl:for-each select="param">
1138 <xsl:apply-templates select="@type" mode="wrapped">
1139 <xsl:with-param name="dir" select="@dir"/>
1140 </xsl:apply-templates>
1141 <xsl:if test="not(position()=last())">
1142 <xsl:text>,
1143 </xsl:text>
1144 <xsl:value-of select="$methodindent"/>
1145 </xsl:if>
1146 </xsl:for-each>
1147 <xsl:text>) = 0;
1148</xsl:text>
1149</xsl:template>
1150
1151<xsl:template match="method" mode="code">
1152 <xsl:param name="topclass"/>
1153
1154 <xsl:variable name="methodindent">
1155 <xsl:call-template name="tospace">
1156 <xsl:with-param name="str" select="@name"/>
1157 </xsl:call-template>
1158 </xsl:variable>
1159 <xsl:variable name="methodclassindent">
1160 <xsl:call-template name="tospace">
1161 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1162 </xsl:call-template>
1163 </xsl:variable>
1164 <xsl:variable name="methodbasename">
1165 <xsl:call-template name="capitalize">
1166 <xsl:with-param name="str" select="@name"/>
1167 </xsl:call-template>
1168 </xsl:variable>
1169 <xsl:variable name="limitedAutoCaller">
1170 <xsl:call-template name="checkoption">
1171 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1172 <xsl:with-param name="option" select="'limitedcaller'"/>
1173 </xsl:call-template>
1174 </xsl:variable>
1175
1176 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1177 <xsl:for-each select="param">
1178 <xsl:apply-templates select="@type" mode="public">
1179 <xsl:with-param name="dir" select="@dir"/>
1180 </xsl:apply-templates>
1181 <xsl:if test="not(position()=last())">
1182 <xsl:text>,
1183 </xsl:text>
1184 <xsl:value-of select="$methodclassindent"/>
1185 </xsl:if>
1186 </xsl:for-each>
1187 <xsl:text>)
1188{
1189 LogRelFlow(("{%p} %s:enter</xsl:text>
1190 <xsl:for-each select="param">
1191 <xsl:text> </xsl:text>
1192 <xsl:apply-templates select="@type" mode="logparamtext">
1193 <xsl:with-param name="dir" select="@dir"/>
1194 <xsl:with-param name="isref" select="'yes'"/>
1195 </xsl:apply-templates>
1196 </xsl:for-each>
1197 <xsl:text>\n", this</xsl:text>
1198 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1199 <xsl:for-each select="param">
1200 <xsl:text>, </xsl:text>
1201 <xsl:apply-templates select="@type" mode="logparamval">
1202 <xsl:with-param name="dir" select="@dir"/>
1203 <xsl:with-param name="isref" select="'yes'"/>
1204 </xsl:apply-templates>
1205 </xsl:for-each>
1206 <xsl:text>));
1207
1208 VirtualBoxBase::clearError();
1209
1210 HRESULT hrc;
1211
1212 try
1213 {
1214</xsl:text>
1215 <!-- @todo check in parameters if possible -->
1216 <xsl:for-each select="param">
1217 <xsl:if test="@dir!='in'">
1218 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1219 <xsl:call-template name="capitalize">
1220 <xsl:with-param name="str" select="@name"/>
1221 </xsl:call-template>
1222 <xsl:text>);
1223</xsl:text>
1224 </xsl:if>
1225 </xsl:for-each>
1226 <xsl:text>
1227 </xsl:text>
1228 <xsl:choose>
1229 <xsl:when test="$limitedAutoCaller = 'true'">
1230 <xsl:text>AutoLimitedCaller</xsl:text>
1231 </xsl:when>
1232 <xsl:otherwise>
1233 <xsl:text>AutoCaller</xsl:text>
1234 </xsl:otherwise>
1235 </xsl:choose>
1236 <xsl:text> autoCaller(this);
1237 if (FAILED(autoCaller.rc()))
1238 throw autoCaller.rc();
1239
1240</xsl:text>
1241 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1242 <xsl:variable name="passAutoCaller">
1243 <xsl:call-template name="checkoption">
1244 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1245 <xsl:with-param name="option" select="'passcaller'"/>
1246 </xsl:call-template>
1247 </xsl:variable>
1248 <xsl:if test="$passAutoCaller = 'true'">
1249 <xsl:text>autoCaller</xsl:text>
1250 <xsl:if test="count(param) > 0">
1251 <xsl:text>,
1252 </xsl:text>
1253 <xsl:value-of select="$methodindent"/>
1254 </xsl:if>
1255 </xsl:if>
1256 <xsl:for-each select="param">
1257 <xsl:apply-templates select="@type" mode="paramvalconversion">
1258 <xsl:with-param name="dir" select="@dir"/>
1259 </xsl:apply-templates>
1260 <xsl:if test="not(position()=last())">
1261 <xsl:text>,
1262 </xsl:text>
1263 <xsl:value-of select="$methodindent"/>
1264 </xsl:if>
1265 </xsl:for-each>
1266 <xsl:text>);
1267 }
1268 catch (HRESULT hrc2)
1269 {
1270 hrc = hrc2;
1271 }
1272 catch (...)
1273 {
1274 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1275 }
1276
1277 LogRelFlow(("{%p} %s: leave</xsl:text>
1278 <xsl:for-each select="param">
1279 <xsl:if test="@dir!='in'">
1280 <xsl:text> </xsl:text>
1281 <xsl:apply-templates select="@type" mode="logparamtext">
1282 <xsl:with-param name="dir" select="@dir"/>
1283 <xsl:with-param name="isref" select="''"/>
1284 </xsl:apply-templates>
1285 </xsl:if>
1286 </xsl:for-each>
1287 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1288 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1289 <xsl:for-each select="param">
1290 <xsl:if test="@dir!='in'">
1291 <xsl:text>, </xsl:text>
1292 <xsl:apply-templates select="@type" mode="logparamval">
1293 <xsl:with-param name="dir" select="@dir"/>
1294 <xsl:with-param name="isref" select="''"/>
1295 </xsl:apply-templates>
1296 </xsl:if>
1297 </xsl:for-each>
1298 <xsl:text>, hrc));
1299 return hrc;
1300}
1301
1302</xsl:text>
1303</xsl:template>
1304
1305<!-- - - - - - - - - - - - - - - - - - - - - - -
1306 emit all methods of an interface
1307 - - - - - - - - - - - - - - - - - - - - - - -->
1308<xsl:template name="emitMethods">
1309 <xsl:param name="iface"/>
1310 <xsl:param name="topclass"/>
1311 <xsl:param name="pmode"/>
1312
1313 <!-- first recurse to emit all base interfaces -->
1314 <xsl:variable name="extends" select="$iface/@extends"/>
1315 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1316 <xsl:call-template name="emitMethods">
1317 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
1318 <xsl:with-param name="topclass" select="$topclass"/>
1319 <xsl:with-param name="pmode" select="$pmode"/>
1320 </xsl:call-template>
1321 </xsl:if>
1322
1323 <xsl:choose>
1324 <xsl:when test="$pmode='code'">
1325 <xsl:text>//
1326</xsl:text>
1327 <xsl:value-of select="concat('// ', $iface/@name, ' methods')"/>
1328 <xsl:text>
1329//
1330
1331</xsl:text>
1332 </xsl:when>
1333 <xsl:otherwise>
1334 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' methods&#10;')"/>
1335 </xsl:otherwise>
1336 </xsl:choose>
1337 <xsl:choose>
1338 <xsl:when test="$pmode='public'">
1339 <xsl:apply-templates select="$iface/method" mode="public"/>
1340 </xsl:when>
1341 <xsl:when test="$pmode='wrapped'">
1342 <xsl:apply-templates select="$iface/method" mode="wrapped"/>
1343 </xsl:when>
1344 <xsl:when test="$pmode='code'">
1345 <xsl:apply-templates select="$iface/method" mode="code">
1346 <xsl:with-param name="topclass" select="$topclass"/>
1347 </xsl:apply-templates>
1348 </xsl:when>
1349 <xsl:otherwise/>
1350 </xsl:choose>
1351</xsl:template>
1352
1353<!-- - - - - - - - - - - - - - - - - - - - - - -
1354 emit all attributes and methods declarations of an interface
1355 - - - - - - - - - - - - - - - - - - - - - - -->
1356<xsl:template name="emitInterfaceDecls">
1357 <xsl:param name="iface"/>
1358 <xsl:param name="pmode"/>
1359
1360 <!-- attributes -->
1361 <xsl:call-template name="emitAttributes">
1362 <xsl:with-param name="iface" select="$iface"/>
1363 <xsl:with-param name="pmode" select="$pmode"/>
1364 </xsl:call-template>
1365
1366 <!-- methods -->
1367 <xsl:call-template name="emitMethods">
1368 <xsl:with-param name="iface" select="$iface"/>
1369 <xsl:with-param name="pmode" select="$pmode"/>
1370 </xsl:call-template>
1371</xsl:template>
1372
1373<!-- - - - - - - - - - - - - - - - - - - - - - -
1374 emit auxiliary method declarations of an interface
1375 - - - - - - - - - - - - - - - - - - - - - - -->
1376<xsl:template name="emitAuxMethodDecls">
1377 <xsl:param name="iface"/>
1378 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
1379</xsl:template>
1380
1381<!-- - - - - - - - - - - - - - - - - - - - - - -
1382 emit the header file of an interface
1383 - - - - - - - - - - - - - - - - - - - - - - -->
1384<xsl:template name="emitHeader">
1385 <xsl:param name="iface"/>
1386 <xsl:param name="addinterfaces"/>
1387
1388 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
1389
1390 <xsl:choose>
1391 <xsl:when test="$filelistonly=''">
1392 <xsl:apply-templates select="$iface" mode="startfile">
1393 <xsl:with-param name="file" select="$filename"/>
1394 </xsl:apply-templates>
1395 <xsl:call-template name="fileheader">
1396 <xsl:with-param name="name" select="$filename"/>
1397 <xsl:with-param name="class" select="substring(@name, 2)"/>
1398 <xsl:with-param name="type" select="'header'"/>
1399 </xsl:call-template>
1400 <xsl:apply-templates select="$iface" mode="classheader">
1401 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1402 </xsl:apply-templates>
1403
1404 <!-- interface attributes/methods (public) -->
1405 <xsl:call-template name="emitInterfaceDecls">
1406 <xsl:with-param name="iface" select="$iface"/>
1407 <xsl:with-param name="pmode" select="'public'"/>
1408 </xsl:call-template>
1409
1410 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1411 <!-- This is super tricky, as the for-each switches to the node
1412 set, which means the normal document isn't available any
1413 more. So need to use the global root node to get back into
1414 the documemt to find corresponding interface data. -->
1415 <xsl:variable name="addifname">
1416 <xsl:value-of select="string(.)"/>
1417 </xsl:variable>
1418 <xsl:call-template name="emitInterfaceDecls">
1419 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1420 <xsl:with-param name="pmode" select="'public'"/>
1421 </xsl:call-template>
1422 </xsl:for-each>
1423
1424 <!-- auxiliary methods (public) -->
1425 <xsl:call-template name="emitAuxMethodDecls">
1426 <xsl:with-param name="iface" select="$iface"/>
1427 </xsl:call-template>
1428
1429 <!-- switch to private -->
1430 <xsl:text>
1431private:</xsl:text>
1432
1433 <!-- wrapped interface attributes/methods (private) -->
1434 <xsl:call-template name="emitInterfaceDecls">
1435 <xsl:with-param name="iface" select="$iface"/>
1436 <xsl:with-param name="pmode" select="'wrapped'"/>
1437 </xsl:call-template>
1438
1439 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1440 <!-- This is super tricky, as the for-each switches to the node
1441 set, which means the normal document isn't available any
1442 more. So need to use the global root node to get back into
1443 the documemt to find corresponding interface data. -->
1444 <xsl:variable name="addifname">
1445 <xsl:value-of select="string(.)"/>
1446 </xsl:variable>
1447 <xsl:call-template name="emitInterfaceDecls">
1448 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1449 <xsl:with-param name="pmode" select="'wrapped'"/>
1450 </xsl:call-template>
1451 </xsl:for-each>
1452
1453 <xsl:apply-templates select="$iface" mode="classfooter"/>
1454 <xsl:apply-templates select="$iface" mode="endfile">
1455 <xsl:with-param name="file" select="$filename"/>
1456 </xsl:apply-templates>
1457 </xsl:when>
1458 <xsl:otherwise>
1459 <xsl:apply-templates select="$iface" mode="listfile">
1460 <xsl:with-param name="file" select="$filename"/>
1461 </xsl:apply-templates>
1462 </xsl:otherwise>
1463 </xsl:choose>
1464</xsl:template>
1465
1466<!-- - - - - - - - - - - - - - - - - - - - - - -
1467 emit all attributes and methods definitions of an interface
1468 - - - - - - - - - - - - - - - - - - - - - - -->
1469<xsl:template name="emitInterfaceDefs">
1470 <xsl:param name="iface"/>
1471 <xsl:param name="addinterfaces"/>
1472
1473 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', substring($iface/@name, 2), 'Wrap)&#10;&#10;')"/>
1474
1475 <!-- attributes -->
1476 <xsl:call-template name="emitAttributes">
1477 <xsl:with-param name="iface" select="$iface"/>
1478 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1479 <xsl:with-param name="pmode" select="'code'"/>
1480 </xsl:call-template>
1481
1482 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1483 <!-- This is super tricky, as the for-each switches to the node set,
1484 which means the normal document isn't available any more. So need
1485 to use the global root node to get back into the documemt to find
1486 corresponding interface data. -->
1487 <xsl:variable name="addifname">
1488 <xsl:value-of select="string(.)"/>
1489 </xsl:variable>
1490 <xsl:call-template name="emitAttributes">
1491 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1492 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1493 <xsl:with-param name="pmode" select="'code'"/>
1494 </xsl:call-template>
1495 </xsl:for-each>
1496
1497 <!-- methods -->
1498 <xsl:call-template name="emitMethods">
1499 <xsl:with-param name="iface" select="$iface"/>
1500 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1501 <xsl:with-param name="pmode" select="'code'"/>
1502 </xsl:call-template>
1503
1504 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1505 <!-- This is super tricky, as the for-each switches to the node set,
1506 which means the normal document isn't available any more. So need
1507 to use the global root node to get back into the documemt to find
1508 corresponding interface data. -->
1509 <xsl:variable name="addifname">
1510 <xsl:value-of select="string(.)"/>
1511 </xsl:variable>
1512 <xsl:call-template name="emitMethods">
1513 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1514 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1515 <xsl:with-param name="pmode" select="'code'"/>
1516 </xsl:call-template>
1517 </xsl:for-each>
1518</xsl:template>
1519
1520<!-- - - - - - - - - - - - - - - - - - - - - - -
1521 emit auxiliary method declarations of an interface
1522 - - - - - - - - - - - - - - - - - - - - - - -->
1523<xsl:template name="emitAuxMethodDefs">
1524 <xsl:param name="iface"/>
1525 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
1526</xsl:template>
1527
1528
1529<!-- - - - - - - - - - - - - - - - - - - - - - -
1530 emit the code file of an interface
1531 - - - - - - - - - - - - - - - - - - - - - - -->
1532<xsl:template name="emitCode">
1533 <xsl:param name="iface"/>
1534 <xsl:param name="addinterfaces"/>
1535
1536 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
1537
1538 <xsl:choose>
1539 <xsl:when test="$filelistonly=''">
1540 <xsl:apply-templates select="$iface" mode="startfile">
1541 <xsl:with-param name="file" select="$filename"/>
1542 </xsl:apply-templates>
1543 <xsl:call-template name="fileheader">
1544 <xsl:with-param name="name" select="$filename"/>
1545 <xsl:with-param name="class" select="substring(@name, 2)"/>
1546 <xsl:with-param name="type" select="'code'"/>
1547 </xsl:call-template>
1548 <xsl:apply-templates select="$iface" mode="codeheader">
1549 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1550 </xsl:apply-templates>
1551
1552 <!-- interface attributes/methods (public) -->
1553 <xsl:call-template name="emitInterfaceDefs">
1554 <xsl:with-param name="iface" select="$iface"/>
1555 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1556 </xsl:call-template>
1557
1558 <!-- auxiliary methods (public) -->
1559 <xsl:call-template name="emitAuxMethodDefs">
1560 <xsl:with-param name="iface" select="$iface"/>
1561 </xsl:call-template>
1562
1563 <xsl:apply-templates select="$iface" mode="codefooter">
1564 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1565 </xsl:apply-templates>
1566 <xsl:apply-templates select="$iface" mode="endfile">
1567 <xsl:with-param name="file" select="$filename"/>
1568 </xsl:apply-templates>
1569 </xsl:when>
1570 <xsl:otherwise>
1571 <xsl:apply-templates select="$iface" mode="listfile">
1572 <xsl:with-param name="file" select="$filename"/>
1573 </xsl:apply-templates>
1574 </xsl:otherwise>
1575 </xsl:choose>
1576</xsl:template>
1577
1578
1579<!-- - - - - - - - - - - - - - - - - - - - - - -
1580 wildcard match, ignore everything which has no explicit match
1581 - - - - - - - - - - - - - - - - - - - - - - -->
1582
1583<xsl:template match="*"/>
1584
1585<!-- - - - - - - - - - - - - - - - - - - - - - -
1586 ignore all if tags except those for XPIDL or MIDL target
1587 - - - - - - - - - - - - - - - - - - - - - - -->
1588
1589<xsl:template match="if">
1590 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
1591 <xsl:apply-templates/>
1592 </xsl:if>
1593</xsl:template>
1594
1595<!-- - - - - - - - - - - - - - - - - - - - - - -
1596 interface match
1597 - - - - - - - - - - - - - - - - - - - - - - -->
1598
1599<xsl:template match="interface">
1600 <xsl:if test="not(@internal='yes') and not(@supportsErrorInfo='no')">
1601 <xsl:call-template name="emitInterface">
1602 <xsl:with-param name="iface" select="."/>
1603 </xsl:call-template>
1604 </xsl:if>
1605</xsl:template>
1606
1607<!-- - - - - - - - - - - - - - - - - - - - - - -
1608 library match
1609 - - - - - - - - - - - - - - - - - - - - - - -->
1610
1611<xsl:template match="library">
1612 <xsl:apply-templates/>
1613</xsl:template>
1614
1615<!-- - - - - - - - - - - - - - - - - - - - - - -
1616 root match
1617 - - - - - - - - - - - - - - - - - - - - - - -->
1618
1619<xsl:template match="/idl">
1620 <xsl:choose>
1621 <xsl:when test="$filelistonly=''">
1622 </xsl:when>
1623 <xsl:otherwise>
1624 <xsl:value-of select="concat($filelistonly, ' := \&#10;')"/>
1625 </xsl:otherwise>
1626 </xsl:choose>
1627 <xsl:apply-templates/>
1628 <xsl:choose>
1629 <xsl:when test="$filelistonly=''">
1630 </xsl:when>
1631 <xsl:otherwise>
1632 <xsl:text>
1633</xsl:text>
1634 </xsl:otherwise>
1635 </xsl:choose>
1636</xsl:template>
1637
1638</xsl:stylesheet>
1639<!-- vi: set tabstop=4 shiftwidth=4 expandtab: -->
Note: See TracBrowser for help on using the repository browser.

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