VirtualBox

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

Last change on this file since 105305 was 103977, checked in by vboxsync, 9 months ago

Apply RT_OVERRIDE/NS_OVERRIDE where required to shut up clang.

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