VirtualBox

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

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

Main/idl/apiwrap-server: add support for providing hints to the wrapper generation, we'll sporadically need to get at the AutoCaller object so that we can call uninit().

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 48.3 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 apiwrap-server.xsl:
5 XSLT stylesheet that generates C++ API wrappers (server side) from
6 VirtualBox.xidl.
7
8 Copyright (C) 2010-2013 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:include href="typemap-shared.inc.xsl"/>
36
37<!-- - - - - - - - - - - - - - - - - - - - - - -
38templates for file separation
39 - - - - - - - - - - - - - - - - - - - - - - -->
40
41<xsl:template match="interface" mode="listfile">
42 <xsl:param name="file"/>
43
44 <xsl:value-of select="concat('&#9;', $file, ' \&#10;')"/>
45</xsl:template>
46
47<xsl:template match="interface" mode="startfile">
48 <xsl:param name="file"/>
49
50 <xsl:value-of select="concat('&#10;// ##### BEGINFILE &quot;', $file, '&quot;&#10;')"/>
51</xsl:template>
52
53<xsl:template match="interface" mode="endfile">
54 <xsl:param name="file"/>
55
56 <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;')"/>
57</xsl:template>
58
59<!-- - - - - - - - - - - - - - - - - - - - - - -
60templates for file headers/footers
61 - - - - - - - - - - - - - - - - - - - - - - -->
62
63<xsl:template name="fileheader">
64 <xsl:param name="class"/>
65 <xsl:param name="name"/>
66 <xsl:param name="type"/>
67
68 <xsl:text>/** @file
69 *
70</xsl:text>
71 <xsl:value-of select="concat(' * VirtualBox API class wrapper ', $type, ' for I', $class, '.')"/>
72 <xsl:text>
73 *
74 * DO NOT EDIT! This is a generated file.
75 * Generated from: src/VBox/Main/idl/VirtualBox.xidl
76 * Generator: src/VBox/Main/idl/apiwrap-server.xsl
77 */
78
79/**
80 * Copyright (C) 2011-2013 Oracle Corporation
81 *
82 * This file is part of VirtualBox Open Source Edition (OSE), as
83 * available from http://www.virtualbox.org. This file is free software;
84 * you can redistribute it and/or modify it under the terms of the GNU
85 * General Public License (GPL) as published by the Free Software
86 * Foundation, in version 2 as it comes in the "COPYING" file of the
87 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
88 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
89 */
90
91</xsl:text>
92</xsl:template>
93
94<xsl:template name="emitCOMInterfaces">
95 <xsl:param name="iface"/>
96
97 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $iface/@name, ')&#10;')"/>
98 <!-- now recurse to emit all base interfaces -->
99 <xsl:variable name="extends" select="$iface/@extends"/>
100 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$dispatched') and not($extends='$errorinfo')">
101 <xsl:call-template name="emitCOMInterfaces">
102 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
103 </xsl:call-template>
104 </xsl:if>
105</xsl:template>
106
107<xsl:template match="interface" mode="classheader">
108 <xsl:value-of select="concat('#ifndef ', substring(@name, 2), 'Wrap_H_&#10;')"/>
109 <xsl:value-of select="concat('#define ', substring(@name, 2), 'Wrap_H_')"/>
110 <xsl:text>
111
112#include "VirtualBoxBase.h"
113#include "Wrapper.h"
114
115</xsl:text>
116 <xsl:value-of select="concat('class ATL_NO_VTABLE ', substring(@name, 2), 'Wrap:')"/>
117 <xsl:text>
118 public VirtualBoxBase,
119</xsl:text>
120 <xsl:value-of select="concat(' VBOX_SCRIPTABLE_IMPL(', @name, ')&#10;')"/>
121 <xsl:text>{
122 Q_OBJECT
123
124public:
125</xsl:text>
126 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', substring(@name, 2), 'Wrap, ', @name, ')&#10;')"/>
127 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', substring(@name, 2), 'Wrap)&#10;')"/>
128 <xsl:text> DECLARE_PROTECT_FINAL_CONSTRUCT()
129
130</xsl:text>
131 <xsl:value-of select="concat(' BEGIN_COM_MAP(', substring(@name, 2), 'Wrap)&#10;')"/>
132 <xsl:text> COM_INTERFACE_ENTRY(ISupportErrorInfo)
133</xsl:text>
134 <xsl:call-template name="emitCOMInterfaces">
135 <xsl:with-param name="iface" select="."/>
136 </xsl:call-template>
137 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')&#10;')"/>
138 <xsl:text> END_COM_MAP()
139
140</xsl:text>
141 <xsl:value-of select="concat(' DECLARE_EMPTY_CTOR_DTOR(', substring(@name, 2), 'Wrap)&#10;')"/>
142</xsl:template>
143
144<xsl:template match="interface" mode="classfooter">
145 <xsl:text>};
146
147</xsl:text>
148 <xsl:value-of select="concat('#endif // !', substring(@name, 2), 'Wrap_H_&#10;')"/>
149</xsl:template>
150
151<xsl:template match="interface" mode="codeheader">
152 <xsl:value-of select="concat('#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_MAIN_', translate(substring(@name, 2), $G_lowerCase, $G_upperCase), '&#10;&#10;')"/>
153 <xsl:value-of select="concat('#include &quot;', substring(@name, 2), 'Wrap.h&quot;&#10;')"/>
154 <xsl:text>#include "Logging.h"
155
156</xsl:text>
157</xsl:template>
158
159<xsl:template match="interface" mode="codefooter">
160 <xsl:text>#ifdef VBOX_WITH_XPCOM
161</xsl:text>
162 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', substring(@name, 2), 'Wrap)&#10;NS_IMPL_THREADSAFE_ISUPPORTS1_CI(', substring(@name, 2), 'Wrap, ', @name, ')&#10;')"/>
163 <xsl:text>#endif // VBOX_WITH_XPCOM
164</xsl:text>
165</xsl:template>
166
167
168<!-- - - - - - - - - - - - - - - - - - - - - - -
169 templates for dealing with names and parameters
170 - - - - - - - - - - - - - - - - - - - - - - -->
171
172<xsl:template name="tospace">
173 <xsl:param name="str"/>
174 <xsl:value-of select="translate($str, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_', ' ')"/>
175</xsl:template>
176
177<xsl:template name="checkoption">
178 <xsl:param name="optionlist"/>
179 <xsl:param name="option"/>
180 <xsl:value-of select="string-length($option) > 0 and contains(concat(',', translate($optionlist, ' ', ''), ','), concat(',', $option, ','))"/>
181</xsl:template>
182
183<xsl:template name="translatepublictype">
184 <xsl:param name="type"/>
185 <xsl:param name="dir"/>
186
187 <!-- get C++ glue type from IDL type from table in typemap-shared.inc.xsl -->
188 <xsl:variable name="gluetypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
189 <xsl:choose>
190 <xsl:when test="$type='wstring' or $type='uuid'">
191 <xsl:choose>
192 <xsl:when test="$dir='in'">
193 <xsl:text>IN_BSTR</xsl:text>
194 </xsl:when>
195 <xsl:otherwise>
196 <xsl:text>BSTR</xsl:text>
197 </xsl:otherwise>
198 </xsl:choose>
199 </xsl:when>
200 <xsl:when test="string-length($gluetypefield)">
201 <xsl:value-of select="$gluetypefield"/>
202 </xsl:when>
203 <xsl:when test="//enum[@name=$type]">
204 <xsl:value-of select="concat($type, '_T')"/>
205 </xsl:when>
206 <xsl:when test="$type='$unknown'">
207 <xsl:text>IUnknown *</xsl:text>
208 </xsl:when>
209 <xsl:when test="//interface[@name=$type]">
210 <xsl:variable name="thatif" select="//interface[@name=$type]"/>
211 <xsl:variable name="thatifname" select="$thatif/@name"/>
212 <xsl:value-of select="concat($thatifname, ' *')"/>
213 </xsl:when>
214 <xsl:otherwise>
215 <xsl:call-template name="fatalError">
216 <xsl:with-param name="msg" select="concat('translatepublictype: Type &quot;', $type, '&quot; is not supported.')"/>
217 </xsl:call-template>
218 </xsl:otherwise>
219 </xsl:choose>
220</xsl:template>
221
222<xsl:template name="translatewrappedtype">
223 <xsl:param name="type"/>
224 <xsl:param name="dir"/>
225 <xsl:param name="safearray"/>
226
227 <!-- get C++ wrap type from IDL type from table in typemap-shared.inc.xsl -->
228 <xsl:variable name="wraptypefield" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluename"/>
229 <xsl:choose>
230 <xsl:when test="$type='wstring'">
231 <xsl:if test="$dir='in' and not($safearray='yes')">
232 <xsl:text>const </xsl:text>
233 </xsl:if>
234 <xsl:text>com::Utf8Str &amp;</xsl:text>
235 </xsl:when>
236 <xsl:when test="$type='uuid'">
237 <xsl:if test="$dir='in'">
238 <xsl:text>const </xsl:text>
239 </xsl:if>
240 <xsl:text>com::Guid &amp;</xsl:text>
241 </xsl:when>
242 <xsl:when test="string-length($wraptypefield)">
243 <xsl:value-of select="$wraptypefield"/>
244 </xsl:when>
245 <xsl:when test="//enum[@name=$type]">
246 <xsl:value-of select="concat($type, '_T')"/>
247 </xsl:when>
248 <xsl:when test="$type='$unknown'">
249 <xsl:if test="$dir='in' and not($safearray='yes')">
250 <xsl:text>const </xsl:text>
251 </xsl:if>
252 <xsl:text>ComPtr&lt;IUnknown&gt; &amp;</xsl:text>
253 </xsl:when>
254 <xsl:when test="//interface[@name=$type]">
255 <xsl:variable name="thatif" select="//interface[@name=$type]"/>
256 <xsl:variable name="thatifname" select="$thatif/@name"/>
257 <xsl:if test="$dir='in' and not($safearray='yes')">
258 <xsl:text>const </xsl:text>
259 </xsl:if>
260 <xsl:value-of select="concat('ComPtr&lt;', $thatifname, '&gt; &amp;')"/>
261 </xsl:when>
262 <xsl:otherwise>
263 <xsl:call-template name="fatalError">
264 <xsl:with-param name="msg" select="concat('translatewrappedtype: Type &quot;', $type, '&quot; is not supported.')"/>
265 </xsl:call-template>
266 </xsl:otherwise>
267 </xsl:choose>
268</xsl:template>
269
270<xsl:template name="translatefmtspectype">
271 <xsl:param name="type"/>
272 <xsl:param name="dir"/>
273 <xsl:param name="safearray"/>
274 <xsl:param name="mod"/>
275
276 <!-- get C format string for IDL type from table in typemap-shared.inc.xsl -->
277 <xsl:variable name="wrapfmt" select="exsl:node-set($G_aSharedTypes)/type[@idlname=$type]/@gluefmt"/>
278 <xsl:choose>
279 <xsl:when test="$mod='ref' and $dir!='in'">
280 <xsl:text>%p</xsl:text>
281 </xsl:when>
282 <xsl:when test="$safearray='yes'">
283 <xsl:text>%zu</xsl:text>
284 </xsl:when>
285 <xsl:when test="string-length($wrapfmt)">
286 <xsl:value-of select="$wrapfmt"/>
287 </xsl:when>
288 <xsl:when test="//enum[@name=$type]">
289 <xsl:text>%RU32</xsl:text>
290 </xsl:when>
291 <xsl:when test="$type='$unknown'">
292 <xsl:text>%p</xsl:text>
293 </xsl:when>
294 <xsl:when test="//interface[@name=$type]">
295 <xsl:text>%p</xsl:text>
296 </xsl:when>
297 <xsl:otherwise>
298 <xsl:call-template name="fatalError">
299 <xsl:with-param name="msg" select="concat('translatefmtcpectype: Type &quot;', $type, '&quot; is not supported.')"/>
300 </xsl:call-template>
301 </xsl:otherwise>
302 </xsl:choose>
303</xsl:template>
304
305<xsl:template match="attribute/@type | param/@type" mode="public">
306 <xsl:param name="dir"/>
307
308 <xsl:variable name="gluetype">
309 <xsl:call-template name="translatepublictype">
310 <xsl:with-param name="type" select="."/>
311 <xsl:with-param name="dir" select="$dir"/>
312 </xsl:call-template>
313 </xsl:variable>
314
315 <xsl:if test="../@safearray='yes'">
316 <xsl:choose>
317 <xsl:when test="$dir='in'">
318 <xsl:text>ComSafeArrayIn(</xsl:text>
319 </xsl:when>
320 <xsl:otherwise>
321 <xsl:text>ComSafeArrayOut(</xsl:text>
322 </xsl:otherwise>
323 </xsl:choose>
324 </xsl:if>
325 <xsl:value-of select="$gluetype"/>
326 <xsl:choose>
327 <xsl:when test="../@safearray='yes'">
328 <xsl:text>, </xsl:text>
329 </xsl:when>
330 <xsl:otherwise>
331 <xsl:if test="substring($gluetype,string-length($gluetype))!='*'">
332 <xsl:text> </xsl:text>
333 </xsl:if>
334 <xsl:choose>
335 <xsl:when test="$dir='in'">
336 </xsl:when>
337 <xsl:otherwise>
338 <xsl:value-of select="'*'"/>
339 </xsl:otherwise>
340 </xsl:choose>
341 </xsl:otherwise>
342 </xsl:choose>
343 <xsl:text>a</xsl:text>
344 <xsl:call-template name="capitalize">
345 <xsl:with-param name="str" select="../@name"/>
346 </xsl:call-template>
347 <xsl:if test="../@safearray='yes'">
348 <xsl:value-of select="')'"/>
349 </xsl:if>
350</xsl:template>
351
352<xsl:template match="attribute/@type | param/@type" mode="wrapped">
353 <xsl:param name="dir"/>
354
355 <xsl:variable name="wraptype">
356 <xsl:call-template name="translatewrappedtype">
357 <xsl:with-param name="type" select="."/>
358 <xsl:with-param name="dir" select="$dir"/>
359 <xsl:with-param name="safearray" select="../@safearray"/>
360 </xsl:call-template>
361 </xsl:variable>
362
363 <xsl:choose>
364 <xsl:when test="../@safearray='yes'">
365 <xsl:if test="$dir='in'">
366 <xsl:text>const </xsl:text>
367 </xsl:if>
368 <xsl:text>std::vector&lt;</xsl:text>
369 <xsl:choose>
370 <xsl:when test="substring($wraptype,string-length($wraptype))='&amp;'">
371 <xsl:variable name="wraptype2">
372 <xsl:value-of select="substring($wraptype,1,string-length($wraptype)-2)"/>
373 </xsl:variable>
374
375 <xsl:choose>
376 <xsl:when test="substring($wraptype2,string-length($wraptype2))='&gt;'">
377 <xsl:value-of select="concat($wraptype2, ' ')"/>
378 </xsl:when>
379 <xsl:otherwise>
380 <xsl:value-of select="$wraptype2"/>
381 </xsl:otherwise>
382 </xsl:choose>
383 </xsl:when>
384 <xsl:when test="substring($wraptype,string-length($wraptype))='&gt;'">
385 <xsl:value-of select="concat($wraptype, ' ')"/>
386 </xsl:when>
387 <xsl:otherwise>
388 <xsl:value-of select="$wraptype"/>
389 </xsl:otherwise>
390 </xsl:choose>
391 <xsl:text>&gt; &amp;</xsl:text>
392 </xsl:when>
393 <xsl:otherwise>
394 <xsl:value-of select="$wraptype"/>
395 <xsl:if test="substring($wraptype,string-length($wraptype))!='&amp;'">
396 <xsl:if test="substring($wraptype,string-length($wraptype))!='*'">
397 <xsl:text> </xsl:text>
398 </xsl:if>
399 <xsl:choose>
400 <xsl:when test="$dir='in'">
401 </xsl:when>
402 <xsl:otherwise>
403 <xsl:value-of select="'*'"/>
404 </xsl:otherwise>
405 </xsl:choose>
406 </xsl:if>
407 </xsl:otherwise>
408 </xsl:choose>
409 <xsl:text>a</xsl:text>
410 <xsl:call-template name="capitalize">
411 <xsl:with-param name="str" select="../@name"/>
412 </xsl:call-template>
413</xsl:template>
414
415<xsl:template match="attribute/@type | param/@type" mode="logparamtext">
416 <xsl:param name="dir"/>
417 <xsl:param name="mod"/>
418
419 <xsl:if test="$mod!='ref' and ($dir='out' or $dir='ret')">
420 <xsl:text>*</xsl:text>
421 </xsl:if>
422 <xsl:text>a</xsl:text>
423 <xsl:call-template name="capitalize">
424 <xsl:with-param name="str" select="../@name"/>
425 </xsl:call-template>
426 <xsl:text>=</xsl:text>
427 <xsl:call-template name="translatefmtspectype">
428 <xsl:with-param name="type" select="."/>
429 <xsl:with-param name="dir" select="$dir"/>
430 <xsl:with-param name="safearray" select="../@safearray"/>
431 <xsl:with-param name="mod" select="$mod"/>
432 </xsl:call-template>
433</xsl:template>
434
435<xsl:template match="attribute/@type | param/@type" mode="logparamval">
436 <xsl:param name="dir"/>
437 <xsl:param name="mod"/>
438
439 <xsl:choose>
440 <xsl:when test="../@safearray='yes' and $mod!='ref'">
441 <xsl:text>ComSafeArraySize(</xsl:text>
442 <xsl:if test="$mod!='ref' and $dir!='in'">
443 <xsl:text>*</xsl:text>
444 </xsl:if>
445 </xsl:when>
446 <xsl:when test="$mod!='ref' and $dir!='in'">
447 <xsl:text>*</xsl:text>
448 </xsl:when>
449 </xsl:choose>
450 <xsl:text>a</xsl:text>
451 <xsl:call-template name="capitalize">
452 <xsl:with-param name="str" select="../@name"/>
453 </xsl:call-template>
454 <xsl:choose>
455 <xsl:when test="../@safearray='yes' and $mod!='ref'">
456 <xsl:text>)</xsl:text>
457 </xsl:when>
458 </xsl:choose>
459</xsl:template>
460
461<xsl:template match="attribute/@type | param/@type" mode="paramvalconversion">
462 <xsl:param name="dir"/>
463
464 <xsl:variable name="gluetype">
465 <xsl:call-template name="translatepublictype">
466 <xsl:with-param name="type" select="."/>
467 <xsl:with-param name="dir" select="$dir"/>
468 </xsl:call-template>
469 </xsl:variable>
470 <xsl:variable name="type" select="."/>
471 <xsl:variable name="thatif" select="../../../..//interface[@name=$type]"/>
472 <xsl:choose>
473 <xsl:when test="$type='$unknown'">
474 <xsl:if test="../@safearray='yes'">
475 <xsl:text>Array</xsl:text>
476 </xsl:if>
477 <xsl:choose>
478 <xsl:when test="$dir='in'">
479 <xsl:text>ComTypeInConverter&lt;IUnknown&gt;(</xsl:text>
480 </xsl:when>
481 <xsl:otherwise>
482 <xsl:text>ComTypeOutConverter&lt;IUnknown&gt;(</xsl:text>
483 </xsl:otherwise>
484 </xsl:choose>
485 <xsl:if test="../@safearray='yes'">
486 <xsl:choose>
487 <xsl:when test="$dir='in'">
488 <xsl:text>ComSafeArrayInArg(</xsl:text>
489 </xsl:when>
490 <xsl:otherwise>
491 <xsl:text>ComSafeArrayOutArg(</xsl:text>
492 </xsl:otherwise>
493 </xsl:choose>
494 </xsl:if>
495 </xsl:when>
496 <xsl:when test="$thatif">
497 <xsl:if test="../@safearray='yes'">
498 <xsl:text>Array</xsl:text>
499 </xsl:if>
500 <xsl:variable name="thatifname" select="$thatif/@name"/>
501 <xsl:choose>
502 <xsl:when test="$dir='in'">
503 <xsl:text>ComTypeInConverter</xsl:text>
504 </xsl:when>
505 <xsl:otherwise>
506 <xsl:text>ComTypeOutConverter</xsl:text>
507 </xsl:otherwise>
508 </xsl:choose>
509 <xsl:value-of select="concat('&lt;', $thatifname, '&gt;(')"/>
510 <xsl:if test="../@safearray='yes'">
511 <xsl:choose>
512 <xsl:when test="$dir='in'">
513 <xsl:text>ComSafeArrayInArg(</xsl:text>
514 </xsl:when>
515 <xsl:otherwise>
516 <xsl:text>ComSafeArrayOutArg(</xsl:text>
517 </xsl:otherwise>
518 </xsl:choose>
519 </xsl:if>
520 </xsl:when>
521 <xsl:when test="$type='wstring'">
522 <xsl:if test="../@safearray='yes'">
523 <xsl:text>Array</xsl:text>
524 </xsl:if>
525 <xsl:choose>
526 <xsl:when test="$dir='in'">
527 <xsl:text>BSTRInConverter(</xsl:text>
528 </xsl:when>
529 <xsl:otherwise>
530 <xsl:text>BSTROutConverter(</xsl:text>
531 </xsl:otherwise>
532 </xsl:choose>
533 <xsl:if test="../@safearray='yes'">
534 <xsl:choose>
535 <xsl:when test="$dir='in'">
536 <xsl:text>ComSafeArrayInArg(</xsl:text>
537 </xsl:when>
538 <xsl:otherwise>
539 <xsl:text>ComSafeArrayOutArg(</xsl:text>
540 </xsl:otherwise>
541 </xsl:choose>
542 </xsl:if>
543 </xsl:when>
544 <xsl:when test="$type='uuid'">
545 <xsl:if test="../@safearray='yes'">
546 <xsl:text>Array</xsl:text>
547 </xsl:if>
548 <xsl:choose>
549 <xsl:when test="$dir='in'">
550 <xsl:text>UuidInConverter(</xsl:text>
551 </xsl:when>
552 <xsl:otherwise>
553 <xsl:text>UuidOutConverter(</xsl:text>
554 </xsl:otherwise>
555 </xsl:choose>
556 <xsl:if test="../@safearray='yes'">
557 <xsl:choose>
558 <xsl:when test="$dir='in'">
559 <xsl:text>ComSafeArrayInArg(</xsl:text>
560 </xsl:when>
561 <xsl:otherwise>
562 <xsl:text>ComSafeArrayOutArg(</xsl:text>
563 </xsl:otherwise>
564 </xsl:choose>
565 </xsl:if>
566 </xsl:when>
567 <xsl:otherwise>
568 <xsl:if test="../@safearray='yes'">
569 <xsl:text>Array</xsl:text>
570 <xsl:choose>
571 <xsl:when test="$dir='in'">
572 <xsl:text>InConverter</xsl:text>
573 </xsl:when>
574 <xsl:otherwise>
575 <xsl:text>OutConverter</xsl:text>
576 </xsl:otherwise>
577 </xsl:choose>
578 <xsl:value-of select="concat('&lt;', $gluetype, '&gt;(')"/>
579 <xsl:choose>
580 <xsl:when test="$dir='in'">
581 <xsl:text>ComSafeArrayInArg(</xsl:text>
582 </xsl:when>
583 <xsl:otherwise>
584 <xsl:text>ComSafeArrayOutArg(</xsl:text>
585 </xsl:otherwise>
586 </xsl:choose>
587 </xsl:if>
588 </xsl:otherwise>
589 </xsl:choose>
590 <xsl:text>a</xsl:text>
591 <xsl:call-template name="capitalize">
592 <xsl:with-param name="str" select="../@name"/>
593 </xsl:call-template>
594 <xsl:choose>
595 <xsl:when test="$type='$unknown' or $thatif">
596 <xsl:choose>
597 <xsl:when test="../@safearray='yes'">
598 <xsl:text>)).array()</xsl:text>
599 </xsl:when>
600 <xsl:otherwise>
601 <xsl:text>).ptr()</xsl:text>
602 </xsl:otherwise>
603 </xsl:choose>
604 </xsl:when>
605 <xsl:when test="$type='wstring'">
606 <xsl:choose>
607 <xsl:when test="../@safearray='yes'">
608 <xsl:text>)).array()</xsl:text>
609 </xsl:when>
610 <xsl:otherwise>
611 <xsl:text>).str()</xsl:text>
612 </xsl:otherwise>
613 </xsl:choose>
614 </xsl:when>
615 <xsl:when test="$type='uuid'">
616 <xsl:choose>
617 <xsl:when test="../@safearray='yes'">
618 <xsl:text>)).array()</xsl:text>
619 </xsl:when>
620 <xsl:otherwise>
621 <xsl:text>).uuid()</xsl:text>
622 </xsl:otherwise>
623 </xsl:choose>
624 </xsl:when>
625 <xsl:otherwise>
626 <xsl:if test="../@safearray='yes'">
627 <xsl:text>)).array()</xsl:text>
628 </xsl:if>
629 </xsl:otherwise>
630 </xsl:choose>
631</xsl:template>
632
633<!-- - - - - - - - - - - - - - - - - - - - - - -
634 emit attribute
635 - - - - - - - - - - - - - - - - - - - - - - -->
636
637<xsl:template match="attribute" mode="public">
638 <xsl:variable name="attrbasename">
639 <xsl:call-template name="capitalize">
640 <xsl:with-param name="str" select="@name"/>
641 </xsl:call-template>
642 </xsl:variable>
643
644 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $attrbasename, '))(')"/>
645 <xsl:apply-templates select="@type" mode="public">
646 <xsl:with-param name="dir" select="'out'"/>
647 </xsl:apply-templates>
648 <xsl:text>);
649</xsl:text>
650
651 <xsl:if test="not(@readonly) or @readonly!='yes'">
652 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $attrbasename, '))(')"/>
653 <xsl:apply-templates select="@type" mode="public">
654 <xsl:with-param name="dir" select="'in'"/>
655 </xsl:apply-templates>
656 <xsl:text>);
657</xsl:text>
658 </xsl:if>
659</xsl:template>
660
661<xsl:template match="attribute" mode="wrapped">
662 <xsl:variable name="attrbasename">
663 <xsl:call-template name="capitalize">
664 <xsl:with-param name="str" select="@name"/>
665 </xsl:call-template>
666 </xsl:variable>
667
668 <xsl:value-of select="concat(' virtual HRESULT get', $attrbasename, '(')"/>
669 <xsl:variable name="passAutoCaller">
670 <xsl:call-template name="checkoption">
671 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
672 <xsl:with-param name="option" select="'passcaller'"/>
673 </xsl:call-template>
674 </xsl:variable>
675 <xsl:if test="$passAutoCaller = 'true'">
676 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
677 </xsl:if>
678 <xsl:apply-templates select="@type" mode="wrapped">
679 <xsl:with-param name="dir" select="'out'"/>
680 </xsl:apply-templates>
681 <xsl:text>) = 0;
682</xsl:text>
683
684 <xsl:if test="not(@readonly) or @readonly!='yes'">
685 <xsl:value-of select="concat(' virtual HRESULT set', $attrbasename, '(')"/>
686 <xsl:if test="$passAutoCaller = 'true'">
687 <xsl:text>AutoCaller &amp;aAutoCaller, </xsl:text>
688 </xsl:if>
689 <xsl:apply-templates select="@type" mode="wrapped">
690 <xsl:with-param name="dir" select="'in'"/>
691 </xsl:apply-templates>
692 <xsl:text>) = 0;
693</xsl:text>
694 </xsl:if>
695</xsl:template>
696
697<xsl:template match="attribute" mode="code">
698 <xsl:param name="topclass"/>
699
700 <xsl:variable name="attrbasename">
701 <xsl:call-template name="capitalize">
702 <xsl:with-param name="str" select="@name"/>
703 </xsl:call-template>
704 </xsl:variable>
705
706 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMGETTER(', $attrbasename, ')(')"/>
707 <xsl:apply-templates select="@type" mode="public">
708 <xsl:with-param name="dir" select="'out'"/>
709 </xsl:apply-templates>
710 <xsl:text>)
711{
712 LogRelFlow(("{%p} %s: enter </xsl:text>
713 <xsl:apply-templates select="@type" mode="logparamtext">
714 <xsl:with-param name="dir" select="'out'"/>
715 <xsl:with-param name="mod" select="'ref'"/>
716 </xsl:apply-templates>
717 <xsl:text>\n", this, </xsl:text>
718 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
719 <xsl:apply-templates select="@type" mode="logparamval">
720 <xsl:with-param name="dir" select="'out'"/>
721 <xsl:with-param name="mod" select="'ref'"/>
722 </xsl:apply-templates>
723 <xsl:text>));
724
725 VirtualBoxBase::clearError();
726
727 HRESULT hrc;
728
729 try
730 {
731 CheckComArgOutPointerValidThrow(a</xsl:text>
732 <xsl:value-of select="$attrbasename"/>
733 <xsl:text>);
734
735 AutoCaller autoCaller(this);
736 if (FAILED(autoCaller.rc()))
737 throw autoCaller.rc();
738
739</xsl:text>
740 <xsl:value-of select="concat(' hrc = get', $attrbasename, '(')"/>
741 <xsl:variable name="passAutoCaller">
742 <xsl:call-template name="checkoption">
743 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
744 <xsl:with-param name="option" select="'passcaller'"/>
745 </xsl:call-template>
746 </xsl:variable>
747 <xsl:if test="$passAutoCaller = 'true'">
748 <xsl:text>autoCaller, </xsl:text>
749 </xsl:if>
750 <xsl:apply-templates select="@type" mode="paramvalconversion">
751 <xsl:with-param name="dir" select="'out'"/>
752 </xsl:apply-templates>
753 <xsl:text>);
754 }
755 catch (HRESULT hrc2)
756 {
757 hrc = hrc2;
758 }
759 catch (...)
760 {
761 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
762 }
763
764 LogRelFlow(("{%p} %s: leave </xsl:text>
765 <xsl:apply-templates select="@type" mode="logparamtext">
766 <xsl:with-param name="dir" select="'out'"/>
767 </xsl:apply-templates>
768 <xsl:text> hrc=%Rhrc\n", this, </xsl:text>
769 <xsl:value-of select="concat('&quot;', $topclass, '::get', $attrbasename, '&quot;, ')"/>
770 <xsl:apply-templates select="@type" mode="logparamval">
771 <xsl:with-param name="dir" select="'out'"/>
772 </xsl:apply-templates>
773 <xsl:text>, hrc));
774 return hrc;
775}
776
777</xsl:text>
778 <xsl:if test="not(@readonly) or @readonly!='yes'">
779 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::COMSETTER(', $attrbasename, ')(')"/>
780 <xsl:apply-templates select="@type" mode="public">
781 <xsl:with-param name="dir" select="'in'"/>
782 </xsl:apply-templates>
783 <!-- @todo check in parameters if possible -->
784 <xsl:text>)
785{
786 LogRelFlow(("{%p} %s: enter </xsl:text>
787 <xsl:apply-templates select="@type" mode="logparamtext">
788 <xsl:with-param name="dir" select="'in'"/>
789 </xsl:apply-templates>
790 <xsl:text>\n", this, </xsl:text>
791 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
792 <xsl:apply-templates select="@type" mode="logparamval">
793 <xsl:with-param name="dir" select="'in'"/>
794 </xsl:apply-templates>
795 <xsl:text>));
796
797 VirtualBoxBase::clearError();
798
799 HRESULT hrc;
800
801 try
802 {
803 AutoCaller autoCaller(this);
804 if (FAILED(autoCaller.rc()))
805 throw autoCaller.rc();
806
807</xsl:text>
808 <xsl:value-of select="concat(' hrc = set', $attrbasename, '(')"/>
809 <xsl:if test="$passAutoCaller = 'true'">
810 <xsl:text>autoCaller, </xsl:text>
811 </xsl:if>
812 <xsl:apply-templates select="@type" mode="paramvalconversion">
813 <xsl:with-param name="dir" select="'in'"/>
814 </xsl:apply-templates>
815 <xsl:text>);
816 }
817 catch (HRESULT hrc2)
818 {
819 hrc = hrc2;
820 }
821 catch (...)
822 {
823 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
824 }
825
826 LogRelFlow(("{%p} %s: leave hrc=%Rhrc\n", this, </xsl:text>
827 <xsl:value-of select="concat('&quot;', $topclass, '::set', $attrbasename, '&quot;, ')"/>
828 <xsl:text>hrc));
829 return hrc;
830}
831
832</xsl:text>
833 </xsl:if>
834</xsl:template>
835
836<!-- - - - - - - - - - - - - - - - - - - - - - -
837 emit all attributes of an interface
838 - - - - - - - - - - - - - - - - - - - - - - -->
839<xsl:template name="emitAttributes">
840 <xsl:param name="iface"/>
841 <xsl:param name="topclass"/>
842 <xsl:param name="pmode"/>
843
844 <!-- first recurse to emit all base interfaces -->
845 <xsl:variable name="extends" select="$iface/@extends"/>
846 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$dispatched') and not($extends='$errorinfo')">
847 <xsl:call-template name="emitAttributes">
848 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
849 <xsl:with-param name="topclass" select="$topclass"/>
850 <xsl:with-param name="pmode" select="$pmode"/>
851 </xsl:call-template>
852 </xsl:if>
853
854 <xsl:choose>
855 <xsl:when test="$pmode='code'">
856 <xsl:text>//
857</xsl:text>
858 <xsl:value-of select="concat('// ', $iface/@name, ' properties')"/>
859 <xsl:text>
860//
861
862</xsl:text>
863 </xsl:when>
864 <xsl:otherwise>
865 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' properties&#10;')"/>
866 </xsl:otherwise>
867 </xsl:choose>
868 <xsl:choose>
869 <xsl:when test="$pmode='public'">
870 <xsl:apply-templates select="$iface/attribute" mode="public"/>
871 </xsl:when>
872 <xsl:when test="$pmode='wrapped'">
873 <xsl:apply-templates select="$iface/attribute" mode="wrapped"/>
874 </xsl:when>
875 <xsl:when test="$pmode='code'">
876 <xsl:apply-templates select="$iface/attribute" mode="code">
877 <xsl:with-param name="topclass" select="$topclass"/>
878 </xsl:apply-templates>
879 </xsl:when>
880 <xsl:otherwise/>
881 </xsl:choose>
882</xsl:template>
883
884<!-- - - - - - - - - - - - - - - - - - - - - - -
885 emit method
886 - - - - - - - - - - - - - - - - - - - - - - -->
887
888<xsl:template match="method" mode="public">
889 <xsl:variable name="methodindent">
890 <xsl:call-template name="tospace">
891 <xsl:with-param name="str" select="@name"/>
892 </xsl:call-template>
893 </xsl:variable>
894
895 <xsl:text> STDMETHOD(</xsl:text>
896 <xsl:call-template name="capitalize">
897 <xsl:with-param name="str" select="@name"/>
898 </xsl:call-template>
899 <xsl:text>)(</xsl:text>
900 <xsl:for-each select="param">
901 <xsl:apply-templates select="@type" mode="public">
902 <xsl:with-param name="dir" select="@dir"/>
903 </xsl:apply-templates>
904 <xsl:if test="not(position()=last())">
905 <xsl:text>,
906 </xsl:text>
907 <xsl:value-of select="$methodindent"/>
908 </xsl:if>
909 </xsl:for-each>
910 <xsl:text>);
911</xsl:text>
912</xsl:template>
913
914<xsl:template match="method" mode="wrapped">
915 <xsl:variable name="methodindent">
916 <xsl:call-template name="tospace">
917 <xsl:with-param name="str" select="@name"/>
918 </xsl:call-template>
919 </xsl:variable>
920
921 <xsl:text> virtual HRESULT </xsl:text>
922 <xsl:call-template name="uncapitalize">
923 <xsl:with-param name="str" select="@name"/>
924 </xsl:call-template>
925 <xsl:text>(</xsl:text>
926 <xsl:variable name="passAutoCaller">
927 <xsl:call-template name="checkoption">
928 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
929 <xsl:with-param name="option" select="'passcaller'"/>
930 </xsl:call-template>
931 </xsl:variable>
932 <xsl:if test="$passAutoCaller = 'true'">
933 <xsl:text>AutoCaller &amp;aAutoCaller</xsl:text>
934 <xsl:if test="count(param) > 0">
935 <xsl:text>,
936 </xsl:text>
937 <xsl:value-of select="$methodindent"/>
938 </xsl:if>
939 </xsl:if>
940 <xsl:for-each select="param">
941 <xsl:apply-templates select="@type" mode="wrapped">
942 <xsl:with-param name="dir" select="@dir"/>
943 </xsl:apply-templates>
944 <xsl:if test="not(position()=last())">
945 <xsl:text>,
946 </xsl:text>
947 <xsl:value-of select="$methodindent"/>
948 </xsl:if>
949 </xsl:for-each>
950 <xsl:text>) = 0;
951</xsl:text>
952</xsl:template>
953
954<xsl:template match="method" mode="code">
955 <xsl:param name="topclass"/>
956
957 <xsl:variable name="methodindent">
958 <xsl:call-template name="tospace">
959 <xsl:with-param name="str" select="@name"/>
960 </xsl:call-template>
961 </xsl:variable>
962 <xsl:variable name="methodclassindent">
963 <xsl:call-template name="tospace">
964 <xsl:with-param name="str" select="concat($topclass, @name)"/>
965 </xsl:call-template>
966 </xsl:variable>
967 <xsl:variable name="methodbasename">
968 <xsl:call-template name="capitalize">
969 <xsl:with-param name="str" select="@name"/>
970 </xsl:call-template>
971 </xsl:variable>
972
973 <xsl:value-of select="concat('STDMETHODIMP ', $topclass, 'Wrap::', $methodbasename, '(')"/>
974 <xsl:for-each select="param">
975 <xsl:apply-templates select="@type" mode="public">
976 <xsl:with-param name="dir" select="@dir"/>
977 </xsl:apply-templates>
978 <xsl:if test="not(position()=last())">
979 <xsl:text>,
980 </xsl:text>
981 <xsl:value-of select="$methodclassindent"/>
982 </xsl:if>
983 </xsl:for-each>
984 <xsl:text>)
985{
986 LogRelFlow(("{%p} %s:enter</xsl:text>
987 <xsl:for-each select="param">
988 <xsl:text> </xsl:text>
989 <xsl:apply-templates select="@type" mode="logparamtext">
990 <xsl:with-param name="dir" select="@dir"/>
991 <xsl:with-param name="mod" select="'ref'"/>
992 </xsl:apply-templates>
993 </xsl:for-each>
994 <xsl:text>\n", this</xsl:text>
995 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
996 <xsl:for-each select="param">
997 <xsl:text>, </xsl:text>
998 <xsl:apply-templates select="@type" mode="logparamval">
999 <xsl:with-param name="dir" select="@dir"/>
1000 <xsl:with-param name="mod" select="'ref'"/>
1001 </xsl:apply-templates>
1002 </xsl:for-each>
1003 <xsl:text>));
1004
1005 VirtualBoxBase::clearError();
1006
1007 HRESULT hrc;
1008
1009 try
1010 {
1011</xsl:text>
1012 <!-- @todo check in parameters if possible -->
1013 <xsl:for-each select="param">
1014 <xsl:if test="@dir!='in'">
1015 <xsl:text> CheckComArgOutPointerValidThrow(a</xsl:text>
1016 <xsl:call-template name="capitalize">
1017 <xsl:with-param name="str" select="@name"/>
1018 </xsl:call-template>
1019 <xsl:text>);
1020</xsl:text>
1021 </xsl:if>
1022 </xsl:for-each>
1023 <xsl:text>
1024 AutoCaller autoCaller(this);
1025 if (FAILED(autoCaller.rc()))
1026 throw autoCaller.rc();
1027
1028</xsl:text>
1029 <xsl:value-of select="concat(' hrc = ', @name, '(')"/>
1030 <xsl:variable name="passAutoCaller">
1031 <xsl:call-template name="checkoption">
1032 <xsl:with-param name="optionlist" select="@wrap-hint-server"/>
1033 <xsl:with-param name="option" select="'passcaller'"/>
1034 </xsl:call-template>
1035 </xsl:variable>
1036 <xsl:if test="$passAutoCaller = 'true'">
1037 <xsl:text>autoCaller</xsl:text>
1038 <xsl:if test="count(param) > 0">
1039 <xsl:text>,
1040 </xsl:text>
1041 <xsl:value-of select="$methodindent"/>
1042 </xsl:if>
1043 </xsl:if>
1044 <xsl:for-each select="param">
1045 <xsl:apply-templates select="@type" mode="paramvalconversion">
1046 <xsl:with-param name="dir" select="@dir"/>
1047 </xsl:apply-templates>
1048 <xsl:if test="not(position()=last())">
1049 <xsl:text>,
1050 </xsl:text>
1051 <xsl:value-of select="$methodindent"/>
1052 </xsl:if>
1053 </xsl:for-each>
1054 <xsl:text>);
1055 }
1056 catch (HRESULT hrc2)
1057 {
1058 hrc = hrc2;
1059 }
1060 catch (...)
1061 {
1062 hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
1063 }
1064
1065 LogRelFlow(("{%p} %s: leave</xsl:text>
1066 <xsl:for-each select="param">
1067 <xsl:if test="@dir!='in'">
1068 <xsl:text> </xsl:text>
1069 <xsl:apply-templates select="@type" mode="logparamtext">
1070 <xsl:with-param name="dir" select="@dir"/>
1071 </xsl:apply-templates>
1072 </xsl:if>
1073 </xsl:for-each>
1074 <xsl:text> hrc=%Rhrc\n", this</xsl:text>
1075 <xsl:value-of select="concat(', &quot;', $topclass, '::', @name, '&quot;')"/>
1076 <xsl:for-each select="param">
1077 <xsl:if test="@dir!='in'">
1078 <xsl:text>, </xsl:text>
1079 <xsl:apply-templates select="@type" mode="logparamval">
1080 <xsl:with-param name="dir" select="@dir"/>
1081 </xsl:apply-templates>
1082 </xsl:if>
1083 </xsl:for-each>
1084 <xsl:text>, hrc));
1085 return hrc;
1086}
1087
1088</xsl:text>
1089</xsl:template>
1090
1091<!-- - - - - - - - - - - - - - - - - - - - - - -
1092 emit all methods of an interface
1093 - - - - - - - - - - - - - - - - - - - - - - -->
1094<xsl:template name="emitMethods">
1095 <xsl:param name="iface"/>
1096 <xsl:param name="topclass"/>
1097 <xsl:param name="pmode"/>
1098
1099 <!-- first recurse to emit all base interfaces -->
1100 <xsl:variable name="extends" select="$iface/@extends"/>
1101 <xsl:if test="$extends and not($extends='$unknown') and not($extends='$dispatched') and not($extends='$errorinfo')">
1102 <xsl:call-template name="emitMethods">
1103 <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
1104 <xsl:with-param name="topclass" select="$topclass"/>
1105 <xsl:with-param name="pmode" select="$pmode"/>
1106 </xsl:call-template>
1107 </xsl:if>
1108
1109 <xsl:choose>
1110 <xsl:when test="$pmode='code'">
1111 <xsl:text>//
1112</xsl:text>
1113 <xsl:value-of select="concat('// ', $iface/@name, ' methods')"/>
1114 <xsl:text>
1115//
1116
1117</xsl:text>
1118 </xsl:when>
1119 <xsl:otherwise>
1120 <xsl:value-of select="concat('&#10; // ', $pmode, ' ', $iface/@name, ' methods&#10;')"/>
1121 </xsl:otherwise>
1122 </xsl:choose>
1123 <xsl:choose>
1124 <xsl:when test="$pmode='public'">
1125 <xsl:apply-templates select="$iface/method" mode="public"/>
1126 </xsl:when>
1127 <xsl:when test="$pmode='wrapped'">
1128 <xsl:apply-templates select="$iface/method" mode="wrapped"/>
1129 </xsl:when>
1130 <xsl:when test="$pmode='code'">
1131 <xsl:apply-templates select="$iface/method" mode="code">
1132 <xsl:with-param name="topclass" select="$topclass"/>
1133 </xsl:apply-templates>
1134 </xsl:when>
1135 <xsl:otherwise/>
1136 </xsl:choose>
1137</xsl:template>
1138
1139<!-- - - - - - - - - - - - - - - - - - - - - - -
1140 emit all attributes and methods declarations of an interface
1141 - - - - - - - - - - - - - - - - - - - - - - -->
1142<xsl:template name="emitInterfaceDecls">
1143 <xsl:param name="iface"/>
1144 <xsl:param name="pmode"/>
1145
1146 <!-- attributes -->
1147 <xsl:call-template name="emitAttributes">
1148 <xsl:with-param name="iface" select="$iface"/>
1149 <xsl:with-param name="pmode" select="$pmode"/>
1150 </xsl:call-template>
1151
1152 <!-- methods -->
1153 <xsl:call-template name="emitMethods">
1154 <xsl:with-param name="iface" select="$iface"/>
1155 <xsl:with-param name="pmode" select="$pmode"/>
1156 </xsl:call-template>
1157</xsl:template>
1158
1159<!-- - - - - - - - - - - - - - - - - - - - - - -
1160 emit auxiliary method declarations of an interface
1161 - - - - - - - - - - - - - - - - - - - - - - -->
1162<xsl:template name="emitAuxMethodDecls">
1163 <xsl:param name="iface"/>
1164 <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
1165</xsl:template>
1166
1167<!-- - - - - - - - - - - - - - - - - - - - - - -
1168 emit the header file of an interface
1169 - - - - - - - - - - - - - - - - - - - - - - -->
1170<xsl:template name="emitHeader">
1171 <xsl:param name="iface"/>
1172
1173 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
1174
1175 <xsl:choose>
1176 <xsl:when test="$filelistonly=''">
1177 <xsl:apply-templates select="$iface" mode="startfile">
1178 <xsl:with-param name="file" select="$filename"/>
1179 </xsl:apply-templates>
1180 <xsl:call-template name="fileheader">
1181 <xsl:with-param name="name" select="$filename"/>
1182 <xsl:with-param name="class" select="substring(@name, 2)"/>
1183 <xsl:with-param name="type" select="'header'"/>
1184 </xsl:call-template>
1185 <xsl:apply-templates select="." mode="classheader"/>
1186
1187 <!-- interface attributes/methods (public) -->
1188 <xsl:call-template name="emitInterfaceDecls">
1189 <xsl:with-param name="iface" select="$iface"/>
1190 <xsl:with-param name="pmode" select="'public'"/>
1191 </xsl:call-template>
1192
1193 <!-- auxiliary methods (public) -->
1194 <xsl:call-template name="emitAuxMethodDecls">
1195 <xsl:with-param name="iface" select="$iface"/>
1196 </xsl:call-template>
1197
1198 <!-- switch to private -->
1199 <xsl:text>
1200private:</xsl:text>
1201
1202 <!-- wrapped interface attributes/methods (private) -->
1203 <xsl:call-template name="emitInterfaceDecls">
1204 <xsl:with-param name="iface" select="$iface"/>
1205 <xsl:with-param name="pmode" select="'wrapped'"/>
1206 </xsl:call-template>
1207
1208 <xsl:apply-templates select="." mode="classfooter"/>
1209 <xsl:apply-templates select="$iface" mode="endfile">
1210 <xsl:with-param name="file" select="$filename"/>
1211 </xsl:apply-templates>
1212 </xsl:when>
1213 <xsl:otherwise>
1214 <xsl:apply-templates select="$iface" mode="listfile">
1215 <xsl:with-param name="file" select="$filename"/>
1216 </xsl:apply-templates>
1217 </xsl:otherwise>
1218 </xsl:choose>
1219</xsl:template>
1220
1221<!-- - - - - - - - - - - - - - - - - - - - - - -
1222 emit all attributes and methods definitions of an interface
1223 - - - - - - - - - - - - - - - - - - - - - - -->
1224<xsl:template name="emitInterfaceDefs">
1225 <xsl:param name="iface"/>
1226
1227 <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', substring($iface/@name, 2), 'Wrap)&#10;&#10;')"/>
1228
1229 <!-- attributes -->
1230 <xsl:call-template name="emitAttributes">
1231 <xsl:with-param name="iface" select="$iface"/>
1232 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1233 <xsl:with-param name="pmode" select="'code'"/>
1234 </xsl:call-template>
1235
1236 <!-- methods -->
1237 <xsl:call-template name="emitMethods">
1238 <xsl:with-param name="iface" select="$iface"/>
1239 <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
1240 <xsl:with-param name="pmode" select="'code'"/>
1241 </xsl:call-template>
1242</xsl:template>
1243
1244<!-- - - - - - - - - - - - - - - - - - - - - - -
1245 emit auxiliary method declarations of an interface
1246 - - - - - - - - - - - - - - - - - - - - - - -->
1247<xsl:template name="emitAuxMethodDefs">
1248 <xsl:param name="iface"/>
1249 <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
1250</xsl:template>
1251
1252
1253<!-- - - - - - - - - - - - - - - - - - - - - - -
1254 emit the code file of an interface
1255 - - - - - - - - - - - - - - - - - - - - - - -->
1256<xsl:template name="emitCode">
1257 <xsl:param name="iface"/>
1258
1259 <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
1260
1261 <xsl:choose>
1262 <xsl:when test="$filelistonly=''">
1263 <xsl:apply-templates select="$iface" mode="startfile">
1264 <xsl:with-param name="file" select="$filename"/>
1265 </xsl:apply-templates>
1266 <xsl:call-template name="fileheader">
1267 <xsl:with-param name="name" select="$filename"/>
1268 <xsl:with-param name="class" select="substring(@name, 2)"/>
1269 <xsl:with-param name="type" select="'code'"/>
1270 </xsl:call-template>
1271 <xsl:apply-templates select="." mode="codeheader"/>
1272
1273 <!-- @todo special thread logging for API methods returning IProgress??? would be very usefulcurrently nothing, maybe later some generic FinalConstruct/... implementation -->
1274
1275 <!-- interface attributes/methods (public) -->
1276 <xsl:call-template name="emitInterfaceDefs">
1277 <xsl:with-param name="iface" select="$iface"/>
1278 </xsl:call-template>
1279
1280 <!-- auxiliary methods (public) -->
1281 <xsl:call-template name="emitAuxMethodDefs">
1282 <xsl:with-param name="iface" select="$iface"/>
1283 </xsl:call-template>
1284
1285 <xsl:apply-templates select="." mode="codefooter"/>
1286 <xsl:apply-templates select="$iface" mode="endfile">
1287 <xsl:with-param name="file" select="$filename"/>
1288 </xsl:apply-templates>
1289 </xsl:when>
1290 <xsl:otherwise>
1291 <xsl:apply-templates select="$iface" mode="listfile">
1292 <xsl:with-param name="file" select="$filename"/>
1293 </xsl:apply-templates>
1294 </xsl:otherwise>
1295 </xsl:choose>
1296</xsl:template>
1297
1298
1299<!-- - - - - - - - - - - - - - - - - - - - - - -
1300 wildcard match, ignore everything which has no explicit match
1301 - - - - - - - - - - - - - - - - - - - - - - -->
1302
1303<xsl:template match="*"/>
1304
1305<!-- - - - - - - - - - - - - - - - - - - - - - -
1306 ignore all if tags except those for XPIDL or MIDL target
1307 - - - - - - - - - - - - - - - - - - - - - - -->
1308
1309<xsl:template match="if">
1310 <xsl:if test="(@target = 'xpidl') or (@target = 'midl')">
1311 <xsl:apply-templates/>
1312 </xsl:if>
1313</xsl:template>
1314
1315<!-- - - - - - - - - - - - - - - - - - - - - - -
1316 library match
1317 - - - - - - - - - - - - - - - - - - - - - - -->
1318
1319<xsl:template match="interface">
1320 <xsl:if test="not(@supportsErrorInfo='no')">
1321 <xsl:call-template name="emitHeader">
1322 <xsl:with-param name="iface" select="."/>
1323 </xsl:call-template>
1324
1325 <xsl:call-template name="emitCode">
1326 <xsl:with-param name="iface" select="."/>
1327 </xsl:call-template>
1328 </xsl:if>
1329</xsl:template>
1330
1331<!-- - - - - - - - - - - - - - - - - - - - - - -
1332 library match
1333 - - - - - - - - - - - - - - - - - - - - - - -->
1334
1335<xsl:template match="library">
1336 <xsl:apply-templates/>
1337</xsl:template>
1338
1339<!-- - - - - - - - - - - - - - - - - - - - - - -
1340 root match
1341 - - - - - - - - - - - - - - - - - - - - - - -->
1342
1343<xsl:template match="/idl">
1344 <xsl:choose>
1345 <xsl:when test="$filelistonly=''">
1346 </xsl:when>
1347 <xsl:otherwise>
1348 <xsl:value-of select="concat($filelistonly, ' := \&#10;')"/>
1349 </xsl:otherwise>
1350 </xsl:choose>
1351 <xsl:apply-templates/>
1352 <xsl:choose>
1353 <xsl:when test="$filelistonly=''">
1354 </xsl:when>
1355 <xsl:otherwise>
1356 <xsl:text>
1357</xsl:text>
1358 </xsl:otherwise>
1359 </xsl:choose>
1360</xsl:template>
1361
1362</xsl:stylesheet>
1363<!-- 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