VirtualBox

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

最後變更 在這個檔案從96407是 96407,由 vboxsync 提交於 3 年 前

scm copyright and license note update

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

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