VirtualBox

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

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

header fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 59.5 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
875 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(', $attrbasename, ')(')"/>
876 <xsl:apply-templates select="@type" mode="public">
877 <xsl:with-param name="dir" select="'out'"/>
878 </xsl:apply-templates>
879 <xsl:text>)
880{
881 LogRelFlow(("{%p} %s: enter </xsl:text>
882 <xsl:apply-templates select="@type" mode="logparamtext">
883 <xsl:with-param name="dir" select="'out'"/>
884 <xsl:with-param name="isref" select="'yes'"/>
885 </xsl:apply-templates>
886 <xsl:text>\n", this, </xsl:text>
887 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
888 <xsl:apply-templates select="@type" mode="logparamval">
889 <xsl:with-param name="dir" select="'out'"/>
890 <xsl:with-param name="isref" select="'yes'"/>
891 </xsl:apply-templates>
892 <xsl:text>));
893
894 VirtualBoxBase::clearError();
895
896 HRESULT hrc;
897
898 try
899 {
900 CheckComArgOutPointerValidThrow(a</xsl:text>
901 <xsl:value-of select="$attrbasename"/>
902 <xsl:text>);
903
904 AutoCaller autoCaller(this);
905 if (FAILED(autoCaller.rc()))
906 throw autoCaller.rc();
907
908</xsl:text>
909 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
910 <xsl:variable name="passAutoCaller">
911 <xsl:call-template name="checkoption">
912 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
913 <xsl:with-param name="option" select="'passcaller'"/>
914 </xsl:call-template>
915 </xsl:variable>
916 <xsl:if test="$passAutoCaller = 'true'">
917 <xsl:text>autoCaller, </xsl:text>
918 </xsl:if>
919 <xsl:apply-templates select="@type" mode="paramvalconversion">
920 <xsl:with-param name="dir" select="'out'"/>
921 </xsl:apply-templates>
922 <xsl:text>);
923 }
924 catch (HRESULT hrc2)
925 {
926 hrc = hrc2;
927 }
928 catch (...)
929 {
930 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
931 }
932
933 LogRelFlow(("{%p} %s: leave </xsl:text>
934 <xsl:apply-templates select="@type" mode="logparamtext">
935 <xsl:with-param name="dir" select="'out'"/>
936 <xsl:with-param name="isref" select="''"/>
937 </xsl:apply-templates>
938 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
939 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
940 <xsl:apply-templates select="@type" mode="logparamval">
941 <xsl:with-param name="dir" select="'out'"/>
942 <xsl:with-param name="isref" select="''"/>
943 </xsl:apply-templates>
944 <xsl:text>, hrc));
945 return hrc;
946}
947
948</xsl:text>
949 <xsl:if test="not(@readonly) or @readonly!='yes'">
950 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
951 <xsl:apply-templates select="@type" mode="public">
952 <xsl:with-param name="dir" select="'in'"/>
953 </xsl:apply-templates>
954 <!-- @todo check in parameters if possible -->
955 <xsl:text>)
956{
957 LogRelFlow(("{%p} %s: enter </xsl:text>
958 <xsl:apply-templates select="@type" mode="logparamtext">
959 <xsl:with-param name="dir" select="'in'"/>
960 <xsl:with-param name="isref" select="''"/>
961 </xsl:apply-templates>
962 <xsl:text>\n", this, </xsl:text>
963 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
964 <xsl:apply-templates select="@type" mode="logparamval">
965 <xsl:with-param name="dir" select="'in'"/>
966 <xsl:with-param name="isref" select="''"/>
967 </xsl:apply-templates>
968 <xsl:text>));
969
970 VirtualBoxBase::clearError();
971
972 HRESULT hrc;
973
974 try
975 {
976 AutoCaller autoCaller(this);
977 if (FAILED(autoCaller.rc()))
978 throw autoCaller.rc();
979
980</xsl:text>
981 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
982 <xsl:if test="$passAutoCaller = 'true'">
983 <xsl:text>autoCaller, </xsl:text>
984 </xsl:if>
985 <xsl:apply-templates select="@type" mode="paramvalconversion">
986 <xsl:with-param name="dir" select="'in'"/>
987 </xsl:apply-templates>
988 <xsl:text>);
989 }
990 catch (HRESULT hrc2)
991 {
992 hrc = hrc2;
993 }
994 catch (...)
995 {
996 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
997 }
998
999 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
1000 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
1001 <xsl:text>hrc));
1002 return hrc;
1003}
1004
1005</xsl:text>
1006 </xsl:if>
1007</xsl:template>
1008
1009<!-- - - - - - - - - - - - - - - - - - - - - - -
1010 emit all attributes of an interface
1011 - - - - - - - - - - - - - - - - - - - - - - -->
1012<xsl:template name="emitAttributes">
1013 <xsl:param name="iface"/>
1014 <xsl:param name="topclass"/>
1015 <xsl:param name="pmode"/>
1016
1017 <!-- first recurse to emit all base interfaces -->
1018 <xsl:variable name="extends" select="$iface/@extends"/>
1019 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1020 <xsl:call-template name="emitAttributes">
1021 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
1022 <xsl:with-param name="topclass" select="$topclass"/>
1023 <xsl:with-param name="pmode" select="$pmode"/>
1024 </xsl:call-template>
1025 </xsl:if>
1026
1027 <xsl:choose>
1028 <xsl:when test="$pmode='code'">
1029 <xsl:text>//
1030</xsl:text>
1031 <xsl:value-of select="concat('// ', $iface/@name, ' properties')"/>
1032 <xsl:text>
1033//
1034
1035</xsl:text>
1036 </xsl:when>
1037 <xsl:otherwise>
1038 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' properties&#10;')"/>
1039 </xsl:otherwise>
1040 </xsl:choose>
1041 <xsl:choose>
1042 <xsl:when test="$pmode='public'">
1043 <xsl:apply-templates select="$iface/attribute" mode="public"/>
1044 </xsl:when>
1045 <xsl:when test="$pmode='wrapped'">
1046 <xsl:apply-templates select="$iface/attribute" mode="wrapped"/>
1047 </xsl:when>
1048 <xsl:when test="$pmode='code'">
1049 <xsl:apply-templates select="$iface/attribute" mode="code">
1050 <xsl:with-param name="topclass" select="$topclass"/>
1051 </xsl:apply-templates>
1052 </xsl:when>
1053 <xsl:otherwise/>
1054 </xsl:choose>
1055</xsl:template>
1056
1057<!-- - - - - - - - - - - - - - - - - - - - - - -
1058 emit method
1059 - - - - - - - - - - - - - - - - - - - - - - -->
1060
1061<xsl:template match="method" mode="public">
1062 <xsl:variable name="methodindent">
1063 <xsl:call-template name="tospace">
1064 <xsl:with-param name="str" select="@name"/>
1065 </xsl:call-template>
1066 </xsl:variable>
1067
1068 <xsl:text> STDMETHOD(</xsl:text>
1069 <xsl:call-template name="capitalize">
1070 <xsl:with-param name="str" select="@name"/>
1071 </xsl:call-template>
1072 <xsl:text>)(</xsl:text>
1073 <xsl:for-each select="param">
1074 <xsl:apply-templates select="@type" mode="public">
1075 <xsl:with-param name="dir" select="@dir"/>
1076 </xsl:apply-templates>
1077 <xsl:if test="not(position()=last())">
1078 <xsl:text>,
1079 </xsl:text>
1080 <xsl:value-of select="$methodindent"/>
1081 </xsl:if>
1082 </xsl:for-each>
1083 <xsl:text>);
1084</xsl:text>
1085</xsl:template>
1086
1087<xsl:template match="method" mode="wrapped">
1088 <xsl:variable name="methodindent">
1089 <xsl:call-template name="tospace">
1090 <xsl:with-param name="str" select="@name"/>
1091 </xsl:call-template>
1092 </xsl:variable>
1093
1094 <xsl:text> virtual HRESULT </xsl:text>
1095 <xsl:call-template name="uncapitalize">
1096 <xsl:with-param name="str" select="@name"/>
1097 </xsl:call-template>
1098 <xsl:text>(</xsl:text>
1099 <xsl:variable name="passAutoCaller">
1100 <xsl:call-template name="checkoption">
1101 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1102 <xsl:with-param name="option" select="'passcaller'"/>
1103 </xsl:call-template>
1104 </xsl:variable>
1105 <xsl:if test="$passAutoCaller = 'true'">
1106 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
1107 <xsl:if test="count(param) > 0">
1108 <xsl:text>,
1109 </xsl:text>
1110 <xsl:value-of select="$methodindent"/>
1111 </xsl:if>
1112 </xsl:if>
1113 <xsl:for-each select="param">
1114 <xsl:apply-templates select="@type" mode="wrapped">
1115 <xsl:with-param name="dir" select="@dir"/>
1116 </xsl:apply-templates>
1117 <xsl:if test="not(position()=last())">
1118 <xsl:text>,
1119 </xsl:text>
1120 <xsl:value-of select="$methodindent"/>
1121 </xsl:if>
1122 </xsl:for-each>
1123 <xsl:text>) = 0;
1124</xsl:text>
1125</xsl:template>
1126
1127<xsl:template match="method" mode="code">
1128 <xsl:param name="topclass"/>
1129
1130 <xsl:variable name="methodindent">
1131 <xsl:call-template name="tospace">
1132 <xsl:with-param name="str" select="@name"/>
1133 </xsl:call-template>
1134 </xsl:variable>
1135 <xsl:variable name="methodclassindent">
1136 <xsl:call-template name="tospace">
1137 <xsl:with-param name="str" select="concat($topclass, @name)"/>
1138 </xsl:call-template>
1139 </xsl:variable>
1140 <xsl:variable name="methodbasename">
1141 <xsl:call-template name="capitalize">
1142 <xsl:with-param name="str" select="@name"/>
1143 </xsl:call-template>
1144 </xsl:variable>
1145
1146 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
1147 <xsl:for-each select="param">
1148 <xsl:apply-templates select="@type" mode="public">
1149 <xsl:with-param name="dir" select="@dir"/>
1150 </xsl:apply-templates>
1151 <xsl:if test="not(position()=last())">
1152 <xsl:text>,
1153 </xsl:text>
1154 <xsl:value-of select="$methodclassindent"/>
1155 </xsl:if>
1156 </xsl:for-each>
1157 <xsl:text>)
1158{
1159 LogRelFlow(("{%p} %s:enter</xsl:text>
1160 <xsl:for-each select="param">
1161 <xsl:text> </xsl:text>
1162 <xsl:apply-templates select="@type" mode="logparamtext">
1163 <xsl:with-param name="dir" select="@dir"/>
1164 <xsl:with-param name="isref" select="'yes'"/>
1165 </xsl:apply-templates>
1166 </xsl:for-each>
1167 <xsl:text>\n", this</xsl:text>
1168 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1169 <xsl:for-each select="param">
1170 <xsl:text>, </xsl:text>
1171 <xsl:apply-templates select="@type" mode="logparamval">
1172 <xsl:with-param name="dir" select="@dir"/>
1173 <xsl:with-param name="isref" select="'yes'"/>
1174 </xsl:apply-templates>
1175 </xsl:for-each>
1176 <xsl:text>));
1177
1178 VirtualBoxBase::clearError();
1179
1180 HRESULT hrc;
1181
1182 try
1183 {
1184</xsl:text>
1185 <!-- @todo check in parameters if possible -->
1186 <xsl:for-each select="param">
1187 <xsl:if test="@dir!='in'">
1188 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1189 <xsl:call-template name="capitalize">
1190 <xsl:with-param name="str" select="@name"/>
1191 </xsl:call-template>
1192 <xsl:text>);
1193</xsl:text>
1194 </xsl:if>
1195 </xsl:for-each>
1196 <xsl:text>
1197 AutoCaller autoCaller(this);
1198 if (FAILED(autoCaller.rc()))
1199 throw autoCaller.rc();
1200
1201</xsl:text>
1202 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1203 <xsl:variable name="passAutoCaller">
1204 <xsl:call-template name="checkoption">
1205 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1206 <xsl:with-param name="option" select="'passcaller'"/>
1207 </xsl:call-template>
1208 </xsl:variable>
1209 <xsl:if test="$passAutoCaller = 'true'">
1210 <xsl:text>autoCaller</xsl:text>
1211 <xsl:if test="count(param) > 0">
1212 <xsl:text>,
1213 </xsl:text>
1214 <xsl:value-of select="$methodindent"/>
1215 </xsl:if>
1216 </xsl:if>
1217 <xsl:for-each select="param">
1218 <xsl:apply-templates select="@type" mode="paramvalconversion">
1219 <xsl:with-param name="dir" select="@dir"/>
1220 </xsl:apply-templates>
1221 <xsl:if test="not(position()=last())">
1222 <xsl:text>,
1223 </xsl:text>
1224 <xsl:value-of select="$methodindent"/>
1225 </xsl:if>
1226 </xsl:for-each>
1227 <xsl:text>);
1228 }
1229 catch (HRESULT hrc2)
1230 {
1231 hrc = hrc2;
1232 }
1233 catch (...)
1234 {
1235 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1236 }
1237
1238 LogRelFlow(("{%p} %s: leave</xsl:text>
1239 <xsl:for-each select="param">
1240 <xsl:if test="@dir!='in'">
1241 <xsl:text> </xsl:text>
1242 <xsl:apply-templates select="@type" mode="logparamtext">
1243 <xsl:with-param name="dir" select="@dir"/>
1244 <xsl:with-param name="isref" select="''"/>
1245 </xsl:apply-templates>
1246 </xsl:if>
1247 </xsl:for-each>
1248 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1249 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1250 <xsl:for-each select="param">
1251 <xsl:if test="@dir!='in'">
1252 <xsl:text>, </xsl:text>
1253 <xsl:apply-templates select="@type" mode="logparamval">
1254 <xsl:with-param name="dir" select="@dir"/>
1255 <xsl:with-param name="isref" select="''"/>
1256 </xsl:apply-templates>
1257 </xsl:if>
1258 </xsl:for-each>
1259 <xsl:text>, hrc));
1260 return hrc;
1261}
1262
1263</xsl:text>
1264</xsl:template>
1265
1266<!-- - - - - - - - - - - - - - - - - - - - - - -
1267 emit all methods of an interface
1268 - - - - - - - - - - - - - - - - - - - - - - -->
1269<xsl:template name="emitMethods">
1270 <xsl:param name="iface"/>
1271 <xsl:param name="topclass"/>
1272 <xsl:param name="pmode"/>
1273
1274 <!-- first recurse to emit all base interfaces -->
1275 <xsl:variable name="extends" select="$iface/@extends"/>
1276 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
1277 <xsl:call-template name="emitMethods">
1278 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
1279 <xsl:with-param name="topclass" select="$topclass"/>
1280 <xsl:with-param name="pmode" select="$pmode"/>
1281 </xsl:call-template>
1282 </xsl:if>
1283
1284 <xsl:choose>
1285 <xsl:when test="$pmode='code'">
1286 <xsl:text>//
1287</xsl:text>
1288 <xsl:value-of select="concat('// ', $iface/@name, ' methods')"/>
1289 <xsl:text>
1290//
1291
1292</xsl:text>
1293 </xsl:when>
1294 <xsl:otherwise>
1295 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' methods&#10;')"/>
1296 </xsl:otherwise>
1297 </xsl:choose>
1298 <xsl:choose>
1299 <xsl:when test="$pmode='public'">
1300 <xsl:apply-templates select="$iface/method" mode="public"/>
1301 </xsl:when>
1302 <xsl:when test="$pmode='wrapped'">
1303 <xsl:apply-templates select="$iface/method" mode="wrapped"/>
1304 </xsl:when>
1305 <xsl:when test="$pmode='code'">
1306 <xsl:apply-templates select="$iface/method" mode="code">
1307 <xsl:with-param name="topclass" select="$topclass"/>
1308 </xsl:apply-templates>
1309 </xsl:when>
1310 <xsl:otherwise/>
1311 </xsl:choose>
1312</xsl:template>
1313
1314<!-- - - - - - - - - - - - - - - - - - - - - - -
1315 emit all attributes and methods declarations of an interface
1316 - - - - - - - - - - - - - - - - - - - - - - -->
1317<xsl:template name="emitInterfaceDecls">
1318 <xsl:param name="iface"/>
1319 <xsl:param name="pmode"/>
1320
1321 <!-- attributes -->
1322 <xsl:call-template name="emitAttributes">
1323 <xsl:with-param name="iface" select="$iface"/>
1324 <xsl:with-param name="pmode" select="$pmode"/>
1325 </xsl:call-template>
1326
1327 <!-- methods -->
1328 <xsl:call-template name="emitMethods">
1329 <xsl:with-param name="iface" select="$iface"/>
1330 <xsl:with-param name="pmode" select="$pmode"/>
1331 </xsl:call-template>
1332</xsl:template>
1333
1334<!-- - - - - - - - - - - - - - - - - - - - - - -
1335 emit auxiliary method declarations of an interface
1336 - - - - - - - - - - - - - - - - - - - - - - -->
1337<xsl:template name="emitAuxMethodDecls">
1338 <xsl:param name="iface"/>
1339 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
1340</xsl:template>
1341
1342<!-- - - - - - - - - - - - - - - - - - - - - - -
1343 emit the header file of an interface
1344 - - - - - - - - - - - - - - - - - - - - - - -->
1345<xsl:template name="emitHeader">
1346 <xsl:param name="iface"/>
1347 <xsl:param name="addinterfaces"/>
1348
1349 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
1350
1351 <xsl:choose>
1352 <xsl:when test="$filelistonly=''">
1353 <xsl:apply-templates select="$iface" mode="startfile">
1354 <xsl:with-param name="file" select="$filename"/>
1355 </xsl:apply-templates>
1356 <xsl:call-template name="fileheader">
1357 <xsl:with-param name="name" select="$filename"/>
1358 <xsl:with-param name="class" select="substring(@name, 2)"/>
1359 <xsl:with-param name="type" select="'header'"/>
1360 </xsl:call-template>
1361 <xsl:apply-templates select="$iface" mode="classheader">
1362 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1363 </xsl:apply-templates>
1364
1365 <!-- interface attributes/methods (public) -->
1366 <xsl:call-template name="emitInterfaceDecls">
1367 <xsl:with-param name="iface" select="$iface"/>
1368 <xsl:with-param name="pmode" select="'public'"/>
1369 </xsl:call-template>
1370
1371 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1372 <!-- This is super tricky, as the for-each switches to the node
1373 set, which means the normal document isn't available any
1374 more. So need to use the global root node to get back into
1375 the documemt to find corresponding interface data. -->
1376 <xsl:variable name="addifname">
1377 <xsl:value-of select="string(.)"/>
1378 </xsl:variable>
1379 <xsl:call-template name="emitInterfaceDecls">
1380 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1381 <xsl:with-param name="pmode" select="'public'"/>
1382 </xsl:call-template>
1383 </xsl:for-each>
1384
1385 <!-- auxiliary methods (public) -->
1386 <xsl:call-template name="emitAuxMethodDecls">
1387 <xsl:with-param name="iface" select="$iface"/>
1388 </xsl:call-template>
1389
1390 <!-- switch to private -->
1391 <xsl:text>
1392private:</xsl:text>
1393
1394 <!-- wrapped interface attributes/methods (private) -->
1395 <xsl:call-template name="emitInterfaceDecls">
1396 <xsl:with-param name="iface" select="$iface"/>
1397 <xsl:with-param name="pmode" select="'wrapped'"/>
1398 </xsl:call-template>
1399
1400 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1401 <!-- This is super tricky, as the for-each switches to the node
1402 set, which means the normal document isn't available any
1403 more. So need to use the global root node to get back into
1404 the documemt to find corresponding interface data. -->
1405 <xsl:variable name="addifname">
1406 <xsl:value-of select="string(.)"/>
1407 </xsl:variable>
1408 <xsl:call-template name="emitInterfaceDecls">
1409 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1410 <xsl:with-param name="pmode" select="'wrapped'"/>
1411 </xsl:call-template>
1412 </xsl:for-each>
1413
1414 <xsl:apply-templates select="$iface" mode="classfooter"/>
1415 <xsl:apply-templates select="$iface" mode="endfile">
1416 <xsl:with-param name="file" select="$filename"/>
1417 </xsl:apply-templates>
1418 </xsl:when>
1419 <xsl:otherwise>
1420 <xsl:apply-templates select="$iface" mode="listfile">
1421 <xsl:with-param name="file" select="$filename"/>
1422 </xsl:apply-templates>
1423 </xsl:otherwise>
1424 </xsl:choose>
1425</xsl:template>
1426
1427<!-- - - - - - - - - - - - - - - - - - - - - - -
1428 emit all attributes and methods definitions of an interface
1429 - - - - - - - - - - - - - - - - - - - - - - -->
1430<xsl:template name="emitInterfaceDefs">
1431 <xsl:param name="iface"/>
1432 <xsl:param name="addinterfaces"/>
1433
1434 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', substring($iface/@name, 2), 'Wrap)&#10;&#10;')"/>
1435
1436 <!-- attributes -->
1437 <xsl:call-template name="emitAttributes">
1438 <xsl:with-param name="iface" select="$iface"/>
1439 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1440 <xsl:with-param name="pmode" select="'code'"/>
1441 </xsl:call-template>
1442
1443 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1444 <!-- This is super tricky, as the for-each switches to the node set,
1445 which means the normal document isn't available any more. So need
1446 to use the global root node to get back into the documemt to find
1447 corresponding interface data. -->
1448 <xsl:variable name="addifname">
1449 <xsl:value-of select="string(.)"/>
1450 </xsl:variable>
1451 <xsl:call-template name="emitAttributes">
1452 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1453 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1454 <xsl:with-param name="pmode" select="'code'"/>
1455 </xsl:call-template>
1456 </xsl:for-each>
1457
1458 <!-- methods -->
1459 <xsl:call-template name="emitMethods">
1460 <xsl:with-param name="iface" select="$iface"/>
1461 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1462 <xsl:with-param name="pmode" select="'code'"/>
1463 </xsl:call-template>
1464
1465 <xsl:for-each select="exsl:node-set($addinterfaces)/token">
1466 <!-- This is super tricky, as the for-each switches to the node set,
1467 which means the normal document isn't available any more. So need
1468 to use the global root node to get back into the documemt to find
1469 corresponding interface data. -->
1470 <xsl:variable name="addifname">
1471 <xsl:value-of select="string(.)"/>
1472 </xsl:variable>
1473 <xsl:call-template name="emitMethods">
1474 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
1475 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1476 <xsl:with-param name="pmode" select="'code'"/>
1477 </xsl:call-template>
1478 </xsl:for-each>
1479</xsl:template>
1480
1481<!-- - - - - - - - - - - - - - - - - - - - - - -
1482 emit auxiliary method declarations of an interface
1483 - - - - - - - - - - - - - - - - - - - - - - -->
1484<xsl:template name="emitAuxMethodDefs">
1485 <xsl:param name="iface"/>
1486 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
1487</xsl:template>
1488
1489
1490<!-- - - - - - - - - - - - - - - - - - - - - - -
1491 emit the code file of an interface
1492 - - - - - - - - - - - - - - - - - - - - - - -->
1493<xsl:template name="emitCode">
1494 <xsl:param name="iface"/>
1495 <xsl:param name="addinterfaces"/>
1496
1497 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
1498
1499 <xsl:choose>
1500 <xsl:when test="$filelistonly=''">
1501 <xsl:apply-templates select="$iface" mode="startfile">
1502 <xsl:with-param name="file" select="$filename"/>
1503 </xsl:apply-templates>
1504 <xsl:call-template name="fileheader">
1505 <xsl:with-param name="name" select="$filename"/>
1506 <xsl:with-param name="class" select="substring(@name, 2)"/>
1507 <xsl:with-param name="type" select="'code'"/>
1508 </xsl:call-template>
1509 <xsl:apply-templates select="$iface" mode="codeheader">
1510 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1511 </xsl:apply-templates>
1512
1513 <!-- interface attributes/methods (public) -->
1514 <xsl:call-template name="emitInterfaceDefs">
1515 <xsl:with-param name="iface" select="$iface"/>
1516 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1517 </xsl:call-template>
1518
1519 <!-- auxiliary methods (public) -->
1520 <xsl:call-template name="emitAuxMethodDefs">
1521 <xsl:with-param name="iface" select="$iface"/>
1522 </xsl:call-template>
1523
1524 <xsl:apply-templates select="$iface" mode="codefooter">
1525 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
1526 </xsl:apply-templates>
1527 <xsl:apply-templates select="$iface" mode="endfile">
1528 <xsl:with-param name="file" select="$filename"/>
1529 </xsl:apply-templates>
1530 </xsl:when>
1531 <xsl:otherwise>
1532 <xsl:apply-templates select="$iface" mode="listfile">
1533 <xsl:with-param name="file" select="$filename"/>
1534 </xsl:apply-templates>
1535 </xsl:otherwise>
1536 </xsl:choose>
1537</xsl:template>
1538
1539
1540<!-- - - - - - - - - - - - - - - - - - - - - - -
1541 wildcard match, ignore everything which has no explicit match
1542 - - - - - - - - - - - - - - - - - - - - - - -->
1543
1544<xsl:template match="*"/>
1545
1546<!-- - - - - - - - - - - - - - - - - - - - - - -
1547 ignore all if tags except those for XPIDL or MIDL target
1548 - - - - - - - - - - - - - - - - - - - - - - -->
1549
1550<xsl:template match="if">
1551 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
1552 <xsl:apply-templates/>
1553 </xsl:if>
1554</xsl:template>
1555
1556<!-- - - - - - - - - - - - - - - - - - - - - - -
1557 interface match
1558 - - - - - - - - - - - - - - - - - - - - - - -->
1559
1560<xsl:template match="interface">
1561 <xsl:if test="not(@internal='yes') and not(@supportsErrorInfo='no')">
1562 <xsl:call-template name="emitInterface">
1563 <xsl:with-param name="iface" select="."/>
1564 </xsl:call-template>
1565 </xsl:if>
1566</xsl:template>
1567
1568<!-- - - - - - - - - - - - - - - - - - - - - - -
1569 library match
1570 - - - - - - - - - - - - - - - - - - - - - - -->
1571
1572<xsl:template match="library">
1573 <xsl:apply-templates/>
1574</xsl:template>
1575
1576<!-- - - - - - - - - - - - - - - - - - - - - - -
1577 root match
1578 - - - - - - - - - - - - - - - - - - - - - - -->
1579
1580<xsl:template match="/idl">
1581 <xsl:choose>
1582 <xsl:when test="$filelistonly=''">
1583 </xsl:when>
1584 <xsl:otherwise>
1585 <xsl:value-of select="concat($filelistonly, ' := \&#10;')"/>
1586 </xsl:otherwise>
1587 </xsl:choose>
1588 <xsl:apply-templates/>
1589 <xsl:choose>
1590 <xsl:when test="$filelistonly=''">
1591 </xsl:when>
1592 <xsl:otherwise>
1593 <xsl:text>
1594</xsl:text>
1595 </xsl:otherwise>
1596 </xsl:choose>
1597</xsl:template>
1598
1599</xsl:stylesheet>
1600<!-- 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