VirtualBox

source: vbox/trunk/src/VBox/Installer/win/VirtualBox_TypeLibWithInterfaces.xsl@ 77807

Last change on this file since 77807 was 76242, checked in by vboxsync, 6 years ago

Installer/win: Corrected the VirtualBox_TypeLib*.xsl script to deal with library/if/application ordering too. bugref:3300

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 11.6 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 Generates a wiX include files with Interface elements for
5 the stuff in the proxy stub DLLs.
6
7 Copyright (C) 2007-2016 Oracle Corporation
8
9 This file is part of VirtualBox Open Source Edition (OSE), as
10 available from http://www.virtualbox.org. This file is free software;
11 you can redistribute it and/or modify it under the terms of the GNU
12 General Public License (GPL) as published by the Free Software
13 Foundation, in version 2 as it comes in the "COPYING" file of the
14 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16-->
17
18<xsl:stylesheet version="1.0"
19 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20
21<xsl:output method="xml"
22 version="1.0"
23 encoding="utf-8"
24 indent="yes"/>
25
26<xsl:strip-space elements="*"/>
27
28<xsl:param name="a_sTarget">all</xsl:param>
29<xsl:param name ="a_sWithSDS" select="no"/>
30<xsl:param name="a_sProxyStubClsid">{0BB3B78C-1807-4249-5BA5-EA42D66AF0BF}</xsl:param>
31<xsl:variable name="g_sProxyStubClsid" select="translate($a_sProxyStubClsid,'abcdef','ABCDEF')"/>
32
33
34<!--
35// templates
36/////////////////////////////////////////////////////////////////////////////
37-->
38
39<!--
40 * header
41-->
42<xsl:template match="/idl">
43 <xsl:comment>
44
45 DO NOT EDIT! This is a generated file.
46
47 WiX include script for the VirtualBox Type Library
48 generated from XIDL (XML interface definition).
49
50 Source : src/VBox/Main/idl/VirtualBox.xidl
51 Generator : src/VBox/Installer/win/VirtualBox_Interfaces.xsl
52 Arguments : a_sTarget=<xsl:value-of select="$a_sTarget"/>
53 a_sProxyStubClsid=<xsl:value-of select="$a_sProxyStubClsid"/>
54
55 </xsl:comment>
56 <xsl:apply-templates/>
57</xsl:template>
58
59
60<!-- - - - - - - - - - - - - - - - - - - - - - -
61 Key for more efficiently looking up of parent interfaces.
62 - - - - - - - - - - - - - - - - - - - - - - -->
63
64<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
65
66<!--
67* filters to skip VBoxSDS class and interfaces if a VBOX_WITH_SDS is not defined in kmk
68-->
69 <xsl:template match="application[@uuid='ec0e78e8-fa43-43e8-ac0a-02c784c4a4fa']">
70 <xsl:if test="$a_sWithSDS='yes'" >
71 <xsl:call-template name="application_template" />
72 </xsl:if>
73 </xsl:template>
74
75<!--
76 Libraries.
77-->
78<xsl:template match="library">
79 <Include>
80 <TypeLib>
81 <xsl:attribute name="Id"><xsl:value-of select="@uuid"/></xsl:attribute>
82 <xsl:attribute name="Advertise">yes</xsl:attribute>
83 <xsl:attribute name="MajorVersion"><xsl:value-of select="substring(@version,1,1)"/></xsl:attribute>
84 <xsl:attribute name="MinorVersion"><xsl:value-of select="substring(@version,3)"/></xsl:attribute>
85 <xsl:attribute name="Language">0</xsl:attribute>
86 <xsl:attribute name="Description"><xsl:value-of select="@name"/></xsl:attribute>
87 <xsl:attribute name="HelpDirectory"><xsl:text>msm_VBoxApplicationFolder</xsl:text></xsl:attribute>
88 <xsl:apply-templates select="application | if[@target='midl']/application" />
89 </TypeLib>
90 </Include>
91</xsl:template>
92
93<!--
94Applications.
95-->
96<xsl:template match="application" name="application_template">
97 <AppId>
98 <xsl:attribute name="Id">
99 <xsl:value-of select="@uuid"/>
100 </xsl:attribute>
101 <xsl:attribute name="Description">
102 <xsl:value-of select="@name"/> Application
103 </xsl:attribute>
104 <!--
105 The name of windows service should be defined as module name in .xidl.
106 It's viable for correct registration of COM windows service.
107 -->
108 <xsl:if test="module/@context = 'LocalService'">
109 <xsl:attribute name="LocalService" >
110 <xsl:value-of select="module/@name"/>
111 </xsl:attribute>
112 </xsl:if>
113 <xsl:choose>
114 <xsl:when test="$a_sTarget = 'VBoxClient-x86'">
115 <xsl:apply-templates select="module[@name='VBoxC']/class"/>
116 </xsl:when>
117 <xsl:otherwise>
118 <xsl:apply-templates select="module/class"/>
119 </xsl:otherwise>
120 </xsl:choose>
121 </AppId>
122 <xsl:apply-templates select="interface | if/interface">
123 <xsl:sort select="translate(@uuid,'abcdef','ABCDEF')"/>
124 </xsl:apply-templates>
125</xsl:template>
126
127<!--
128 Classes.
129-->
130<xsl:template match="library//module/class">
131 <Class>
132 <xsl:attribute name="Id"><xsl:value-of select="@uuid"/></xsl:attribute>
133 <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
134 <xsl:attribute name="Server">
135 <xsl:choose>
136 <xsl:when test="$a_sTarget = 'VBoxClient-x86' and ../@name = 'VBoxC'"><xsl:text>VBoxClient_x86</xsl:text></xsl:when>
137 <xsl:otherwise><xsl:value-of select="../@name"/></xsl:otherwise>
138 </xsl:choose>
139 </xsl:attribute>
140 <xsl:attribute name="Context">
141 <xsl:choose>
142 <xsl:when test="../@context='InprocServer'">InprocServer32</xsl:when>
143 <xsl:when test="../@context='LocalServer'" >LocalServer32</xsl:when>
144 <xsl:when test="../@context='LocalService'">LocalServer32</xsl:when>
145 <xsl:otherwise>
146 <xsl:message terminate="yes">
147 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
148 <xsl:text>module context </xsl:text>
149 <xsl:value-of select="concat('&quot;',../@context,'&quot;')"/>
150 <xsl:text> is invalid!</xsl:text>
151 </xsl:message>
152 </xsl:otherwise>
153 </xsl:choose>
154 </xsl:attribute>
155 <xsl:if test="../@context='InprocServer'">
156 <xsl:variable name="tmodel" select="(./@threadingModel | ../@threadingModel)[last()]"/>
157 <xsl:attribute name="ThreadingModel">
158 <xsl:choose>
159 <xsl:when test="$tmodel='Apartment'">apartment</xsl:when>
160 <xsl:when test="$tmodel='Free'">free</xsl:when>
161 <xsl:when test="$tmodel='Both'">both</xsl:when>
162 <xsl:when test="$tmodel='Neutral'">neutral</xsl:when>
163 <xsl:when test="$tmodel='Single'">single</xsl:when>
164 <xsl:when test="$tmodel='Rental'">rental</xsl:when>
165 <xsl:otherwise>
166 <xsl:message terminate="yes">
167 <xsl:value-of select="concat(../../@name,'::',@name,': ')"/>
168 <xsl:text>class (or module) threading model </xsl:text>
169 <xsl:value-of select="concat('&quot;',$tmodel,'&quot;')"/>
170 <xsl:text> is invalid!</xsl:text>
171 </xsl:message>
172 </xsl:otherwise>
173 </xsl:choose>
174 </xsl:attribute>
175 </xsl:if>
176 <ProgId>
177 <xsl:attribute name="Id">
178 <xsl:value-of select="concat(//library/@name,'.',@name,'.1')"/>
179 </xsl:attribute>
180 <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
181 <ProgId>
182 <xsl:attribute name="Id">
183 <xsl:value-of select="concat(//library/@name,'.',@name)"/>
184 </xsl:attribute>
185 <xsl:attribute name="Description"><xsl:value-of select="@name"/> Class</xsl:attribute>
186 </ProgId>
187 </ProgId>
188 </Class>
189</xsl:template>
190
191
192<!--
193 Interfaces.
194-->
195<xsl:template match=" library/application/interface
196 | library/application/if[@target='midl']/interface
197 | library/if[@target='midl']/application/interface
198 ">
199 <Interface>
200<!-- Interface Id="{00C8F974-92C5-44A1-8F3F-702469FDD04B}" Name="IDHCPServer" ProxyStubClassId32="{0BB3B78C-1807-4249-5BA5-EA42D66AF0BF}" NumMethods="33" -->
201 <xsl:attribute name="Id">
202 <xsl:text>{</xsl:text>
203 <xsl:value-of select="translate(@uuid,'abcdef','ABCDEF')"/>
204 <xsl:text>}</xsl:text>
205 </xsl:attribute>
206 <xsl:attribute name="Name"><xsl:value-of select="@name"/></xsl:attribute>
207 <xsl:attribute name="ProxyStubClassId32"><xsl:value-of select="$g_sProxyStubClsid"/></xsl:attribute>
208 <xsl:attribute name="NumMethods"><xsl:call-template name="fnCountMethods"/></xsl:attribute>
209 </Interface>
210</xsl:template>
211
212
213
214<!--
215 Count the number of methods. This must match what midl.exe initializes
216 CInterfaceStubVtbl::header::DispatchTableCount with in VirtualBox_p.c!
217 -->
218<xsl:template name="fnCountMethods">
219 <xsl:variable name="sParent" select="@extends"/>
220
221 <!-- Count immediate methods and attributes by kind. -->
222 <xsl:variable name="cMethods"
223 select="count(child::method)
224 + count(child::if[@target='midl']/method)"/>
225 <xsl:variable name="cReadOnlyAttributes"
226 select="count(child::attribute[@readonly='yes'])
227 + count(child::if[@target='midl']/attribute[@readonly='yes'])"/>
228 <xsl:variable name="cReadWriteAttributes"
229 select="count(child::attribute[not(@readonly) or not(@readonly='yes')])
230 + count(child::if[@target = 'midl']/attribute[not(@readonly) or not(@readonly='yes')])"/>
231 <xsl:variable name="cReservedMethods">
232 <xsl:choose>
233 <xsl:when test="not(@reservedMethods)">0</xsl:when>
234 <xsl:otherwise><xsl:value-of select="@reservedMethods"/></xsl:otherwise>
235 </xsl:choose>
236 </xsl:variable>
237 <xsl:variable name="cReservedAttributes">
238 <xsl:choose>
239 <xsl:when test="not(@reservedAttributes)">0</xsl:when>
240 <xsl:otherwise><xsl:value-of select="@reservedAttributes"/></xsl:otherwise>
241 </xsl:choose>
242 </xsl:variable>
243
244 <!-- Recursively figure out the parent -->
245 <xsl:variable name="cParent">
246 <xsl:choose>
247 <xsl:when test="@extends = '$unknown'">
248 <xsl:value-of select='7'/>
249 </xsl:when>
250 <xsl:when test="@extends = '$errorinfo'">
251 <xsl:value-of select='8'/> <!-- check this one! -->
252 </xsl:when>
253 <xsl:otherwise>
254 <xsl:if test="count(key('G_keyInterfacesByName', $sParent)) != 1">
255 <xsl:message terminate="yes">Couldn't find parent (<xsl:value-of select="$sParent"/>) to <xsl:value-of select="@name"/></xsl:message>
256 </xsl:if>
257 <xsl:for-each select="key('G_keyInterfacesByName', $sParent)">
258 <xsl:call-template name="fnCountMethods"/>
259 </xsl:for-each>
260 </xsl:otherwise>
261 </xsl:choose>
262 </xsl:variable>
263
264 <!-- Compute the result. -->
265 <xsl:variable name="cMethodsTotal"
266 select="$cMethods + $cReservedMethods + $cReadOnlyAttributes
267 + ($cReadWriteAttributes * 2) + $cReservedAttributes + $cParent"/>
268 <xsl:value-of select="$cMethodsTotal"/>
269
270 <!-- For debugging! -->
271 <xsl:if test="0 or $cMethodsTotal > 256">
272 <xsl:message terminate="no">
273 <xsl:text>Debug: cMethods=</xsl:text><xsl:value-of select="$cMethods"/>
274 <xsl:text> cReadOnlyAttributes=</xsl:text><xsl:value-of select="$cReadOnlyAttributes"/>
275 <xsl:text> cReadWriteAttributes=</xsl:text><xsl:value-of select="$cReadWriteAttributes"/>
276 <xsl:text> cReservedMethods=</xsl:text><xsl:value-of select="$cReservedMethods"/>
277 <xsl:text> cReservedAttributes=</xsl:text><xsl:value-of select="$cReservedAttributes"/>
278 <xsl:text> cParent=</xsl:text><xsl:value-of select="$cParent"/>
279 <xsl:text> name=</xsl:text><xsl:value-of select="@name"/>
280 <xsl:text> parent=</xsl:text><xsl:value-of select="$sParent"/>
281 </xsl:message>
282 <xsl:if test="$cMethodsTotal > 256">
283 <xsl:message terminate="yes">
284 <xsl:text>
285Fatal xidl error: Interface </xsl:text><xsl:value-of select="@name"/>
286 <xsl:text> has </xsl:text><xsl:value-of select="$cMethodsTotal"/>
287 <xsl:text>! The maximum that older windows allows for proxy stubs is 256.
288 Please try adjust the number of reserved methods or attributes,
289 though it's clearly time to consider splitting up this monster interface.
290
291</xsl:text>
292 </xsl:message>
293 </xsl:if>
294 </xsl:if>
295</xsl:template>
296
297
298
299<!--
300 Eat everything else not explicitly matched.
301-->
302<xsl:template match="*">
303</xsl:template>
304
305
306</xsl:stylesheet>
307
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