VirtualBox

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

Last change on this file since 30825 was 30714, checked in by vboxsync, 15 years ago

Main: remove SupportErrorInfo template magic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.1 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
93 <xsl:choose>
94 <xsl:when test="$safearray='yes'">
95 <xsl:variable name="elemtype">
96 <xsl:call-template name="typeIdl2Back">
97 <xsl:with-param name="type" select="$type" />
98 <xsl:with-param name="safearray" select="''" />
99 <xsl:with-param name="dir" select="'in'" />
100 </xsl:call-template>
101 </xsl:variable>
102 <xsl:choose>
103 <xsl:when test="$param and ($dir='in')">
104 <xsl:value-of select="concat('ComSafeArrayIn(',$elemtype,',', $param,')')"/>
105 </xsl:when>
106 <xsl:when test="$param and ($dir='out')">
107 <xsl:value-of select="concat('ComSafeArrayOut(',$elemtype,', ', $param, ')')"/>
108 </xsl:when>
109 <xsl:otherwise>
110 <xsl:value-of select="concat('com::SafeArray&lt;',$elemtype,'&gt;')"/>
111 </xsl:otherwise>
112 </xsl:choose>
113 </xsl:when>
114 <xsl:otherwise>
115 <xsl:choose>
116 <xsl:when test="(($type='wstring') or ($type='uuid')) and $param">
117 <xsl:value-of select="'BSTR'" />
118 </xsl:when>
119 <xsl:when test="(($type='wstring') or ($type='uuid')) and not($param)">
120 <xsl:value-of select="'Bstr'" />
121 </xsl:when>
122 <xsl:when test="//enum[@name=$type]">
123 <xsl:value-of select="concat($type,'_T')"/>
124 </xsl:when>
125 <xsl:when test="//interface[@name=$type]">
126 <xsl:choose>
127 <xsl:when test="$param">
128 <xsl:value-of select="concat($type,'*')"/>
129 </xsl:when>
130 <xsl:otherwise>
131 <xsl:value-of select="concat('ComPtr&lt;',$type,'&gt;')"/>
132 </xsl:otherwise>
133 </xsl:choose>
134 </xsl:when>
135 <xsl:when test="$type='boolean'">
136 <xsl:value-of select="'BOOL'" />
137 </xsl:when>
138 <xsl:when test="$type='octet'">
139 <xsl:value-of select="'BYTE'" />
140 </xsl:when>
141 <xsl:when test="$type='unsigned long'">
142 <xsl:value-of select="'ULONG'" />
143 </xsl:when>
144 <xsl:when test="$type='long'">
145 <xsl:value-of select="'LONG'" />
146 </xsl:when>
147 <xsl:when test="$type='unsigned long long'">
148 <xsl:value-of select="'ULONG64'" />
149 </xsl:when>
150 <xsl:when test="$type='long long'">
151 <xsl:value-of select="'LONG64'" />
152 </xsl:when>
153 <xsl:otherwise>
154 <xsl:call-template name="fatalError">
155 <xsl:with-param name="msg" select="concat('Unhandled type: ', $type)" />
156 </xsl:call-template>
157 </xsl:otherwise>
158 </xsl:choose>
159 <xsl:if test="$dir='out'">
160 <xsl:value-of select="'*'"/>
161 </xsl:if>
162 <xsl:if test="$param and not($param='_')">
163 <xsl:value-of select="concat(' ', $param)"/>
164 </xsl:if>
165 </xsl:otherwise>
166 </xsl:choose>
167
168</xsl:template>
169
170
171<xsl:template name="genSetParam">
172 <xsl:param name="member"/>
173 <xsl:param name="param"/>
174 <xsl:param name="type"/>
175 <xsl:param name="safearray"/>
176
177 <xsl:choose>
178 <xsl:when test="$safearray='yes'">
179 <xsl:variable name="elemtype">
180 <xsl:call-template name="typeIdl2Back">
181 <xsl:with-param name="type" select="@type" />
182 <xsl:with-param name="safearray" select="''" />
183 <xsl:with-param name="dir" select="'in'" />
184 </xsl:call-template>
185 </xsl:variable>
186 <xsl:value-of select="concat(' SafeArray&lt;', $elemtype, '&gt; aArr(ComSafeArrayInArg(',$param,'));&#10;')"/>
187 <xsl:value-of select="concat(' ',$member, '.initFrom(aArr);&#10;')"/>
188 </xsl:when>
189 <xsl:otherwise>
190 <xsl:value-of select="concat(' ', $member, ' = ', $param, ';&#10;')"/>
191 </xsl:otherwise>
192 </xsl:choose>
193</xsl:template>
194
195<xsl:template name="genRetParam">
196 <xsl:param name="member"/>
197 <xsl:param name="param"/>
198 <xsl:param name="type"/>
199 <xsl:param name="safearray"/>
200 <xsl:choose>
201 <xsl:when test="$safearray='yes'">
202 <xsl:variable name="elemtype">
203 <xsl:call-template name="typeIdl2Back">
204 <xsl:with-param name="type" select="@type" />
205 <xsl:with-param name="safearray" select="''" />
206 <xsl:with-param name="dir" select="'in'" />
207 </xsl:call-template>
208 </xsl:variable>
209 <xsl:value-of select="concat(' SafeArray&lt;', $elemtype,'&gt; result;&#10;')"/>
210 <xsl:value-of select="concat(' ', $member, '.cloneTo(result);&#10;')"/>
211 <xsl:value-of select="concat(' result.detachTo(ComSafeArrayOutArg(', $param, '));&#10;')"/>
212 </xsl:when>
213 <xsl:otherwise>
214 <xsl:choose>
215 <xsl:when test="($type='wstring') or ($type = 'uuid')">
216 <xsl:value-of select="concat(' ', $member, '.cloneTo(', $param, ');&#10;')"/>
217 </xsl:when>
218 <xsl:when test="//interface[@name=$type]">
219 <xsl:value-of select="concat(' ', $member, '.queryInterfaceTo(', $param, ');&#10;')"/>
220 </xsl:when>
221 <xsl:otherwise>
222 <xsl:value-of select="concat(' *', $param, ' = ', $member, ';&#10;')"/>
223 </xsl:otherwise>
224 </xsl:choose>
225 </xsl:otherwise>
226 </xsl:choose>
227</xsl:template>
228
229<xsl:template name="genAttrInitCode">
230 <xsl:param name="name" />
231 <xsl:param name="obj" />
232 <xsl:variable name="extends">
233 <xsl:value-of select="//interface[@name=$name]/@extends" />
234 </xsl:variable>
235
236 <xsl:choose>
237 <xsl:when test="$extends='IEvent'">
238 </xsl:when>
239 <xsl:when test="//interface[@name=$extends]">
240 <xsl:call-template name="genAttrInitCode">
241 <xsl:with-param name="name" select="$extends" />
242 <xsl:with-param name="obj" select="$obj" />
243 </xsl:call-template>
244 </xsl:when>
245 <xsl:otherwise>
246 <xsl:call-template name="fatalError">
247 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
248 </xsl:call-template>
249 </xsl:otherwise>
250 </xsl:choose>
251
252 <xsl:for-each select="//interface[@name=$name]/attribute">
253 <xsl:variable name="aName" select="concat('a_',@name)"/>
254 <xsl:variable name="aTypeName">
255 <xsl:call-template name="typeIdl2Back">
256 <xsl:with-param name="type" select="@type" />
257 <xsl:with-param name="safearray" select="@safearray" />
258 <xsl:with-param name="param" select="$aName" />
259 <xsl:with-param name="dir" select="'in'" />
260 </xsl:call-template>
261 </xsl:variable>
262 <xsl:variable name="aType">
263 <xsl:call-template name="typeIdl2Back">
264 <xsl:with-param name="type" select="@type" />
265 <xsl:with-param name="safearray" select="@safearray" />
266 <xsl:with-param name="param" select="'_'" />
267 <xsl:with-param name="dir" select="'in'" />
268 </xsl:call-template>
269 </xsl:variable>
270
271 <xsl:choose>
272 <xsl:when test="@safearray='yes'">
273 <xsl:variable name="elemtype">
274 <xsl:call-template name="typeIdl2Back">
275 <xsl:with-param name="type" select="@type" />
276 <xsl:with-param name="safearray" select="''" />
277 <xsl:with-param name="dir" select="'in'" />
278 </xsl:call-template>
279 </xsl:variable>
280 <xsl:value-of select=" '#ifdef RT_OS_WINDOWS&#10;'"/>
281 <xsl:value-of select=" ' SAFEARRAY ** aPtr = va_arg(args, SAFEARRAY **);&#10;'"/>
282 <xsl:value-of select="concat(' com::SafeArray&lt;', $elemtype,'&gt; aArr(aPtr);&#10;')"/>
283 <xsl:value-of select=" '#else&#10;'"/>
284 <xsl:value-of select=" ' PRUint32 aArrSize = va_arg(args, PRUint32);&#10;'"/>
285 <xsl:value-of select=" ' void* aPtr = va_arg(args, void*);&#10;'"/>
286 <xsl:value-of select="concat(' com::SafeArray&lt;', $elemtype,'&gt; aArr(aArrSize, (', $elemtype,'*)aPtr);&#10;')"/>
287 <xsl:value-of select=" '#endif&#10;'"/>
288 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(ComSafeArrayAsInParam(aArr));&#10;')"/>
289 </xsl:when>
290 <xsl:otherwise>
291 <xsl:value-of select="concat(' ',$aTypeName, ' = va_arg(args, ',$aType,');&#10;')"/>
292 <xsl:value-of select="concat(' ',$obj, '->set_', @name, '(',$aName, ');&#10;')"/>
293 </xsl:otherwise>
294 </xsl:choose>
295 </xsl:for-each>
296</xsl:template>
297
298<xsl:template name="genImplList">
299 <xsl:param name="impl" />
300 <xsl:param name="name" />
301 <xsl:param name="depth" />
302 <xsl:param name="parents" />
303
304 <xsl:variable name="extends">
305 <xsl:value-of select="//interface[@name=$name]/@extends" />
306 </xsl:variable>
307
308 <xsl:choose>
309 <xsl:when test="$extends='IEvent'">
310 <xsl:value-of select=" '#ifdef VBOX_WITH_XPCOM&#10;'" />
311 <xsl:value-of select="concat('NS_DECL_CLASSINFO(', $impl, ')&#10;')" />
312 <xsl:value-of select="concat('NS_IMPL_THREADSAFE_ISUPPORTS',$depth,'_CI(', $impl, ', ', $name, $parents, ', IEvent)&#10;')" />
313 <xsl:value-of select=" '#endif&#10;&#10;'"/>
314 </xsl:when>
315 <xsl:when test="//interface[@name=$extends]">
316 <xsl:call-template name="genImplList">
317 <xsl:with-param name="impl" select="$impl" />
318 <xsl:with-param name="name" select="$extends" />
319 <xsl:with-param name="depth" select="$depth+1" />
320 <xsl:with-param name="parents" select="concat($parents, ', ', @name)" />
321 </xsl:call-template>
322 </xsl:when>
323 <xsl:otherwise>
324 <xsl:call-template name="fatalError">
325 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $name)" />
326 </xsl:call-template>
327 </xsl:otherwise>
328 </xsl:choose>
329</xsl:template>
330
331<xsl:template name="genAttrCode">
332 <xsl:param name="name" />
333 <xsl:param name="depth" />
334 <xsl:param name="parents" />
335
336 <xsl:variable name="extends">
337 <xsl:value-of select="//interface[@name=$name]/@extends" />
338 </xsl:variable>
339
340 <xsl:for-each select="//interface[@name=$name]/attribute">
341 <xsl:variable name="mName">
342 <xsl:value-of select="concat('m_', @name)" />
343 </xsl:variable>
344 <xsl:variable name="mType">
345 <xsl:call-template name="typeIdl2Back">
346 <xsl:with-param name="type" select="@type" />
347 <xsl:with-param name="safearray" select="@safearray" />
348 <xsl:with-param name="dir" select="'in'" />
349 </xsl:call-template>
350 </xsl:variable>
351 <xsl:variable name="pName">
352 <xsl:value-of select="concat('a_', @name)" />
353 </xsl:variable>
354 <xsl:variable name="pTypeNameOut">
355 <xsl:call-template name="typeIdl2Back">
356 <xsl:with-param name="type" select="@type" />
357 <xsl:with-param name="safearray" select="@safearray" />
358 <xsl:with-param name="param" select="$pName" />
359 <xsl:with-param name="dir" select="'out'" />
360 </xsl:call-template>
361 </xsl:variable>
362
363 <xsl:variable name="pTypeNameIn">
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="'in'" />
369 </xsl:call-template>
370 </xsl:variable>
371
372 <xsl:variable name="capsName">
373 <xsl:call-template name="capitalize">
374 <xsl:with-param name="str" select="@name" />
375 </xsl:call-template>
376 </xsl:variable>
377
378 <xsl:value-of select=" '&#10;'" />
379 <xsl:value-of select="concat(' // attribute ', @name,'&#10;')" />
380 <xsl:value-of select=" 'private:&#10;'" />
381 <xsl:value-of select="concat(' ', $mType, ' ', $mName,';&#10;')" />
382 <xsl:value-of select=" 'public:&#10;'" />
383 <xsl:value-of select="concat(' STDMETHOD(COMGETTER(', $capsName,'))(',$pTypeNameOut,')&#10; {&#10;')" />
384 <xsl:call-template name="genRetParam">
385 <xsl:with-param name="type" select="@type" />
386 <xsl:with-param name="member" select="$mName" />
387 <xsl:with-param name="param" select="$pName" />
388 <xsl:with-param name="safearray" select="@safearray" />
389 </xsl:call-template>
390 <xsl:value-of select=" ' return S_OK;&#10;'" />
391 <xsl:value-of select=" ' }&#10;'" />
392
393 <xsl:if test="not(@readonly='yes')">
394 <xsl:value-of select="concat(' STDMETHOD(COMSETTER(', $capsName,'))(',$pTypeNameIn,')&#10; {&#10;')" />
395 <xsl:call-template name="genSetParam">
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 </xsl:if>
404
405 <xsl:value-of select=" ' // purely internal setter&#10;'" />
406 <xsl:value-of select="concat(' HRESULT set_', @name,'(',$pTypeNameIn, ')&#10; {&#10;')" />
407 <xsl:call-template name="genSetParam">
408 <xsl:with-param name="type" select="@type" />
409 <xsl:with-param name="member" select="$mName" />
410 <xsl:with-param name="param" select="$pName" />
411 <xsl:with-param name="safearray" select="@safearray" />
412 </xsl:call-template>
413 <xsl:value-of select=" ' return S_OK;&#10;'" />
414 <xsl:value-of select=" ' }&#10;'" />
415 </xsl:for-each>
416
417 <xsl:choose>
418 <xsl:when test="$extends='IEvent'">
419 <xsl:value-of select=" ' // skipping IEvent attributes &#10;'" />
420 </xsl:when>
421 <xsl:when test="//interface[@name=$extends]">
422 <xsl:call-template name="genAttrCode">
423 <xsl:with-param name="name" select="$extends" />
424 <xsl:with-param name="depth" select="$depth+1" />
425 <xsl:with-param name="parents" select="concat($parents, ', ', @name)" />
426 </xsl:call-template>
427 </xsl:when>
428 <xsl:otherwise>
429 <xsl:call-template name="fatalError">
430 <xsl:with-param name="msg" select="concat('No idea how to process it: ', $extends)" />
431 </xsl:call-template>
432 </xsl:otherwise>
433 </xsl:choose>
434</xsl:template>
435
436<xsl:template name="genEventImpl">
437 <xsl:param name="implName" />
438 <xsl:param name="isVeto" />
439
440 <xsl:value-of select="concat('class ATL_NO_VTABLE ',$implName,
441 '&#10; : public VirtualBoxBase,&#10; VBOX_SCRIPTABLE_IMPL(',
442 @name, ')&#10;{&#10;')" />
443 <xsl:value-of select="'public:&#10;'" />
444 <xsl:value-of select="concat(' VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(', $implName, ', ', @name, ')&#10;')" />
445 <xsl:value-of select="concat(' DECLARE_NOT_AGGREGATABLE(', $implName, ')&#10;')" />
446 <xsl:value-of select=" ' DECLARE_PROTECT_FINAL_CONSTRUCT()&#10;'" />
447 <xsl:value-of select="concat(' BEGIN_COM_MAP(', $implName, ')&#10;')" />
448 <xsl:call-template name="genComEntry">
449 <xsl:with-param name="name" select="@name" />
450 </xsl:call-template>
451 <xsl:value-of select=" ' END_COM_MAP()&#10;'" />
452 <xsl:value-of select="concat(' ', $implName, '() {}&#10;')" />
453 <xsl:value-of select="concat(' virtual ~', $implName, '() {}&#10;')" />
454 <xsl:text><![CDATA[
455 HRESULT FinalConstruct()
456 {
457 return mEvent.createObject();
458 }
459 void FinalRelease()
460 {
461 mEvent->FinalRelease();
462 }
463 STDMETHOD(COMGETTER(Type)) (VBoxEventType_T *aType)
464 {
465 return ((VBoxEvent*)mEvent)->COMGETTER(Type) (aType);
466 }
467 STDMETHOD(COMGETTER(Source)) (IEventSource * *aSource)
468 {
469 return ((VBoxEvent*)mEvent)->COMGETTER(Source) (aSource);
470 }
471 STDMETHOD(COMGETTER(Waitable)) (BOOL *aWaitable)
472 {
473 return ((VBoxEvent*)mEvent)->COMGETTER(Waitable) (aWaitable);
474 }
475 STDMETHOD(SetProcessed)()
476 {
477 return ((VBoxEvent*)mEvent)->SetProcessed();
478 }
479 STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult)
480 {
481 return ((VBoxEvent*)mEvent)->WaitProcessed(aTimeout, aResult);
482 }
483 void uninit()
484 {
485 mEvent->uninit();
486 }
487]]></xsl:text>
488 <xsl:choose>
489 <xsl:when test="$isVeto='yes'">
490<xsl:text><![CDATA[
491 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable = TRUE)
492 {
493 NOREF(aWaitable);
494 return mEvent->init(aSource, aType);
495 }
496 STDMETHOD(AddVeto)(IN_BSTR aVeto)
497 {
498 return mEvent->AddVeto(aVeto);
499 }
500 STDMETHOD(IsVetoed)(BOOL *aResult)
501 {
502 return mEvent->IsVetoed(aResult);
503 }
504 STDMETHOD(GetVetos)(ComSafeArrayOut(BSTR, aVetos))
505 {
506 return mEvent->GetVetos(ComSafeArrayOutArg(aVetos));
507 }
508private:
509 ComObjPtr<VBoxVetoEvent> mEvent;
510]]></xsl:text>
511 </xsl:when>
512 <xsl:otherwise>
513<xsl:text><![CDATA[
514 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, BOOL aWaitable)
515 {
516 return mEvent->init(aSource, aType, aWaitable);
517 }
518private:
519 ComObjPtr<VBoxEvent> mEvent;
520]]></xsl:text>
521 </xsl:otherwise>
522 </xsl:choose>
523 <xsl:call-template name="genAttrCode">
524 <xsl:with-param name="name" select="@name" />
525 </xsl:call-template>
526 <xsl:value-of select="'};&#10;'" />
527
528
529 <xsl:call-template name="genImplList">
530 <xsl:with-param name="impl" select="$implName" />
531 <xsl:with-param name="name" select="@name" />
532 <xsl:with-param name="depth" select="'2'" />
533 <xsl:with-param name="parents" select="''" />
534 </xsl:call-template>
535
536</xsl:template>
537
538
539<xsl:template name="genSwitchCase">
540 <xsl:param name="implName" />
541 <xsl:variable name="waitable">
542 <xsl:choose>
543 <xsl:when test="@waitable='yes'">
544 <xsl:value-of select="'TRUE'"/>
545 </xsl:when>
546 <xsl:otherwise>
547 <xsl:value-of select="'FALSE'"/>
548 </xsl:otherwise>
549 </xsl:choose>
550 </xsl:variable>
551 <xsl:value-of select="concat(' case VBoxEventType_', @id, ':&#10;')"/>
552 <xsl:value-of select=" ' {&#10;'"/>
553 <xsl:value-of select="concat(' ComObjPtr&lt;', $implName, '&gt; obj;&#10;')"/>
554 <xsl:value-of select=" ' obj.createObject();&#10;'"/>
555 <xsl:value-of select="concat(' obj->init(aSource, aType, ', $waitable, ');&#10;')"/>
556 <xsl:call-template name="genAttrInitCode">
557 <xsl:with-param name="name" select="@name" />
558 <xsl:with-param name="obj" select="'obj'" />
559 </xsl:call-template>
560 <xsl:value-of select=" ' obj.queryInterfaceTo(mEvent.asOutParam());&#10;'"/>
561 <xsl:value-of select=" ' break;&#10;'"/>
562 <xsl:value-of select=" ' }&#10;'"/>
563</xsl:template>
564
565<xsl:template name="genCommonEventCode">
566 <xsl:text><![CDATA[
567HRESULT VBoxEventDesc::init(IEventSource* aSource, VBoxEventType_T aType, ...)
568{
569 va_list args;
570
571 mEventSource = aSource;
572 va_start(args, aType);
573 switch (aType)
574 {
575]]></xsl:text>
576
577 <xsl:for-each select="//interface[@autogen=$G_kind]">
578 <xsl:variable name="implName">
579 <xsl:value-of select="substring(@name, 2)" />
580 </xsl:variable>
581 <xsl:call-template name="genSwitchCase">
582 <xsl:with-param name="implName" select="$implName" />
583 </xsl:call-template>
584 </xsl:for-each>
585
586 <xsl:text><![CDATA[
587 default:
588 if (1) AssertFailed();
589 }
590 va_end(args);
591
592 return S_OK;
593}
594]]></xsl:text>
595
596</xsl:template>
597
598
599<xsl:template match="/">
600 <xsl:call-template name="fileheader">
601 <xsl:with-param name="name" select="'VBoxEvents.cpp'" />
602 </xsl:call-template>
603
604<xsl:text><![CDATA[
605 #include <VBox/com/array.h>
606 #include "EventImpl.h"
607]]></xsl:text>
608
609
610 <!-- Interfaces -->
611 <xsl:for-each select="//interface[@autogen=$G_kind]">
612 <xsl:value-of select="concat('// ', @name, ' implementation code &#10;')" />
613 <xsl:variable name="implName">
614 <xsl:value-of select="substring(@name, 2)" />
615 </xsl:variable>
616
617 <xsl:choose>
618 <xsl:when test="$G_kind='VBoxEvent'">
619 <xsl:variable name="isVeto">
620 <xsl:if test="@extends='IVetoEvent'">
621 <xsl:value-of select="'yes'" />
622 </xsl:if>
623 </xsl:variable>
624 <xsl:call-template name="genEventImpl">
625 <xsl:with-param name="implName" select="$implName" />
626 <xsl:with-param name="isVeto" select="$isVeto" />
627 </xsl:call-template>
628 </xsl:when>
629 </xsl:choose>
630 </xsl:for-each>
631
632 <!-- Global code -->
633 <xsl:choose>
634 <xsl:when test="$G_kind='VBoxEvent'">
635 <xsl:call-template name="genCommonEventCode">
636 </xsl:call-template>
637 </xsl:when>
638 </xsl:choose>
639</xsl:template>
640
641</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