VirtualBox

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

Last change on this file since 33238 was 33063, checked in by vboxsync, 14 years ago

windows burn

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.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 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="../webservice/websrv-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
38<xsl:template name="fileheader">
39 <xsl:param name="name" />
40 <xsl:text>/**
41 * Copyright (C) 2010 Oracle Corporation
42 *
43 * This file is part of VirtualBox Open Source Edition (OSE), as
44 * available from http://www.virtualbox.org. This file is free software;
45 * you can redistribute it and/or modify it under the terms of the GNU
46 * General Public License (GPL) as published by the Free Software
47 * Foundation, in version 2 as it comes in the "COPYING" file of the
48 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
49 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
50 *
51</xsl:text>
52 <xsl:value-of select="concat(' * ',$name)"/>
53<xsl:text>
54 *
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/autogen.xsl
58 */
59
60</xsl:text>
61</xsl:template>
62
63<xsl:template name="genComEntry">
64 <xsl:param name="name" />
65 <xsl:variable name="extends">
66 <xsl:value-of select="//interface[@name=$name]/@extends" />
67 </xsl:variable>
68
69 <xsl:value-of select="concat(' COM_INTERFACE_ENTRY(', $name, ')&#10;')" />
70 <xsl:choose>
71 <xsl:when test="$extends='$unknown'">
72 <xsl:value-of select=" ' COM_INTERFACE_ENTRY(IDispatch)&#10;'" />
73 </xsl:when>
74 <xsl:when test="//interface[@name=$extends]">
75 <xsl:call-template name="genComEntry">
76 <xsl:with-param name="name" select="$extends" />
77 </xsl:call-template>
78 </xsl:when>
79 <xsl:otherwise>
80 <xsl:call-template name="fatalError">
81 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $extends)" />
82 </xsl:call-template>
83 </xsl:otherwise>
84 </xsl:choose>
85</xsl:template>
86
87<xsl:template name="typeIdl2Back">
88 <xsl:param name="type" />
89 <xsl:param name="safearray" />
90 <xsl:param name="param" />
91 <xsl:param name="dir" />
92 <xsl:param name="mod" />
93
94 <xsl:choose>
95 <xsl:when test="$safearray='yes'">
96 <xsl:variable name="elemtype">
97 <xsl:call-template name="typeIdl2Back">
98 <xsl:with-param name="type" select="$type" />
99 <xsl:with-param name="safearray" select="''" />
100 <xsl:with-param name="dir" select="'in'" />
101 </xsl:call-template>
102 </xsl:variable>
103 <xsl:choose>
104 <xsl:when test="$param and ($dir='in')">
105 <xsl:value-of select="concat('ComSafeArrayIn(',$elemtype,',', $param,')')"/>
106 </xsl:when>
107 <xsl:when test="$param and ($dir='out')">
108 <xsl:value-of select="concat('ComSafeArrayOut(',$elemtype,', ', $param, ')')"/>
109 </xsl:when>
110 <xsl:otherwise>
111 <xsl:value-of select="concat('com::SafeArray&lt;',$elemtype,'&gt;')"/>
112 </xsl:otherwise>
113 </xsl:choose>
114 </xsl:when>
115 <xsl:otherwise>
116 <xsl:choose>
117 <xsl:when test="$mod='ptr'">
118 <xsl:value-of select="'BYTE*'" />
119 </xsl:when>
120 <xsl:when test="(($type='wstring') or ($type='uuid')) and $param">
121 <xsl:value-of select="'BSTR'" />
122 </xsl:when>
123 <xsl:when test="(($type='wstring') or ($type='uuid')) and not($param)">
124 <xsl:value-of select="'Bstr'" />
125 </xsl:when>
126 <xsl:when test="//enum[@name=$type]">
127 <xsl:value-of select="concat($type,'_T')"/>
128 </xsl:when>
129 <xsl:when test="//interface[@name=$type]">
130 <xsl:choose>
131 <xsl:when test="$param">
132 <xsl:value-of select="concat($type,'*')"/>
133 </xsl:when>
134 <xsl:otherwise>
135 <xsl:value-of select="concat('ComPtr&lt;',$type,'&gt;')"/>
136 </xsl:otherwise>
137 </xsl:choose>
138 </xsl:when>
139 <xsl:when test="$type='boolean'">
140 <xsl:value-of select="'BOOL'" />
141 </xsl:when>
142 <xsl:when test="$type='octet'">
143 <xsl:value-of select="'BYTE'" />
144 </xsl:when>
145 <xsl:when test="$type='unsigned long'">
146 <xsl:value-of select="'ULONG'" />
147 </xsl:when>
148 <xsl:when test="$type='long'">
149 <xsl:value-of select="'LONG'" />
150 </xsl:when>
151 <xsl:when test="$type='unsigned long long'">
152 <xsl:value-of select="'ULONG64'" />
153 </xsl:when>
154 <xsl:when test="$type='long long'">
155 <xsl:value-of select="'LONG64'" />
156 </xsl:when>
157 <xsl:otherwise>
158 <xsl:call-template name="fatalError">
159 <xsl:with-param name="msg" select="concat('Unhandled type: ', $type)" />
160 </xsl:call-template>
161 </xsl:otherwise>
162 </xsl:choose>
163 <xsl:if test="$dir='out'">
164 <xsl:value-of select="'*'"/>
165 </xsl:if>
166 <xsl:if test="$param and not($param='_')">
167 <xsl:value-of select="concat(' ', $param)"/>
168 </xsl:if>
169 </xsl:otherwise>
170 </xsl:choose>
171
172</xsl:template>
173
174
175<xsl:template name="genSetParam">
176 <xsl:param name="member"/>
177 <xsl:param name="param"/>
178 <xsl:param name="type"/>
179 <xsl:param name="safearray"/>
180
181 <xsl:choose>
182 <xsl:when test="$safearray='yes'">
183 <xsl:variable name="elemtype">
184 <xsl:call-template name="typeIdl2Back">
185 <xsl:with-param name="type" select="@type" />
186 <xsl:with-param name="safearray" select="''" />
187 <xsl:with-param name="dir" select="'in'" />
188 </xsl:call-template>
189 </xsl:variable>
190 <xsl:value-of select="concat(' SafeArray&lt;', $elemtype, '&gt; aArr(ComSafeArrayInArg(',$param,'));&#10;')"/>
191 <xsl:value-of select="concat(' ',$member, '.initFrom(aArr);&#10;')"/>
192 </xsl:when>
193 <xsl:otherwise>
194 <xsl:value-of select="concat(' ', $member, ' = ', $param, ';&#10;')"/>
195 </xsl:otherwise>
196 </xsl:choose>
197</xsl:template>
198
199<xsl:template name="genRetParam">
200 <xsl:param name="member"/>
201 <xsl:param name="param"/>
202 <xsl:param name="type"/>
203 <xsl:param name="safearray"/>
204 <xsl:choose>
205 <xsl:when test="$safearray='yes'">
206 <xsl:variable name="elemtype">
207 <xsl:call-template name="typeIdl2Back">
208 <xsl:with-param name="type" select="@type" />
209 <xsl:with-param name="safearray" select="''" />
210 <xsl:with-param name="dir" select="'in'" />
211 </xsl:call-template>
212 </xsl:variable>
213 <xsl:value-of select="concat(' SafeArray&lt;', $elemtype,'&gt; result;&#10;')"/>
214 <xsl:value-of select="concat(' ', $member, '.cloneTo(result);&#10;')"/>
215 <xsl:value-of select="concat(' result.detachTo(ComSafeArrayOutArg(', $param, '));&#10;')"/>
216 </xsl:when>
217 <xsl:otherwise>
218 <xsl:choose>
219 <xsl:when test="($type='wstring') or ($type = 'uuid')">
220 <xsl:value-of select="concat(' ', $member, '.cloneTo(', $param, ');&#10;')"/>
221 </xsl:when>
222 <xsl:when test="//interface[@name=$type]">
223 <xsl:value-of select="concat(' ', $member, '.queryInterfaceTo(', $param, ');&#10;')"/>
224 </xsl:when>
225 <xsl:otherwise>
226 <xsl:value-of select="concat(' *', $param, ' = ', $member, ';&#10;')"/>
227 </xsl:otherwise>
228 </xsl:choose>
229 </xsl:otherwise>
230 </xsl:choose>
231</xsl:template>
232
233<xsl:template name="genAttrInitCode">
234 <xsl:param name="name" />
235 <xsl:param name="obj" />
236 <xsl:variable name="extends">
237 <xsl:value-of select="//interface[@name=$name]/@extends" />
238 </xsl:variable>
239
240 <xsl:choose>
241 <xsl:when test="$extends='IEvent'">
242 </xsl:when>
243 <xsl:when test="$extends='IReusableEvent'">
244 </xsl:when>
245 <xsl:when test="//interface[@name=$extends]">
246 <xsl:call-template name="genAttrInitCode">
247 <xsl:with-param name="name" select="$extends" />
248 <xsl:with-param name="obj" select="$obj" />
249 </xsl:call-template>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:call-template name="fatalError">
253 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
254 </xsl:call-template>
255 </xsl:otherwise>
256 </xsl:choose>
257
258 <xsl:for-each select="//interface[@name=$name]/attribute">
259 <xsl:variable name="aName" select="concat('a_',@name)"/>
260 <xsl:variable name="aTypeName">
261 <xsl:call-template name="typeIdl2Back">
262 <xsl:with-param name="type" select="@type" />
263 <xsl:with-param name="safearray" select="@safearray" />
264 <xsl:with-param name="param" select="$aName" />
265 <xsl:with-param name="dir" select="'in'" />
266 <xsl:with-param name="mod" select="@mod" />
267 </xsl:call-template>
268 </xsl:variable>
269 <xsl:variable name="aType">
270 <xsl:call-template name="typeIdl2Back">
271 <xsl:with-param name="type" select="@type" />
272 <xsl:with-param name="safearray" select="@safearray" />
273 <xsl:with-param name="param" select="'_'" />
274 <xsl:with-param name="dir" select="'in'" />
275 <xsl:with-param name="mod" select="@mod" />
276 </xsl:call-template>
277 </xsl:variable>
278
279 <xsl:choose>
280 <xsl:when test="@safearray='yes'">
281 <xsl:variable name="elemtype">
282 <xsl:call-template name="typeIdl2Back">
283 <xsl:with-param name="type" select="@type" />
284 <xsl:with-param name="safearray" select="''" />
285 <xsl:with-param name="dir" select="'in'" />
286 </xsl:call-template>
287 </xsl:variable>
288 <xsl:value-of select=" '#ifdef RT_OS_WINDOWS&#10;'"/>
289 <xsl:value-of select=" ' SAFEARRAY ** aPtr = va_arg(args, SAFEARRAY **);&#10;'"/>
290 <xsl:value-of select="concat(' com::SafeArray&lt;', $elemtype,'&gt; aArr(aPtr);&#10;')"/>
291 <xsl:value-of select=" '#else&#10;'"/>
292 <xsl:value-of select=" ' PRUint32 aArrSize = va_arg(args, PRUint32);&#10;'"/>
293 <xsl:value-of select=" ' void* aPtr = va_arg(args, void*);&#10;'"/>
294 <xsl:value-of select="concat(' com::SafeArray&lt;', $elemtype,'&gt; aArr(aArrSize, (', $elemtype,'*)aPtr);&#10;')"/>
295 <xsl:value-of select=" '#endif&#10;'"/>
296 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(ComSafeArrayAsInParam(aArr));&#10;')"/>
297 </xsl:when>
298 <xsl:otherwise>
299 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,');&#10;')"/>
300 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, ');&#10;')"/>
301 </xsl:otherwise>
302 </xsl:choose>
303 </xsl:for-each>
304</xsl:template>
305
306<xsl:template name="genImplList">
307 <xsl:param name="impl" />
308 <xsl:param name="name" />
309 <xsl:param name="depth" />
310 <xsl:param name="parents" />
311
312 <xsl:variable name="extends">
313 <xsl:value-of select="//interface[@name=$name]/@extends" />
314 </xsl:variable>
315
316 <xsl:choose>
317 <xsl:when test="$extends='IEvent'">
318 <xsl:value-of select=" '#ifdef VBOX_WITH_XPCOM&#10;'" />
319 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', $impl, ')&#10;')" />
320 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS',$depth,'_CI(', $impl, ', ', $name, $parents, ', IEvent)&#10;')" />
321 <xsl:value-of select=" '#endif&#10;&#10;'"/>
322 </xsl:when>
323 <xsl:when test="//interface[@name=$extends]">
324 <xsl:call-template name="genImplList">
325 <xsl:with-param name="impl" select="$impl" />
326 <xsl:with-param name="name" select="$extends" />
327 <xsl:with-param name="depth" select="$depth+1" />
328 <xsl:with-param name="parents" select="concat($parents, ', ', @name)" />
329 </xsl:call-template>
330 </xsl:when>
331 <xsl:otherwise>
332 <xsl:call-template name="fatalError">
333 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
334 </xsl:call-template>
335 </xsl:otherwise>
336 </xsl:choose>
337</xsl:template>
338
339<xsl:template name="genAttrCode">
340 <xsl:param name="name" />
341 <xsl:param name="depth" />
342 <xsl:param name="parents" />
343
344 <xsl:variable name="extends">
345 <xsl:value-of select="//interface[@name=$name]/@extends" />
346 </xsl:variable>
347
348 <xsl:for-each select="//interface[@name=$name]/attribute">
349 <xsl:variable name="mName">
350 <xsl:value-of select="concat('m_', @name)" />
351 </xsl:variable>
352 <xsl:variable name="mType">
353 <xsl:call-template name="typeIdl2Back">
354 <xsl:with-param name="type" select="@type" />
355 <xsl:with-param name="safearray" select="@safearray" />
356 <xsl:with-param name="dir" select="'in'" />
357 <xsl:with-param name="mod" select="@mod" />
358 </xsl:call-template>
359 </xsl:variable>
360 <xsl:variable name="pName">
361 <xsl:value-of select="concat('a_', @name)" />
362 </xsl:variable>
363 <xsl:variable name="pTypeNameOut">
364 <xsl:call-template name="typeIdl2Back">
365 <xsl:with-param name="type" select="@type" />
366 <xsl:with-param name="safearray" select="@safearray" />
367 <xsl:with-param name="param" select="$pName" />
368 <xsl:with-param name="dir" select="'out'" />
369 <xsl:with-param name="mod" select="@mod" />
370 </xsl:call-template>
371 </xsl:variable>
372
373 <xsl:variable name="pTypeNameIn">
374 <xsl:call-template name="typeIdl2Back">
375 <xsl:with-param name="type" select="@type" />
376 <xsl:with-param name="safearray" select="@safearray" />
377 <xsl:with-param name="param" select="$pName" />
378 <xsl:with-param name="dir" select="'in'" />
379 <xsl:with-param name="mod" select="@mod" />
380 </xsl:call-template>
381 </xsl:variable>
382
383 <xsl:variable name="capsName">
384 <xsl:call-template name="capitalize">
385 <xsl:with-param name="str" select="@name" />
386 </xsl:call-template>
387 </xsl:variable>
388
389 <xsl:value-of select=" '&#10;'" />
390 <xsl:value-of select="concat(' // attribute ', @name,'&#10;')" />
391 <xsl:value-of select=" 'private:&#10;'" />
392 <xsl:value-of select="concat(' ', $mType, ' ', $mName,';&#10;')" />
393 <xsl:value-of select=" 'public:&#10;'" />
394 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,')&#10; {&#10;')" />
395 <xsl:call-template name="genRetParam">
396 <xsl:with-param name="type" select="@type" />
397 <xsl:with-param name="member" select="$mName" />
398 <xsl:with-param name="param" select="$pName" />
399 <xsl:with-param name="safearray" select="@safearray" />
400 </xsl:call-template>
401 <xsl:value-of select=" ' return S_OK;&#10;'" />
402 <xsl:value-of select=" ' }&#10;'" />
403
404 <xsl:if test="not(@readonly='yes')">
405 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,')&#10; {&#10;')" />
406 <xsl:call-template name="genSetParam">
407 <xsl:with-param name="type" select="@type" />
408 <xsl:with-param name="member" select="$mName" />
409 <xsl:with-param name="param" select="$pName" />
410 <xsl:with-param name="safearray" select="@safearray" />
411 </xsl:call-template>
412 <xsl:value-of select=" ' return S_OK;&#10;'" />
413 <xsl:value-of select=" ' }&#10;'" />
414 </xsl:if>
415
416 <xsl:value-of select=" ' // purely internal setter&#10;'" />
417 <xsl:value-of select="concat(' HRESULT set_', @name,'(',$pTypeNameIn, ')&#10; {&#10;')" />
418 <xsl:call-template name="genSetParam">
419 <xsl:with-param name="type" select="@type" />
420 <xsl:with-param name="member" select="$mName" />
421 <xsl:with-param name="param" select="$pName" />
422 <xsl:with-param name="safearray" select="@safearray" />
423 </xsl:call-template>
424 <xsl:value-of select=" ' return S_OK;&#10;'" />
425 <xsl:value-of select=" ' }&#10;'" />
426 </xsl:for-each>
427
428 <xsl:choose>
429 <xsl:when test="$extends='IEvent'">
430 <xsl:value-of select=" ' // skipping IEvent attributes &#10;'" />
431 </xsl:when>
432 <xsl:when test="$extends='IReusableEvent'">
433 <xsl:value-of select=" ' // skipping IReusableEvent attributes &#10;'" />
434 </xsl:when>
435 <xsl:when test="$extends='IVetoEvent'">
436 <xsl:value-of select=" ' // skipping IVetoEvent attributes &#10;'" />
437 </xsl:when>
438 <xsl:when test="//interface[@name=$extends]">
439 <xsl:call-template name="genAttrCode">
440 <xsl:with-param name="name" select="$extends" />
441 <xsl:with-param name="depth" select="$depth+1" />
442 <xsl:with-param name="parents" select="concat($parents, ', ', @name)" />
443 </xsl:call-template>
444 </xsl:when>
445 <xsl:otherwise>
446 <xsl:call-template name="fatalError">
447 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $extends)" />
448 </xsl:call-template>
449 </xsl:otherwise>
450 </xsl:choose>
451</xsl:template>
452
453<xsl:template name="genEventImpl">
454 <xsl:param name="implName" />
455 <xsl:param name="isVeto" />
456 <xsl:param name="isReusable" />
457
458 <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName,
459 '&#10; : public VirtualBoxBase,&#10; VBOX_SCRIPTABLE_IMPL(',
460 @name, ')&#10;{&#10;')" />
461 <xsl:value-of select="'public:&#10;'" />
462 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', $implName, ', ', @name, ')&#10;')" />
463 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', $implName, ')&#10;')" />
464 <xsl:value-of select=" ' DECLARE_PROTECT_FINAL_CONSTRUCT()&#10;'" />
465 <xsl:value-of select="concat(' BEGIN_COM_MAP(', $implName, ')&#10;')" />
466 <xsl:call-template name="genComEntry">
467 <xsl:with-param name="name" select="@name" />
468 </xsl:call-template>
469 <xsl:value-of select=" ' END_COM_MAP()&#10;'" />
470 <xsl:value-of select="concat(' ',$implName,'() { /*printf(&quot;',$implName,'\n&quot;)*/;}&#10;')" />
471 <xsl:value-of select="concat(' virtual ~',$implName,'() { /*printf(&quot;~',$implName,'\n&quot;)*/; uninit(); }&#10;')" />
472 <xsl:text><![CDATA[
473 HRESULT FinalConstruct()
474 {
475 return mEvent.createObject();
476 }
477 void FinalRelease()
478 {
479 mEvent->FinalRelease();
480 }
481 STDMETHOD(COMGETTER(Type)) (VBoxEventType_T *aType)
482 {
483 return ((VBoxEvent*)mEvent)->COMGETTER(Type) (aType);
484 }
485 STDMETHOD(COMGETTER(Source)) (IEventSource * *aSource)
486 {
487 return ((VBoxEvent*)mEvent)->COMGETTER(Source) (aSource);
488 }
489 STDMETHOD(COMGETTER(Waitable)) (BOOL *aWaitable)
490 {
491 return ((VBoxEvent*)mEvent)->COMGETTER(Waitable) (aWaitable);
492 }
493 STDMETHOD(SetProcessed)()
494 {
495 return ((VBoxEvent*)mEvent)->SetProcessed();
496 }
497 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult)
498 {
499 return ((VBoxEvent*)mEvent)->WaitProcessed(aTimeout, aResult);
500 }
501 void uninit()
502 {
503 if (!mEvent.isNull())
504 {
505 mEvent->uninit();
506 mEvent.setNull();
507 }
508 }
509]]></xsl:text>
510 <xsl:choose>
511 <xsl:when test="$isVeto='yes'">
512<xsl:text><![CDATA[
513 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)
514 {
515 NOREF(aWaitable);
516 return mEvent->init(aSource, aType);
517 }
518 STDMETHOD(AddVeto)(IN_BSTR aVeto)
519 {
520 return mEvent->AddVeto(aVeto);
521 }
522 STDMETHOD(IsVetoed)(BOOL *aResult)
523 {
524 return mEvent->IsVetoed(aResult);
525 }
526 STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos))
527 {
528 return mEvent->GetVetos(ComSafeArrayOutArg(aVetos));
529 }
530private:
531 ComObjPtr<VBoxVetoEvent> mEvent;
532]]></xsl:text>
533 </xsl:when>
534 <xsl:when test="$isReusable='yes'">
535 <xsl:text>
536<![CDATA[
537 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = FALSE)
538 {
539 mGeneration = 1;
540 return mEvent->init(aSource, aType, aWaitable);
541 }
542 STDMETHOD(COMGETTER(Generation)) (ULONG *aGeneration)
543 {
544 *aGeneration = mGeneration;
545 return S_OK;
546 }
547 STDMETHOD(Reuse) ()
548 {
549 ASMAtomicIncU32((volatile uint32_t*)&mGeneration);
550 return S_OK;
551 }
552private:
553 volatile ULONG mGeneration;
554 ComObjPtr<VBoxEvent> mEvent;
555]]></xsl:text>
556 </xsl:when>
557 <xsl:otherwise>
558<xsl:text><![CDATA[
559 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable)
560 {
561 return mEvent->init(aSource, aType, aWaitable);
562 }
563private:
564 ComObjPtr<VBoxEvent> mEvent;
565]]></xsl:text>
566 </xsl:otherwise>
567 </xsl:choose>
568 <xsl:call-template name="genAttrCode">
569 <xsl:with-param name="name" select="@name" />
570 </xsl:call-template>
571 <xsl:value-of select="'};&#10;'" />
572
573
574 <xsl:call-template name="genImplList">
575 <xsl:with-param name="impl" select="$implName" />
576 <xsl:with-param name="name" select="@name" />
577 <xsl:with-param name="depth" select="'2'" />
578 <xsl:with-param name="parents" select="''" />
579 </xsl:call-template>
580
581</xsl:template>
582
583
584<xsl:template name="genSwitchCase">
585 <xsl:param name="ifaceName" />
586 <xsl:param name="implName" />
587 <xsl:param name="reinit" />
588 <xsl:variable name="waitable">
589 <xsl:choose>
590 <xsl:when test="@waitable='yes'">
591 <xsl:value-of select="'TRUE'"/>
592 </xsl:when>
593 <xsl:otherwise>
594 <xsl:value-of select="'FALSE'"/>
595 </xsl:otherwise>
596 </xsl:choose>
597 </xsl:variable>
598 <xsl:value-of select="concat(' case VBoxEventType_', @id, ':&#10;')"/>
599 <xsl:value-of select=" ' {&#10;'"/>
600 <xsl:choose>
601 <xsl:when test="$reinit='yes'">
602 <xsl:value-of select="concat(' ComPtr&lt;', $ifaceName, '&gt; iobj;&#10;')"/>
603 <xsl:value-of select=" ' iobj = mEvent;&#10;'"/>
604 <xsl:value-of select=" ' Assert(!iobj.isNull());&#10;'"/>
605 <xsl:value-of select="concat(' ',$implName, '* obj = (', $implName, '*)(', $ifaceName, '*)iobj;&#10;')"/>
606 <xsl:value-of select=" ' obj->Reuse();&#10;'"/>
607 </xsl:when>
608 <xsl:otherwise>
609 <xsl:value-of select="concat(' ComObjPtr&lt;', $implName, '&gt; obj;&#10;')"/>
610 <xsl:value-of select=" ' obj.createObject();&#10;'"/>
611 <xsl:value-of select="concat(' obj->init(aSource, aType, ', $waitable, ');&#10;')"/>
612 </xsl:otherwise>
613 </xsl:choose>
614 <xsl:call-template name="genAttrInitCode">
615 <xsl:with-param name="name" select="@name" />
616 <xsl:with-param name="obj" select="'obj'" />
617 </xsl:call-template>
618 <xsl:if test="not($reinit='yes')">
619 <xsl:value-of select=" ' obj.queryInterfaceTo(mEvent.asOutParam());&#10;'"/>
620 </xsl:if>
621 <xsl:value-of select=" ' break;&#10;'"/>
622 <xsl:value-of select=" ' }&#10;'"/>
623</xsl:template>
624
625<xsl:template name="genCommonEventCode">
626 <xsl:text><![CDATA[
627HRESULT VBoxEventDesc::init(IEventSource* aSource, VBoxEventType_T aType, ...)
628{
629 va_list args;
630
631 mEventSource = aSource;
632 va_start(args, aType);
633 switch (aType)
634 {
635]]></xsl:text>
636
637 <xsl:for-each select="//interface[@autogen=$G_kind]">
638 <xsl:variable name="implName">
639 <xsl:value-of select="substring(@name, 2)" />
640 </xsl:variable>
641 <xsl:call-template name="genSwitchCase">
642 <xsl:with-param name="ifaceName" select="@name" />
643 <xsl:with-param name="implName" select="$implName" />
644 <xsl:with-param name="reinit" select="'no'" />
645 </xsl:call-template>
646 </xsl:for-each>
647
648 <xsl:text><![CDATA[
649 default:
650 AssertFailed();
651 }
652 va_end(args);
653
654 return S_OK;
655}
656]]></xsl:text>
657
658 <xsl:text><![CDATA[
659HRESULT VBoxEventDesc::reinit(VBoxEventType_T aType, ...)
660{
661 va_list args;
662
663 va_start(args, aType);
664 switch (aType)
665 {
666]]></xsl:text>
667
668 <xsl:for-each select="//interface[@autogen=$G_kind and @extends='IReusableEvent']">
669 <xsl:variable name="implName">
670 <xsl:value-of select="substring(@name, 2)" />
671 </xsl:variable>
672 <xsl:call-template name="genSwitchCase">
673 <xsl:with-param name="ifaceName" select="@name" />
674 <xsl:with-param name="implName" select="$implName" />
675 <xsl:with-param name="reinit" select="'yes'" />
676 </xsl:call-template>
677 </xsl:for-each>
678
679 <xsl:text><![CDATA[
680 default:
681 AssertFailed();
682 }
683 va_end(args);
684
685 return S_OK;
686}
687]]></xsl:text>
688
689</xsl:template>
690
691
692<xsl:template match="/">
693 <xsl:call-template name="fileheader">
694 <xsl:with-param name="name" select="'VBoxEvents.cpp'" />
695 </xsl:call-template>
696
697<xsl:text><![CDATA[
698#include <VBox/com/array.h>
699#include <iprt/asm.h>
700#include "EventImpl.h"
701]]></xsl:text>
702
703
704 <!-- Interfaces -->
705 <xsl:for-each select="//interface[@autogen=$G_kind]">
706 <xsl:value-of select="concat('// ', @name, ' implementation code &#10;')" />
707 <xsl:variable name="implName">
708 <xsl:value-of select="substring(@name, 2)" />
709 </xsl:variable>
710
711 <xsl:choose>
712 <xsl:when test="$G_kind='VBoxEvent'">
713 <xsl:variable name="isVeto">
714 <xsl:if test="@extends='IVetoEvent'">
715 <xsl:value-of select="'yes'" />
716 </xsl:if>
717 </xsl:variable>
718 <xsl:variable name="isReusable">
719 <xsl:if test="@extends='IReusableEvent'">
720 <xsl:value-of select="'yes'" />
721 </xsl:if>
722 </xsl:variable>
723 <xsl:call-template name="genEventImpl">
724 <xsl:with-param name="implName" select="$implName" />
725 <xsl:with-param name="isVeto" select="$isVeto" />
726 <xsl:with-param name="isReusable" select="$isReusable" />
727 </xsl:call-template>
728 </xsl:when>
729 </xsl:choose>
730 </xsl:for-each>
731
732 <!-- Global code -->
733 <xsl:choose>
734 <xsl:when test="$G_kind='VBoxEvent'">
735 <xsl:call-template name="genCommonEventCode">
736 </xsl:call-template>
737 </xsl:when>
738 </xsl:choose>
739</xsl:template>
740
741</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