VirtualBox

source: vbox/trunk/src/VBox/Main/idl/comimpl.xsl@ 85672

Last change on this file since 85672 was 85317, checked in by vboxsync, 4 years ago

Main/comimpl.xsl: Cleanup - don't emit inline setters we don't need. bugref:9790

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.4 KB
Line 
1<xsl:stylesheet version = '1.0'
2 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
3 xmlns:vbox="http://www.virtualbox.org/"
4 xmlns:exsl="http://exslt.org/common"
5 extension-element-prefixes="exsl">
6
7<!--
8
9 comimpl.xsl:
10 XSLT stylesheet that generates COM C++ classes implementing
11 interfaces described in VirtualBox.xidl.
12 For now we generate implementation for events, as they are
13 rather trivial container classes for their read-only attributes.
14 Further extension to other interfaces is possible and anticipated.
15
16 Copyright (C) 2010-2020 Oracle Corporation
17
18 This file is part of VirtualBox Open Source Edition (OSE), as
19 available from http://www.virtualbox.org. This file is free software;
20 you can redistribute it and/or modify it under the terms of the GNU
21 General Public License (GPL) as published by the Free Software
22 Foundation, in version 2 as it comes in the "COPYING" file of the
23 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
24 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
25-->
26
27<xsl:output
28 method="text"
29 version="1.0"
30 encoding="utf-8"
31 indent="no"/>
32
33<xsl:include href="typemap-shared.inc.xsl" />
34
35<!-- $G_kind contains what kind of COM class implementation we generate -->
36<xsl:variable name="G_xsltFilename" select="'autogen.xsl'" />
37<xsl:variable name="G_generateBstrVariants" select="'no'" />
38
39
40<!-- - - - - - - - - - - - - - - - - - - - - - -
41 Keys for more efficiently looking up of types.
42 - - - - - - - - - - - - - - - - - - - - - - -->
43
44<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
45<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
46
47<!-- - - - - - - - - - - - - - - - - - - - - - -
48 - - - - - - - - - - - - - - - - - - - - - - -->
49
50<xsl:template name="fileheader">
51 <xsl:param name="name" />
52 <xsl:text>/** @file </xsl:text>
53 <xsl:value-of select="$name"/>
54 <xsl:text>
55 * DO NOT EDIT! This is a generated file.
56 * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
57 * Generator: src/VBox/Main/idl/comimpl.xsl
58 */
59
60/*
61 * Copyright (C) 2010-2020 Oracle Corporation
62 *
63 * This file is part of VirtualBox Open Source Edition (OSE), as
64 * available from http://www.virtualbox.org. This file is free software;
65 * you can redistribute it and/or modify it under the terms of the GNU
66 * General Public License (GPL) as published by the Free Software
67 * Foundation, in version 2 as it comes in the "COPYING" file of the
68 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
69 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
70 */
71
72</xsl:text>
73</xsl:template>
74
75<xsl:template name="genComEntry">
76 <xsl:param name="name" />
77 <xsl:variable name="extends">
78 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
79 </xsl:variable>
80
81 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $name, ')&#10;')" />
82 <xsl:choose>
83 <xsl:when test="$extends='$unknown'">
84 <!-- Reached base -->
85 </xsl:when>
86 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
87 <xsl:call-template name="genComEntry">
88 <xsl:with-param name="name" select="$extends" />
89 </xsl:call-template>
90 </xsl:when>
91 <xsl:otherwise>
92 <xsl:call-template name="fatalError">
93 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $extends)" />
94 </xsl:call-template>
95 </xsl:otherwise>
96 </xsl:choose>
97</xsl:template>
98
99<xsl:template name="typeIdl2Back">
100 <xsl:param name="type" />
101 <xsl:param name="safearray" />
102 <xsl:param name="param" />
103 <xsl:param name="dir" />
104 <xsl:param name="mod" />
105 <xsl:param name="utf8str" select="'no'" />
106
107 <xsl:choose>
108 <xsl:when test="$safearray='yes'">
109 <xsl:variable name="elemtype">
110 <xsl:call-template name="typeIdl2Back">
111 <xsl:with-param name="type" select="$type" />
112 <xsl:with-param name="safearray" select="''" />
113 <xsl:with-param name="dir" select="'in'" />
114 <xsl:with-param name="utf8str" select="$utf8str" />
115 </xsl:call-template>
116 </xsl:variable>
117 <xsl:choose>
118 <xsl:when test="$param and ($dir='in')">
119 <xsl:value-of select="concat('ComSafeArrayIn(',$elemtype,',', $param,')')"/>
120 </xsl:when>
121 <xsl:when test="$param and ($dir='out')">
122 <xsl:value-of select="concat('ComSafeArrayOut(',$elemtype,', ', $param, ')')"/>
123 </xsl:when>
124 <xsl:otherwise>
125 <xsl:value-of select="concat('com::SafeArray&lt;',$elemtype,'&gt;')"/>
126 </xsl:otherwise>
127 </xsl:choose>
128 </xsl:when>
129 <xsl:otherwise>
130 <xsl:choose>
131 <xsl:when test="$mod='ptr'">
132 <xsl:value-of select="'BYTE *'" />
133 </xsl:when>
134 <xsl:when test="(($type='wstring') or ($type='uuid'))">
135 <xsl:choose>
136 <xsl:when test="$param and ($dir='in') and ($utf8str!='yes')">
137 <xsl:value-of select="'CBSTR'"/>
138 </xsl:when>
139 <xsl:when test="$param and ($dir='in') and ($utf8str='yes')">
140 <xsl:value-of select="'const Utf8Str &amp;'"/>
141 </xsl:when>
142 <xsl:when test="$param and ($dir='out')">
143 <xsl:value-of select="'BSTR'"/>
144 </xsl:when>
145 <xsl:when test="$param and ($dir='out') and ($utf8str='yes')">
146 <xsl:value-of select="'Utf8Str &amp;'"/>
147 </xsl:when>
148 <xsl:otherwise>
149 <xsl:value-of select="'Utf8Str'"/>
150 </xsl:otherwise>
151 </xsl:choose>
152 </xsl:when>
153 <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
154 <xsl:value-of select="concat($type,'_T')"/>
155 </xsl:when>
156 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
157 <xsl:choose>
158 <xsl:when test="$param">
159 <xsl:value-of select="concat($type,' *')"/>
160 </xsl:when>
161 <xsl:otherwise>
162 <xsl:value-of select="concat('ComPtr&lt;',$type,'&gt;')"/>
163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:when>
166 <xsl:when test="$type='boolean'">
167 <xsl:value-of select="'BOOL'" />
168 </xsl:when>
169 <xsl:when test="$type='octet'">
170 <xsl:value-of select="'BYTE'" />
171 </xsl:when>
172 <xsl:when test="$type='unsigned short'">
173 <xsl:value-of select="'USHORT'" />
174 </xsl:when>
175 <xsl:when test="$type='short'">
176 <xsl:value-of select="'SHORT'" />
177 </xsl:when>
178 <xsl:when test="$type='unsigned long'">
179 <xsl:value-of select="'ULONG'" />
180 </xsl:when>
181 <xsl:when test="$type='long'">
182 <xsl:value-of select="'LONG'" />
183 </xsl:when>
184 <xsl:when test="$type='unsigned long long'">
185 <xsl:value-of select="'ULONG64'" />
186 </xsl:when>
187 <xsl:when test="$type='long long'">
188 <xsl:value-of select="'LONG64'" />
189 </xsl:when>
190 <xsl:otherwise>
191 <xsl:call-template name="fatalError">
192 <xsl:with-param name="msg" select="concat('Unhandled type: ', $type)" />
193 </xsl:call-template>
194 </xsl:otherwise>
195 </xsl:choose>
196 <xsl:if test="$dir='out'">
197 <xsl:value-of select="' *'"/>
198 </xsl:if>
199 <xsl:if test="$param and not($param='_')">
200 <xsl:value-of select="concat(' ', $param)"/>
201 </xsl:if>
202 </xsl:otherwise>
203 </xsl:choose>
204
205</xsl:template>
206
207<!-- Checks if interface $name has any string attributes, producing '1' for each string attrib.
208 No output if no string attributes -->
209<xsl:template name="hasStringAttributes">
210 <xsl:param name="name" />
211
212 <!-- Recurse into parent interfaces: -->
213 <xsl:variable name="extends">
214 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
215 </xsl:variable>
216 <xsl:choose>
217 <xsl:when test="$extends='IEvent'">
218 </xsl:when>
219 <xsl:when test="$extends='IReusableEvent'">
220 </xsl:when>
221 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
222 <xsl:call-template name="hasStringAttributes">
223 <xsl:with-param name="name" select="$extends" />
224 </xsl:call-template>
225 </xsl:when>
226 <xsl:otherwise>
227 <xsl:call-template name="fatalError">
228 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
229 </xsl:call-template>
230 </xsl:otherwise>
231 </xsl:choose>
232
233 <!-- Find immediate string and uuid attributes and output '1' for each one: -->
234 <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute[(@type = 'wstring' or @type = 'uuid') and (@name != 'midlDoesNotLikeEmptyInterfaces')]">
235 <xsl:text>1</xsl:text>
236 </xsl:for-each>
237</xsl:template>
238
239
240<xsl:template name="genSetParam">
241 <xsl:param name="member"/>
242 <xsl:param name="param"/>
243 <xsl:param name="type"/>
244 <xsl:param name="safearray"/>
245 <xsl:param name="internal"/>
246
247 <xsl:choose>
248 <xsl:when test="$safearray='yes'">
249 <xsl:variable name="elemtype">
250 <xsl:call-template name="typeIdl2Back">
251 <xsl:with-param name="type" select="$type" />
252 <xsl:with-param name="safearray" select="''" />
253 <xsl:with-param name="dir" select="'in'" />
254 </xsl:call-template>
255 </xsl:variable>
256 <xsl:text> SafeArray&lt;</xsl:text><xsl:value-of select="$elemtype"/>
257 <xsl:text>&gt; aArr(ComSafeArrayInArg(</xsl:text><xsl:value-of select="$param"/><xsl:text>));&#10;</xsl:text>
258 <xsl:text> return </xsl:text><xsl:value-of select="$member"/><xsl:text>.initFrom(aArr);&#10;</xsl:text>
259 </xsl:when>
260 <xsl:when test="($type='wstring') or ($type='uuid')">
261 <xsl:text> return </xsl:text><xsl:value-of select="$member"/><xsl:text>.assignEx(</xsl:text>
262 <xsl:value-of select="$param"/><xsl:text>);&#10;</xsl:text>
263 </xsl:when>
264 <xsl:otherwise>
265 <xsl:value-of select="concat(' ', $member, ' = ', $param, ';&#10;')"/>
266 <xsl:if test="$internal!='yes'">
267 <xsl:text> return S_OK;&#10;</xsl:text>
268 </xsl:if>
269 </xsl:otherwise>
270 </xsl:choose>
271</xsl:template>
272
273<xsl:template name="genRetParam">
274 <xsl:param name="member"/>
275 <xsl:param name="param"/>
276 <xsl:param name="type"/>
277 <xsl:param name="safearray"/>
278 <xsl:choose>
279 <xsl:when test="$safearray='yes'">
280 <xsl:variable name="elemtype">
281 <xsl:call-template name="typeIdl2Back">
282 <xsl:with-param name="type" select="$type" />
283 <xsl:with-param name="safearray" select="''" />
284 <xsl:with-param name="dir" select="'in'" />
285 </xsl:call-template>
286 </xsl:variable>
287<!-- @todo String arrays probably needs work, I doubt we're generating sensible code for them at the moment. -->
288 <xsl:text> SafeArray&lt;</xsl:text><xsl:value-of select="$elemtype"/><xsl:text>&gt; result;&#10;</xsl:text>
289 <xsl:text> HRESULT hrc = </xsl:text><xsl:value-of select="$member"/><xsl:text>.cloneTo(result);&#10;</xsl:text>
290 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
291 <xsl:text> result.detachTo(ComSafeArrayOutArg(</xsl:text><xsl:value-of select="$param"/><xsl:text>));&#10;</xsl:text>
292 <xsl:text> return hrc;&#10;</xsl:text>
293 </xsl:when>
294 <xsl:otherwise>
295 <xsl:choose>
296 <xsl:when test="($type='wstring') or ($type = 'uuid')">
297 <xsl:text> return </xsl:text><xsl:value-of select="$member"/><xsl:text>.cloneToEx(</xsl:text>
298 <xsl:value-of select="$param"/><xsl:text>);&#10;</xsl:text>
299 </xsl:when>
300 <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
301 <xsl:text> return </xsl:text><xsl:value-of select="$member"/><xsl:text>.queryInterfaceTo(</xsl:text>
302 <xsl:value-of select="$param"/><xsl:text>);&#10;</xsl:text>
303 </xsl:when>
304 <xsl:otherwise>
305 <xsl:text> *</xsl:text><xsl:value-of select="$param"/><xsl:text> = </xsl:text>
306 <xsl:value-of select="$member"/><xsl:text>;&#10;</xsl:text>
307 <xsl:text> return S_OK;&#10;</xsl:text>
308 </xsl:otherwise>
309 </xsl:choose>
310 </xsl:otherwise>
311 </xsl:choose>
312</xsl:template>
313
314<xsl:template name="genFormalParams">
315 <xsl:param name="name" />
316 <xsl:param name="utf8str" />
317 <xsl:variable name="extends">
318 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
319 </xsl:variable>
320
321 <xsl:choose>
322 <xsl:when test="$extends='IEvent'">
323 </xsl:when>
324 <xsl:when test="$extends='IReusableEvent'">
325 </xsl:when>
326 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
327 <xsl:call-template name="genFormalParams">
328 <xsl:with-param name="name" select="$extends" />
329 <xsl:with-param name="utf8str" select="$utf8str" />
330 </xsl:call-template>
331 </xsl:when>
332 <xsl:otherwise>
333 <xsl:call-template name="fatalError">
334 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
335 </xsl:call-template>
336 </xsl:otherwise>
337 </xsl:choose>
338
339 <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute[@name != 'midlDoesNotLikeEmptyInterfaces']">
340 <xsl:variable name="aName" select="concat('a_',@name)"/>
341 <xsl:variable name="aTypeName">
342 <xsl:call-template name="typeIdl2Back">
343 <xsl:with-param name="type" select="@type" />
344 <xsl:with-param name="safearray" select="@safearray" />
345 <xsl:with-param name="param" select="$aName" />
346 <xsl:with-param name="dir" select="'in'" />
347 <xsl:with-param name="mod" select="@mod" />
348 <xsl:with-param name="utf8str" select="$utf8str" />
349 </xsl:call-template>
350 </xsl:variable>
351 <xsl:value-of select="concat(', ',$aTypeName)"/>
352 </xsl:for-each>
353</xsl:template>
354
355<xsl:template name="genCallParams">
356 <xsl:param name="name" />
357 <xsl:variable name="extends">
358 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
359 </xsl:variable>
360
361 <xsl:choose>
362 <xsl:when test="$extends='IEvent'">
363 </xsl:when>
364 <xsl:when test="$extends='IReusableEvent'">
365 </xsl:when>
366 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
367 <xsl:call-template name="genCallParams">
368 <xsl:with-param name="name" select="$extends" />
369 </xsl:call-template>
370 </xsl:when>
371 <xsl:otherwise>
372 <xsl:call-template name="fatalError">
373 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
374 </xsl:call-template>
375 </xsl:otherwise>
376 </xsl:choose>
377
378 <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute[@name != 'midlDoesNotLikeEmptyInterfaces']">
379 <xsl:variable name="aName" select="concat('a_',@name)"/>
380 <xsl:choose>
381 <xsl:when test="@safearray='yes'">
382 <xsl:value-of select="concat(', ComSafeArrayInArg(',$aName,')')"/>
383 </xsl:when>
384 <xsl:otherwise>
385 <xsl:value-of select="concat(', ',$aName)"/>
386 </xsl:otherwise>
387 </xsl:choose>
388 </xsl:for-each>
389</xsl:template>
390
391<xsl:template name="genAttrInitCode">
392 <xsl:param name="name" />
393 <xsl:param name="obj" />
394 <xsl:variable name="extends">
395 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
396 </xsl:variable>
397
398 <xsl:choose>
399 <xsl:when test="$extends='IEvent'">
400 </xsl:when>
401 <xsl:when test="$extends='IReusableEvent'">
402 </xsl:when>
403 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
404 <xsl:call-template name="genAttrInitCode">
405 <xsl:with-param name="name" select="$extends" />
406 <xsl:with-param name="obj" select="$obj" />
407 </xsl:call-template>
408 </xsl:when>
409 <xsl:otherwise>
410 <xsl:call-template name="fatalError">
411 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
412 </xsl:call-template>
413 </xsl:otherwise>
414 </xsl:choose>
415
416 <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute[@name != 'midlDoesNotLikeEmptyInterfaces']">
417 <xsl:variable name="aName" select="concat('a_',@name)"/>
418 <xsl:variable name="aTypeName">
419 <xsl:call-template name="typeIdl2Back">
420 <xsl:with-param name="type" select="@type" />
421 <xsl:with-param name="safearray" select="@safearray" />
422 <xsl:with-param name="param" select="$aName" />
423 <xsl:with-param name="dir" select="'in'" />
424 <xsl:with-param name="mod" select="@mod" />
425 </xsl:call-template>
426 </xsl:variable>
427 <xsl:variable name="aType">
428 <xsl:call-template name="typeIdl2Back">
429 <xsl:with-param name="type" select="@type" />
430 <xsl:with-param name="safearray" select="@safearray" />
431 <xsl:with-param name="param" select="'_'" />
432 <xsl:with-param name="dir" select="'in'" />
433 <xsl:with-param name="mod" select="@mod" />
434 </xsl:call-template>
435 </xsl:variable>
436
437 <xsl:choose>
438 <xsl:when test="@safearray='yes'">
439 <xsl:variable name="elemtype">
440 <xsl:call-template name="typeIdl2Back">
441 <xsl:with-param name="type" select="@type" />
442 <xsl:with-param name="safearray" select="''" />
443 <xsl:with-param name="dir" select="'in'" />
444 </xsl:call-template>
445 </xsl:variable>
446 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
447 <xsl:value-of select="concat(' hrc = ',$obj, '->set_', @name, '(ComSafeArrayInArg(a_', @name, '));&#10;')"/>
448 </xsl:when>
449 <xsl:when test="(@type='wstring') or (@type = 'uuid')">
450 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
451 <xsl:value-of select="concat(' hrc = ',$obj, '->set_', @name, '(',$aName, ');&#10;')"/>
452 </xsl:when>
453 <xsl:otherwise>
454 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, ');&#10;')"/>
455 </xsl:otherwise>
456 </xsl:choose>
457 </xsl:for-each>
458</xsl:template>
459
460<xsl:template name="genImplList">
461 <xsl:param name="impl" />
462 <xsl:param name="name" />
463 <xsl:param name="depth" />
464 <xsl:param name="parents" />
465
466 <xsl:variable name="extends">
467 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
468 </xsl:variable>
469
470 <xsl:choose>
471 <xsl:when test="$name='IEvent'">
472 <xsl:value-of select=" '#ifdef VBOX_WITH_XPCOM&#10;'" />
473 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', $impl, ')&#10;')" />
474 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS',$depth,'_CI(', $impl, $parents, ', IEvent)&#10;')" />
475 <xsl:value-of select=" '#endif&#10;&#10;'"/>
476 </xsl:when>
477 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
478 <xsl:call-template name="genImplList">
479 <xsl:with-param name="impl" select="$impl" />
480 <xsl:with-param name="name" select="$extends" />
481 <xsl:with-param name="depth" select="$depth+1" />
482 <xsl:with-param name="parents" select="concat($parents, ', ', $name)" />
483 </xsl:call-template>
484 </xsl:when>
485 <xsl:otherwise>
486 <xsl:call-template name="fatalError">
487 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
488 </xsl:call-template>
489 </xsl:otherwise>
490 </xsl:choose>
491</xsl:template>
492
493<xsl:template name="genAttrCode">
494 <xsl:param name="name" />
495 <xsl:param name="depth" />
496 <xsl:param name="parents" />
497 <xsl:param name="fGenBstr" />
498
499 <xsl:variable name="extends">
500 <xsl:value-of select="key('G_keyInterfacesByName', $name)/@extends" />
501 </xsl:variable>
502
503 <xsl:for-each select="key('G_keyInterfacesByName', $name)/attribute">
504 <xsl:variable name="mName">
505 <xsl:value-of select="concat('m_', @name)" />
506 </xsl:variable>
507 <xsl:variable name="mType">
508 <xsl:call-template name="typeIdl2Back">
509 <xsl:with-param name="type" select="@type" />
510 <xsl:with-param name="safearray" select="@safearray" />
511 <xsl:with-param name="dir" select="'in'" />
512 <xsl:with-param name="mod" select="@mod" />
513 </xsl:call-template>
514 </xsl:variable>
515 <xsl:variable name="pName">
516 <xsl:value-of select="concat('a_', @name)" />
517 </xsl:variable>
518 <xsl:variable name="pTypeNameOut">
519 <xsl:call-template name="typeIdl2Back">
520 <xsl:with-param name="type" select="@type" />
521 <xsl:with-param name="safearray" select="@safearray" />
522 <xsl:with-param name="param" select="$pName" />
523 <xsl:with-param name="dir" select="'out'" />
524 <xsl:with-param name="mod" select="@mod" />
525 </xsl:call-template>
526 </xsl:variable>
527
528 <xsl:variable name="pTypeNameIn">
529 <xsl:call-template name="typeIdl2Back">
530 <xsl:with-param name="type" select="@type" />
531 <xsl:with-param name="safearray" select="@safearray" />
532 <xsl:with-param name="param" select="$pName" />
533 <xsl:with-param name="dir" select="'in'" />
534 <xsl:with-param name="mod" select="@mod" />
535 </xsl:call-template>
536 </xsl:variable>
537
538 <xsl:variable name="capsName">
539 <xsl:call-template name="capitalize">
540 <xsl:with-param name="str" select="@name" />
541 </xsl:call-template>
542 </xsl:variable>
543
544 <xsl:value-of select=" '&#10;'" />
545 <xsl:value-of select="concat(' // attribute ', @name,'&#10;')" />
546 <xsl:value-of select=" 'private:&#10;'" />
547 <xsl:value-of select="concat(' ', $mType, ' ', $mName,';&#10;')" />
548 <xsl:value-of select=" 'public:&#10;'" />
549 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,') RT_OVERRIDE&#10; {&#10;')" />
550 <xsl:call-template name="genRetParam">
551 <xsl:with-param name="type" select="@type" />
552 <xsl:with-param name="member" select="$mName" />
553 <xsl:with-param name="param" select="$pName" />
554 <xsl:with-param name="safearray" select="@safearray" />
555 </xsl:call-template>
556 <xsl:value-of select=" ' }&#10;'" />
557
558 <xsl:if test="not(@readonly='yes')">
559 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,') RT_OVERRIDE&#10; {&#10;')" />
560 <xsl:call-template name="genSetParam">
561 <xsl:with-param name="type" select="@type" />
562 <xsl:with-param name="member" select="$mName" />
563 <xsl:with-param name="param" select="$pName" />
564 <xsl:with-param name="safearray" select="@safearray" />
565 <xsl:with-param name="internal" select="'no'" />
566 </xsl:call-template>
567 <xsl:value-of select=" ' }&#10;'" />
568 </xsl:if>
569
570 <xsl:text> // purely internal setter&#10;</xsl:text>
571 <xsl:if test="(@type='wstring') or (@type = 'uuid')">
572 <xsl:text> inline HRESULT set_</xsl:text><xsl:value-of select="@name"/><xsl:text>(const Utf8Str &amp;a_rString)&#10;</xsl:text>
573 <xsl:text> {&#10;</xsl:text>
574 <xsl:text> return </xsl:text><xsl:value-of select="$mName"/><xsl:text>.assignEx(a_rString);&#10;</xsl:text>
575 <xsl:text> }&#10;</xsl:text>
576 </xsl:if>
577 <xsl:if test="not((@type='wstring') or (@type = 'uuid')) or $fGenBstr">
578 <xsl:text> inline </xsl:text>
579 <xsl:choose>
580 <xsl:when test="(@safearray='yes') or (@type='wstring') or (@type = 'uuid')">
581 <xsl:text>HRESULT</xsl:text>
582 </xsl:when>
583 <xsl:otherwise>
584 <xsl:text>void</xsl:text>
585 </xsl:otherwise>
586 </xsl:choose>
587 <xsl:value-of select="concat(' set_', @name,'(',$pTypeNameIn, ')&#10; {&#10;')" />
588 <xsl:call-template name="genSetParam">
589 <xsl:with-param name="type" select="@type" />
590 <xsl:with-param name="member" select="$mName" />
591 <xsl:with-param name="param" select="$pName" />
592 <xsl:with-param name="safearray" select="@safearray" />
593 <xsl:with-param name="internal" select="'yes'" />
594 </xsl:call-template>
595 <xsl:value-of select=" ' }&#10;'" />
596 </xsl:if>
597
598 </xsl:for-each>
599
600 <xsl:choose>
601 <xsl:when test="$extends='IEvent'">
602 <xsl:value-of select=" ' // skipping IEvent attributes &#10;'" />
603 </xsl:when>
604 <xsl:when test="$extends='IReusableEvent'">
605 <xsl:value-of select=" ' // skipping IReusableEvent attributes &#10;'" />
606 </xsl:when>
607 <xsl:when test="$extends='IVetoEvent'">
608 <xsl:value-of select=" ' // skipping IVetoEvent attributes &#10;'" />
609 </xsl:when>
610 <xsl:when test="count(key('G_keyInterfacesByName', $extends)) > 0">
611 <xsl:call-template name="genAttrCode">
612 <xsl:with-param name="name" select="$extends" />
613 <xsl:with-param name="depth" select="$depth+1" />
614 <xsl:with-param name="parents" select="concat($parents, ', ', @name)" />
615 <xsl:with-param name="fGenBstr" select="$fGenBstr" />
616 </xsl:call-template>
617 </xsl:when>
618 <xsl:otherwise>
619 <xsl:call-template name="fatalError">
620 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $extends)" />
621 </xsl:call-template>
622 </xsl:otherwise>
623 </xsl:choose>
624</xsl:template>
625
626<xsl:template name="genReinitFunction">
627 <xsl:param name="name"/>
628 <xsl:param name="evname"/>
629 <xsl:param name="ifname"/>
630 <xsl:param name="implName"/>
631 <xsl:param name="utf8str"/>
632
633 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
634 <xsl:call-template name="genFormalParams">
635 <xsl:with-param name="name" select="$ifname" />
636 <xsl:with-param name="utf8str" select="'no'" />
637 </xsl:call-template>
638 <xsl:text>)&#10;</xsl:text>
639 <xsl:text>{&#10;</xsl:text>
640 <xsl:text> </xsl:text><xsl:value-of select="$implName"/><xsl:text> *pEvtImpl = dynamic_cast&lt;</xsl:text>
641 <xsl:value-of select="$implName"/><xsl:text> *&gt;(aEvent);&#10;</xsl:text>
642 <xsl:text> if (pEvtImpl)&#10;</xsl:text>
643 <xsl:text> {&#10;</xsl:text>
644 <xsl:text> pEvtImpl->Reuse();&#10;</xsl:text>
645 <xsl:text> HRESULT hrc = S_OK;&#10;</xsl:text>
646 <xsl:call-template name="genAttrInitCode">
647 <xsl:with-param name="name" select="$name" />
648 <xsl:with-param name="obj" select="'pEvtImpl'" />
649 </xsl:call-template>
650 <xsl:text> return hrc;&#10;</xsl:text>
651 <xsl:text> }&#10;</xsl:text>
652 <xsl:text> return E_INVALIDARG;&#10;</xsl:text>
653 <xsl:text>}&#10;</xsl:text>
654 <xsl:text>&#10;</xsl:text>
655</xsl:template>
656
657<xsl:template name="genCreateFunction">
658 <xsl:param name="name"/>
659 <xsl:param name="evname"/>
660 <xsl:param name="ifname"/>
661 <xsl:param name="implName"/>
662 <xsl:param name="waitable"/>
663 <xsl:param name="evid"/>
664 <xsl:param name="utf8str"/>
665
666 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
667 <xsl:call-template name="genFormalParams">
668 <xsl:with-param name="name" select="$ifname" />
669 <xsl:with-param name="utf8str" select="$utf8str" />
670 </xsl:call-template>
671 <xsl:text>)&#10;</xsl:text>
672 <xsl:text>{&#10;</xsl:text>
673 <xsl:text> ComObjPtr&lt;</xsl:text><xsl:value-of select="$implName"/><xsl:text>&gt; EvtObj;&#10;</xsl:text>
674 <xsl:text> HRESULT hrc = EvtObj.createObject();&#10;</xsl:text>
675 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
676 <xsl:text> {&#10;</xsl:text>
677 <xsl:text> hrc = EvtObj-&gt;init(aSource, VBoxEventType_</xsl:text><xsl:value-of select="$evid"/>
678 <xsl:text>, </xsl:text><xsl:value-of select="$waitable" /><xsl:text> /*waitable*/);&#10;</xsl:text>
679 <xsl:call-template name="genAttrInitCode">
680 <xsl:with-param name="name" select="$name" />
681 <xsl:with-param name="obj" select="'EvtObj'" />
682 </xsl:call-template>
683 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
684 <xsl:text> {&#10;</xsl:text>
685 <xsl:text> hrc = EvtObj.queryInterfaceTo(aEvent);&#10;</xsl:text>
686 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
687 <xsl:text> return hrc;&#10;</xsl:text>
688 <xsl:text> }&#10;</xsl:text>
689 <xsl:text> }&#10;</xsl:text>
690 <xsl:text> *aEvent = NULL;&#10;</xsl:text>
691 <xsl:text> return hrc;&#10;</xsl:text>
692 <xsl:text>}&#10;</xsl:text>
693 <xsl:text>&#10;</xsl:text>
694</xsl:template>
695
696<xsl:template name="genFireFunction">
697 <xsl:param name="evname"/>
698 <xsl:param name="ifname"/>
699 <xsl:param name="utf8str"/>
700
701 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
702 <xsl:call-template name="genFormalParams">
703 <xsl:with-param name="name" select="$ifname" />
704 <xsl:with-param name="utf8str" select="$utf8str" />
705 </xsl:call-template>
706 <xsl:text>)&#10;</xsl:text>
707 <xsl:text>{&#10;</xsl:text>
708 <xsl:text> AssertReturn(aSource, E_INVALIDARG);&#10;</xsl:text>
709 <xsl:text> ComPtr&lt;IEvent&gt; ptrEvent;&#10;</xsl:text>
710 <xsl:text> HRESULT hrc = </xsl:text>
711 <xsl:value-of select="concat('Create', $evname, '(ptrEvent.asOutParam(), aSource')"/>
712 <xsl:call-template name="genCallParams">
713 <xsl:with-param name="name" select="$ifname" />
714 </xsl:call-template>
715 <xsl:text>);&#10;</xsl:text>
716 <xsl:text> if (SUCCEEDED(hrc))&#10;</xsl:text>
717 <xsl:text> {&#10;</xsl:text>
718 <xsl:text> BOOL fDeliveredIgnored = FALSE;&#10;</xsl:text>
719 <xsl:text> hrc = aSource-&gt;FireEvent(ptrEvent, /* do not wait for delivery */ 0, &amp;fDeliveredIgnored);&#10;</xsl:text>
720 <xsl:text> AssertComRC(hrc);&#10;</xsl:text>
721 <xsl:text> }&#10;</xsl:text>
722 <xsl:text> return hrc;&#10;</xsl:text>
723 <xsl:text>}&#10;</xsl:text>
724 <xsl:text>&#10;</xsl:text>
725</xsl:template>
726
727<xsl:template name="genEventImpl">
728 <xsl:param name="implName" />
729 <xsl:param name="isVeto" />
730 <xsl:param name="isReusable" />
731
732 <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName,
733 '&#10; : public VirtualBoxBase&#10; , VBOX_SCRIPTABLE_IMPL(',
734 @name, ')&#10;{&#10;')" />
735 <xsl:value-of select="'public:&#10;'" />
736 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', $implName, ', ', @name, ')&#10;')" />
737 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', $implName, ')&#10;')" />
738 <xsl:value-of select=" ' DECLARE_PROTECT_FINAL_CONSTRUCT()&#10;'" />
739 <xsl:value-of select="concat(' BEGIN_COM_MAP(', $implName, ')&#10;')" />
740 <xsl:value-of select=" ' COM_INTERFACE_ENTRY(ISupportErrorInfo)&#10;'" />
741 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', @name, ')&#10;')" />
742 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')&#10;')" />
743 <xsl:value-of select="concat(' VBOX_TWEAK_INTERFACE_ENTRY(', @name, ')&#10;')" />
744
745 <xsl:call-template name="genComEntry">
746 <xsl:with-param name="name" select="@name" />
747 </xsl:call-template>
748 <xsl:value-of select=" ' END_COM_MAP()&#10;'" />
749 <xsl:value-of select="concat(' ',$implName,'() { Log12((&quot;',$implName,' %p\n&quot;, this)); }&#10;')" />
750 <xsl:value-of select="concat(' virtual ~',$implName,'() { Log12((&quot;~',$implName,' %p\n&quot;, this)); uninit(); }&#10;')" />
751 <xsl:text><![CDATA[
752 HRESULT FinalConstruct()
753 {
754 BaseFinalConstruct();
755 return mEvent.createObject();
756 }
757 void FinalRelease()
758 {
759 uninit();
760 BaseFinalRelease();
761 }
762 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType) RT_OVERRIDE
763 {
764 return mEvent->COMGETTER(Type)(aType);
765 }
766 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource) RT_OVERRIDE
767 {
768 return mEvent->COMGETTER(Source)(aSource);
769 }
770 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable) RT_OVERRIDE
771 {
772 return mEvent->COMGETTER(Waitable)(aWaitable);
773 }
774 STDMETHOD(SetProcessed)() RT_OVERRIDE
775 {
776 return mEvent->SetProcessed();
777 }
778 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult) RT_OVERRIDE
779 {
780 return mEvent->WaitProcessed(aTimeout, aResult);
781 }
782 void uninit()
783 {
784 if (!mEvent.isNull())
785 {
786 mEvent->uninit();
787 mEvent.setNull();
788 }
789 }
790]]></xsl:text>
791 <xsl:choose>
792 <xsl:when test="$isVeto='yes'">
793<xsl:text><![CDATA[
794 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)
795 {
796 NOREF(aWaitable);
797 return mEvent->init(aSource, aType);
798 }
799 STDMETHOD(AddVeto)(IN_BSTR aVeto) RT_OVERRIDE
800 {
801 return mEvent->AddVeto(aVeto);
802 }
803 STDMETHOD(IsVetoed)(BOOL *aResult) RT_OVERRIDE
804 {
805 return mEvent->IsVetoed(aResult);
806 }
807 STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos)) RT_OVERRIDE
808 {
809 return mEvent->GetVetos(ComSafeArrayOutArg(aVetos));
810 }
811 STDMETHOD(AddApproval)(IN_BSTR aReason) RT_OVERRIDE
812 {
813 return mEvent->AddApproval(aReason);
814 }
815 STDMETHOD(IsApproved)(BOOL *aResult) RT_OVERRIDE
816 {
817 return mEvent->IsApproved(aResult);
818 }
819 STDMETHOD(GetApprovals)(ComSafeArrayOut(BSTR, aReasons)) RT_OVERRIDE
820 {
821 return mEvent->GetApprovals(ComSafeArrayOutArg(aReasons));
822 }
823private:
824 ComObjPtr<VBoxVetoEvent> mEvent;
825]]></xsl:text>
826 </xsl:when>
827 <xsl:when test="$isReusable='yes'">
828 <xsl:text>
829<![CDATA[
830 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable = FALSE)
831 {
832 mGeneration = 1;
833 return mEvent->init(aSource, aType, aWaitable);
834 }
835 STDMETHOD(COMGETTER(Generation))(ULONG *aGeneration) RT_OVERRIDE
836 {
837 *aGeneration = mGeneration;
838 return S_OK;
839 }
840 STDMETHOD(Reuse)() RT_OVERRIDE
841 {
842 ASMAtomicIncU32((volatile uint32_t *)&mGeneration);
843 return S_OK;
844 }
845private:
846 volatile ULONG mGeneration;
847 ComObjPtr<VBoxEvent> mEvent;
848]]></xsl:text>
849 </xsl:when>
850 <xsl:otherwise>
851<xsl:text><![CDATA[
852 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable)
853 {
854 return mEvent->init(aSource, aType, aWaitable);
855 }
856private:
857 ComObjPtr<VBoxEvent> mEvent;
858]]></xsl:text>
859 </xsl:otherwise>
860 </xsl:choose>
861
862 <!-- Before we generate attribute code, we check and make sure there are attributes here. -->
863 <xsl:if test="count(attribute) = 0 and @name != 'INATNetworkAlterEvent'">
864 <xsl:call-template name="fatalError">
865 <xsl:with-param name="msg">error: <xsl:value-of select="@name"/> has no attributes</xsl:with-param>
866 </xsl:call-template>
867 </xsl:if>
868
869 <xsl:call-template name="genAttrCode">
870 <xsl:with-param name="name" select="@name" />
871 <xsl:with-param name="fGenBstr" select="($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR'))" />
872 </xsl:call-template>
873 <xsl:value-of select="'};&#10;'" />
874
875
876 <xsl:call-template name="genImplList">
877 <xsl:with-param name="impl" select="$implName" />
878 <xsl:with-param name="name" select="@name" />
879 <xsl:with-param name="depth" select="'1'" />
880 <xsl:with-param name="parents" select="''" />
881 </xsl:call-template>
882
883 <!-- Associate public functions. -->
884 <xsl:variable name="evname">
885 <xsl:value-of select="substring(@name, 2)" />
886 </xsl:variable>
887 <xsl:variable name="evid">
888 <xsl:value-of select="concat('On', substring(@name, 2, string-length(@name)-6))" />
889 </xsl:variable>
890 <xsl:variable name="ifname">
891 <xsl:value-of select="@name" />
892 </xsl:variable>
893 <xsl:variable name="waitable">
894 <xsl:choose>
895 <xsl:when test="@waitable='yes'">
896 <xsl:value-of select="'TRUE'"/>
897 </xsl:when>
898 <xsl:otherwise>
899 <xsl:value-of select="'FALSE'"/>
900 </xsl:otherwise>
901 </xsl:choose>
902 </xsl:variable>
903 <xsl:variable name="hasStringAttribs">
904 <xsl:call-template name="hasStringAttributes">
905 <xsl:with-param name="name" select="@name"/>
906 </xsl:call-template>
907 </xsl:variable>
908
909 <!-- Generate ReinitXxxxEvent functions if reusable. -->
910 <xsl:if test="$isReusable='yes'">
911 <xsl:call-template name="genReinitFunction">
912 <xsl:with-param name="name" select="@name"/>
913 <xsl:with-param name="evname" select="$evname"/>
914 <xsl:with-param name="ifname" select="$ifname"/>
915 <xsl:with-param name="implName" select="$implName"/>
916 <xsl:with-param name="utf8str" select="'yes'"/>
917 </xsl:call-template>
918
919 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
920 <xsl:call-template name="genReinitFunction">
921 <xsl:with-param name="name" select="@name"/>
922 <xsl:with-param name="evname" select="$evname"/>
923 <xsl:with-param name="ifname" select="$ifname"/>
924 <xsl:with-param name="implName" select="$implName"/>
925 <xsl:with-param name="utf8str" select="'no'"/>
926 </xsl:call-template>
927 </xsl:if>
928 </xsl:if>
929
930 <!-- Generate the CreateXxxxEvent function. -->
931 <xsl:call-template name="genCreateFunction">
932 <xsl:with-param name="name" select="@name"/>
933 <xsl:with-param name="evname" select="$evname"/>
934 <xsl:with-param name="ifname" select="$ifname"/>
935 <xsl:with-param name="implName" select="$implName"/>
936 <xsl:with-param name="waitable" select="$waitable"/>
937 <xsl:with-param name="evid" select="$evid"/>
938 <xsl:with-param name="utf8str" select="'yes'"/>
939 </xsl:call-template>
940
941 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
942 <xsl:call-template name="genCreateFunction">
943 <xsl:with-param name="name" select="@name"/>
944 <xsl:with-param name="evname" select="$evname"/>
945 <xsl:with-param name="ifname" select="$ifname"/>
946 <xsl:with-param name="implName" select="$implName"/>
947 <xsl:with-param name="waitable" select="$waitable"/>
948 <xsl:with-param name="evid" select="$evid"/>
949 <xsl:with-param name="utf8str" select="'no'"/>
950 </xsl:call-template>
951 </xsl:if>
952
953 <!-- Generate the FireXxxxEvent function. -->
954 <xsl:call-template name="genFireFunction">
955 <xsl:with-param name="evname" select="$evname"/>
956 <xsl:with-param name="ifname" select="$ifname"/>
957 <xsl:with-param name="utf8str" select="'yes'"/>
958 </xsl:call-template>
959
960 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
961 <xsl:call-template name="genFireFunction">
962 <xsl:with-param name="evname" select="$evname"/>
963 <xsl:with-param name="ifname" select="$ifname"/>
964 <xsl:with-param name="utf8str" select="'no'"/>
965 </xsl:call-template>
966 </xsl:if>
967
968</xsl:template>
969
970
971<!--
972 Produces VBoxEvents.cpp
973 -->
974<xsl:template name="genCommonEventCode">
975 <xsl:call-template name="fileheader">
976 <xsl:with-param name="name" select="'VBoxEvents.cpp'" />
977 </xsl:call-template>
978
979<xsl:text><![CDATA[
980#define LOG_GROUP LOG_GROUP_MAIN_EVENT
981#include <VBox/com/array.h>
982#include <VBox/log.h>
983#include <iprt/asm.h>
984#include "VBoxEvents.h"
985
986]]></xsl:text>
987
988 <!-- Interfaces -->
989 <xsl:for-each select="//interface[@autogen=$G_kind]">
990 <xsl:value-of select="concat('// ', @name, ' implementation code')" />
991 <xsl:call-template name="xsltprocNewlineOutputHack"/>
992 <xsl:variable name="implName">
993 <xsl:value-of select="substring(@name, 2)" />
994 </xsl:variable>
995
996 <xsl:choose>
997 <xsl:when test="$G_kind='VBoxEvent'">
998 <xsl:variable name="isVeto">
999 <xsl:if test="@extends='IVetoEvent'">
1000 <xsl:value-of select="'yes'" />
1001 </xsl:if>
1002 </xsl:variable>
1003 <xsl:variable name="isReusable">
1004 <xsl:if test="@extends='IReusableEvent'">
1005 <xsl:value-of select="'yes'" />
1006 </xsl:if>
1007 </xsl:variable>
1008 <xsl:call-template name="genEventImpl">
1009 <xsl:with-param name="implName" select="$implName" />
1010 <xsl:with-param name="isVeto" select="$isVeto" />
1011 <xsl:with-param name="isReusable" select="$isReusable" />
1012 </xsl:call-template>
1013 </xsl:when>
1014 </xsl:choose>
1015 </xsl:for-each>
1016
1017</xsl:template>
1018
1019
1020<!--
1021 Produces VBoxEvents.h
1022 -->
1023<xsl:template name="genCommonEventHeader">
1024 <xsl:call-template name="fileheader">
1025 <xsl:with-param name="name" select="'VBoxEvents.h'" />
1026 </xsl:call-template>
1027
1028 <xsl:text><![CDATA[
1029#include "EventImpl.h"
1030
1031]]></xsl:text>
1032
1033 <!-- Simple methods for firing off events. -->
1034 <xsl:text>/** @name Fire off events&#10;</xsl:text>
1035 <xsl:text> * @{ */&#10;</xsl:text>
1036 <xsl:for-each select="//interface[@autogen='VBoxEvent']">
1037 <xsl:value-of select="concat('/** Fire an ', @name, ' event. */&#10;')" />
1038 <xsl:variable name="evname">
1039 <xsl:value-of select="substring(@name, 2)" />
1040 </xsl:variable>
1041 <xsl:variable name="ifname">
1042 <xsl:value-of select="@name" />
1043 </xsl:variable>
1044 <xsl:variable name="hasStringAttribs">
1045 <xsl:call-template name="hasStringAttributes">
1046 <xsl:with-param name="name" select="@name"/>
1047 </xsl:call-template>
1048 </xsl:variable>
1049
1050 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
1051 <xsl:call-template name="genFormalParams">
1052 <xsl:with-param name="name" select="$ifname" />
1053 <xsl:with-param name="utf8str" select="'yes'" />
1054 </xsl:call-template>
1055 <xsl:text>);&#10;</xsl:text>
1056
1057 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
1058 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Fire', $evname, '(IEventSource *aSource')"/>
1059 <xsl:call-template name="genFormalParams">
1060 <xsl:with-param name="name" select="$ifname" />
1061 <xsl:with-param name="utf8str" select="'no'" />
1062 </xsl:call-template>
1063 <xsl:text>);&#10;</xsl:text>
1064 </xsl:if>
1065 </xsl:for-each>
1066 <xsl:text>/** @} */&#10;&#10;</xsl:text>
1067
1068 <!-- Event instantiation methods. -->
1069 <xsl:text>/** @name Instantiate events&#10;</xsl:text>
1070 <xsl:text> * @{ */&#10;</xsl:text>
1071 <xsl:for-each select="//interface[@autogen='VBoxEvent']">
1072 <xsl:value-of select="concat('/** Create an ', @name, ' event. */&#10;')" />
1073 <xsl:variable name="evname">
1074 <xsl:value-of select="substring(@name, 2)" />
1075 </xsl:variable>
1076 <xsl:variable name="ifname">
1077 <xsl:value-of select="@name" />
1078 </xsl:variable>
1079 <xsl:variable name="hasStringAttribs">
1080 <xsl:call-template name="hasStringAttributes">
1081 <xsl:with-param name="name" select="@name"/>
1082 </xsl:call-template>
1083 </xsl:variable>
1084
1085 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
1086 <xsl:call-template name="genFormalParams">
1087 <xsl:with-param name="name" select="$ifname" />
1088 <xsl:with-param name="utf8str" select="'yes'" />
1089 </xsl:call-template>
1090 <xsl:text>);&#10;</xsl:text>
1091
1092 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
1093 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Create', $evname, '(IEvent **aEvent, IEventSource *aSource')"/>
1094 <xsl:call-template name="genFormalParams">
1095 <xsl:with-param name="name" select="$ifname" />
1096 <xsl:with-param name="utf8str" select="'no'" />
1097 </xsl:call-template>
1098 <xsl:text>);&#10;</xsl:text>
1099 </xsl:if>
1100 </xsl:for-each>
1101 <xsl:text>/** @} */&#10;</xsl:text>
1102 <xsl:text>&#10;</xsl:text>
1103
1104 <!-- Reinitialization methods for reusable events. -->
1105 <xsl:text>/** @name Re-init reusable events&#10;</xsl:text>
1106 <xsl:text> * @{ */&#10;</xsl:text>
1107 <xsl:for-each select="//interface[@autogen='VBoxEvent']">
1108 <xsl:if test="@extends='IReusableEvent'">
1109 <xsl:value-of select="concat('/** Re-init an ', @name, ' event. */&#10;')" />
1110 <xsl:variable name="evname">
1111 <xsl:value-of select="substring(@name, 2)" />
1112 </xsl:variable>
1113 <xsl:variable name="ifname">
1114 <xsl:value-of select="@name" />
1115 </xsl:variable>
1116 <xsl:variable name="hasStringAttribs">
1117 <xsl:call-template name="hasStringAttributes">
1118 <xsl:with-param name="name" select="@name"/>
1119 </xsl:call-template>
1120 </xsl:variable>
1121
1122 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
1123 <xsl:call-template name="genFormalParams">
1124 <xsl:with-param name="name" select="$ifname" />
1125 <xsl:with-param name="utf8str" select="'yes'" />
1126 </xsl:call-template>
1127 <xsl:text>);&#10;</xsl:text>
1128
1129 <xsl:if test="($hasStringAttribs != '') and (($G_generateBstrVariants = 'yes') or (contains(@autogenflags, 'BSTR')))">
1130 <xsl:value-of select="concat('DECLHIDDEN(HRESULT) Reinit', $evname, '(IEvent *aEvent')"/>
1131 <xsl:call-template name="genFormalParams">
1132 <xsl:with-param name="name" select="$ifname" />
1133 <xsl:with-param name="utf8str" select="'no'" />
1134 </xsl:call-template>
1135 <xsl:text>);&#10;</xsl:text>
1136 </xsl:if>
1137 </xsl:if>
1138 </xsl:for-each>
1139 <xsl:text>/** @} */&#10;</xsl:text>
1140
1141</xsl:template>
1142
1143<xsl:template match="/">
1144 <!-- Global code -->
1145 <xsl:choose>
1146 <xsl:when test="$G_kind='VBoxEvent'">
1147 <xsl:call-template name="genCommonEventCode">
1148 </xsl:call-template>
1149 </xsl:when>
1150 <xsl:when test="$G_kind='VBoxEventHeader'">
1151 <xsl:call-template name="genCommonEventHeader">
1152 </xsl:call-template>
1153 </xsl:when>
1154 <xsl:otherwise>
1155 <xsl:call-template name="fatalError">
1156 <xsl:with-param name="msg" select="concat('Request unsupported: ', $G_kind)" />
1157 </xsl:call-template>
1158 </xsl:otherwise>
1159 </xsl:choose>
1160</xsl:template>
1161
1162</xsl:stylesheet>
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