VirtualBox

Changeset 53879 in vbox for trunk/src/VBox/Main/idl


Ignore:
Timestamp:
Jan 21, 2015 1:13:01 AM (10 years ago)
Author:
vboxsync
Message:

apiwrap-server.xsl: Fixed a couple of bugs in previous commit and optimize the filelist stuff, keeping it from going unecessarily deep and adding unecessary conditionals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/apiwrap-server.xsl

    r53878 r53879  
    503503    <xsl:param name="iface"/>
    504504
    505     <xsl:variable name="addinterfaces">
    506         <xsl:call-template name="getattrlist">
    507             <xsl:with-param name="val" select="$iface/@wrap-hint-server-addinterfaces"/>
    508         </xsl:call-template>
    509     </xsl:variable>
    510 
    511     <xsl:if test="$generating = 'headers' or $generating = 'filelist'">
    512         <xsl:call-template name="emitHeader">
    513             <xsl:with-param name="iface" select="$iface"/>
    514             <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    515         </xsl:call-template>
    516     </xsl:if>
    517 
    518     <xsl:if test="$generating = 'sources' or $generating = 'filelist'">
    519         <xsl:call-template name="emitCode">
    520             <xsl:with-param name="iface" select="$iface"/>
    521             <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    522         </xsl:call-template>
    523     </xsl:if>
    524 
    525     <xsl:if test="$generating = 'dtrace-probes'">
    526         <xsl:call-template name="emitDTraceProbes">
    527             <xsl:with-param name="iface" select="$iface"/>
    528             <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    529         </xsl:call-template>
    530     </xsl:if>
    531 
     505    <xsl:choose>
     506        <xsl:when test="$generating != 'filelist'">
     507            <!-- sources, headers and dtrace-probes all needs attribute lists -->
     508            <xsl:variable name="addinterfaces">
     509                <xsl:call-template name="getattrlist">
     510                    <xsl:with-param name="val" select="$iface/@wrap-hint-server-addinterfaces"/>
     511                </xsl:call-template>
     512            </xsl:variable>
     513            <xsl:choose>
     514                <xsl:when test="$generating = 'sources'">
     515                    <xsl:call-template name="emitCode">
     516                        <xsl:with-param name="iface" select="$iface"/>
     517                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     518                    </xsl:call-template>
     519                </xsl:when>
     520                <xsl:when test="$generating = 'headers'">
     521                    <xsl:call-template name="emitHeader">
     522                        <xsl:with-param name="iface" select="$iface"/>
     523                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     524                    </xsl:call-template>
     525                </xsl:when>
     526                <xsl:when test="$generating = 'dtrace-probes'">
     527                    <xsl:call-template name="emitDTraceProbes">
     528                        <xsl:with-param name="iface" select="$iface"/>
     529                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     530                    </xsl:call-template>
     531                </xsl:when>
     532            </xsl:choose>
     533        </xsl:when>
     534
     535        <xsl:when test="$generating = 'filelist'">
     536            <!-- Just output the name of the header and source filenames for this interface. -->
     537            <xsl:apply-templates select="$iface" mode="listfile">
     538                <xsl:with-param name="file" select="concat(substring(@name, 2), 'Wrap.h')"/>
     539            </xsl:apply-templates>
     540            <xsl:apply-templates select="$iface" mode="listfile">
     541                <xsl:with-param name="file" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
     542            </xsl:apply-templates>
     543        </xsl:when>
     544    </xsl:choose>
    532545</xsl:template>
    533546
     
    21772190    <xsl:param name="addinterfaces"/>
    21782191
     2192    <xsl:if test="$generating != 'headers'"> <!-- Paranoia -->
     2193        <xsl:message terminate="yes">
     2194            Did not expect generating='<xsl:value-of select="$generating"/>' in the emitHeader template.
     2195        </xsl:message>
     2196    </xsl:if>
     2197
    21792198    <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
    21802199
    2181     <xsl:choose>
    2182         <xsl:when test="$generating = 'headers'">
    2183             <xsl:apply-templates select="$iface" mode="startfile">
    2184                 <xsl:with-param name="file" select="$filename"/>
    2185             </xsl:apply-templates>
    2186             <xsl:call-template name="fileheader">
    2187                 <xsl:with-param name="name" select="$filename"/>
    2188                 <xsl:with-param name="class" select="substring(@name, 2)"/>
    2189                 <xsl:with-param name="type" select="'header'"/>
    2190             </xsl:call-template>
    2191             <xsl:apply-templates select="$iface" mode="classheader">
    2192                 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2193             </xsl:apply-templates>
    2194 
    2195             <!-- interface attributes/methods (public) -->
    2196             <xsl:call-template name="emitInterfaceDecls">
    2197                 <xsl:with-param name="iface" select="$iface"/>
    2198                 <xsl:with-param name="pmode" select="'public'"/>
    2199             </xsl:call-template>
    2200 
    2201             <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    2202                 <!-- This is super tricky, as the for-each switches to the node
    2203                      set, which means the normal document isn't available any
    2204                      more. So need to use the global root node to get back into
    2205                      the documemt to find corresponding interface data. -->
    2206                 <xsl:variable name="addifname">
    2207                     <xsl:value-of select="string(.)"/>
    2208                 </xsl:variable>
    2209                 <xsl:call-template name="emitInterfaceDecls">
    2210                     <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2211                     <xsl:with-param name="pmode" select="'public'"/>
    2212                 </xsl:call-template>
    2213             </xsl:for-each>
    2214 
    2215             <!-- auxiliary methods (public) -->
    2216             <xsl:call-template name="emitAuxMethodDecls">
    2217                 <xsl:with-param name="iface" select="$iface"/>
    2218             </xsl:call-template>
    2219 
    2220             <!-- switch to private -->
    2221             <xsl:text>
     2200    <xsl:apply-templates select="$iface" mode="startfile">
     2201        <xsl:with-param name="file" select="$filename"/>
     2202    </xsl:apply-templates>
     2203    <xsl:call-template name="fileheader">
     2204        <xsl:with-param name="name" select="$filename"/>
     2205        <xsl:with-param name="class" select="substring(@name, 2)"/>
     2206        <xsl:with-param name="type" select="'header'"/>
     2207    </xsl:call-template>
     2208    <xsl:apply-templates select="$iface" mode="classheader">
     2209        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2210    </xsl:apply-templates>
     2211
     2212    <!-- interface attributes/methods (public) -->
     2213    <xsl:call-template name="emitInterfaceDecls">
     2214        <xsl:with-param name="iface" select="$iface"/>
     2215        <xsl:with-param name="pmode" select="'public'"/>
     2216    </xsl:call-template>
     2217
     2218    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
     2219        <!-- This is super tricky, as the for-each switches to the node
     2220             set, which means the normal document isn't available any
     2221             more. So need to use the global root node to get back into
     2222             the documemt to find corresponding interface data. -->
     2223        <xsl:variable name="addifname">
     2224            <xsl:value-of select="string(.)"/>
     2225        </xsl:variable>
     2226        <xsl:call-template name="emitInterfaceDecls">
     2227            <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
     2228            <xsl:with-param name="pmode" select="'public'"/>
     2229        </xsl:call-template>
     2230    </xsl:for-each>
     2231
     2232    <!-- auxiliary methods (public) -->
     2233    <xsl:call-template name="emitAuxMethodDecls">
     2234        <xsl:with-param name="iface" select="$iface"/>
     2235    </xsl:call-template>
     2236
     2237    <!-- switch to private -->
     2238    <xsl:text>
    22222239private:</xsl:text>
    22232240
    2224             <!-- wrapped interface attributes/methods (private) -->
    2225             <xsl:call-template name="emitInterfaceDecls">
    2226                 <xsl:with-param name="iface" select="$iface"/>
    2227                 <xsl:with-param name="pmode" select="'wrapped'"/>
    2228             </xsl:call-template>
    2229 
    2230             <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    2231                 <!-- This is super tricky, as the for-each switches to the node
    2232                      set, which means the normal document isn't available any
    2233                      more. So need to use the global root node to get back into
    2234                      the documemt to find corresponding interface data. -->
    2235                 <xsl:variable name="addifname">
    2236                     <xsl:value-of select="string(.)"/>
    2237                 </xsl:variable>
    2238                 <xsl:call-template name="emitInterfaceDecls">
    2239                     <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2240                     <xsl:with-param name="pmode" select="'wrapped'"/>
    2241                 </xsl:call-template>
    2242             </xsl:for-each>
    2243 
    2244             <xsl:apply-templates select="$iface" mode="classfooter"/>
    2245             <xsl:apply-templates select="$iface" mode="endfile">
    2246                 <xsl:with-param name="file" select="$filename"/>
    2247             </xsl:apply-templates>
    2248         </xsl:when>
    2249 
    2250         <xsl:when test="$generating = 'filelist'">
    2251             <xsl:apply-templates select="$iface" mode="listfile">
    2252                 <xsl:with-param name="file" select="$filename"/>
    2253             </xsl:apply-templates>
    2254         </xsl:when>
    2255 
    2256         <xsl:otherwise>
    2257             <xsl:message terminate="yes">
    2258                 Did not expect generating='<xsl:value-of select="$generating"/>' in the emitHeader template.
    2259             </xsl:message>
    2260         </xsl:otherwise>
    2261     </xsl:choose>
     2241    <!-- wrapped interface attributes/methods (private) -->
     2242    <xsl:call-template name="emitInterfaceDecls">
     2243        <xsl:with-param name="iface" select="$iface"/>
     2244        <xsl:with-param name="pmode" select="'wrapped'"/>
     2245    </xsl:call-template>
     2246
     2247    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
     2248        <!-- This is super tricky, as the for-each switches to the node
     2249             set, which means the normal document isn't available any
     2250             more. So need to use the global root node to get back into
     2251             the documemt to find corresponding interface data. -->
     2252        <xsl:variable name="addifname">
     2253            <xsl:value-of select="string(.)"/>
     2254        </xsl:variable>
     2255        <xsl:call-template name="emitInterfaceDecls">
     2256            <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
     2257            <xsl:with-param name="pmode" select="'wrapped'"/>
     2258        </xsl:call-template>
     2259    </xsl:for-each>
     2260
     2261    <xsl:apply-templates select="$iface" mode="classfooter"/>
     2262    <xsl:apply-templates select="$iface" mode="endfile">
     2263        <xsl:with-param name="file" select="$filename"/>
     2264    </xsl:apply-templates>
    22622265</xsl:template>
    22632266
     
    23472350    <xsl:param name="addinterfaces"/>
    23482351
     2352    <xsl:if test="$generating != 'sources'"> <!-- Paranoia -->
     2353        <xsl:message terminate="yes">
     2354            Did not expect generating='<xsl:value-of select="$generating"/>' in the emitCode template.
     2355        </xsl:message>
     2356    </xsl:if>
     2357
    23492358    <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
    23502359
    2351     <xsl:choose>
    2352         <xsl:when test="$generating = 'sources'">
    2353             <xsl:apply-templates select="$iface" mode="startfile">
    2354                 <xsl:with-param name="file" select="$filename"/>
    2355             </xsl:apply-templates>
    2356             <xsl:call-template name="fileheader">
    2357                 <xsl:with-param name="name" select="$filename"/>
    2358                 <xsl:with-param name="class" select="substring(@name, 2)"/>
    2359                 <xsl:with-param name="type" select="'code'"/>
    2360             </xsl:call-template>
    2361             <xsl:apply-templates select="$iface" mode="codeheader">
    2362                 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2363             </xsl:apply-templates>
    2364 
    2365             <!-- interface attributes/methods (public) -->
    2366             <xsl:call-template name="emitInterfaceDefs">
    2367                 <xsl:with-param name="iface" select="$iface"/>
    2368                 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2369             </xsl:call-template>
    2370 
    2371             <!-- auxiliary methods (public) -->
    2372             <xsl:call-template name="emitAuxMethodDefs">
    2373                 <xsl:with-param name="iface" select="$iface"/>
    2374             </xsl:call-template>
    2375 
    2376             <xsl:apply-templates select="$iface" mode="codefooter">
    2377                 <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2378             </xsl:apply-templates>
    2379             <xsl:apply-templates select="$iface" mode="endfile">
    2380                 <xsl:with-param name="file" select="$filename"/>
    2381             </xsl:apply-templates>
    2382         </xsl:when>
    2383         <xsl:when test="$generating = 'filelist'">
    2384             <xsl:apply-templates select="$iface" mode="listfile">
    2385                 <xsl:with-param name="file" select="$filename"/>
    2386             </xsl:apply-templates>
    2387         </xsl:when>
    2388         <xsl:otherwise>
    2389             <xsl:message terminate="yes">
    2390                 Did not expect generating='<xsl:value-of select="$generating"/>' in the emitCode template.
    2391             </xsl:message>
    2392         </xsl:otherwise>
    2393     </xsl:choose>
     2360    <xsl:apply-templates select="$iface" mode="startfile">
     2361        <xsl:with-param name="file" select="$filename"/>
     2362    </xsl:apply-templates>
     2363    <xsl:call-template name="fileheader">
     2364        <xsl:with-param name="name" select="$filename"/>
     2365        <xsl:with-param name="class" select="substring(@name, 2)"/>
     2366        <xsl:with-param name="type" select="'code'"/>
     2367    </xsl:call-template>
     2368    <xsl:apply-templates select="$iface" mode="codeheader">
     2369        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2370    </xsl:apply-templates>
     2371
     2372    <!-- interface attributes/methods (public) -->
     2373    <xsl:call-template name="emitInterfaceDefs">
     2374        <xsl:with-param name="iface" select="$iface"/>
     2375        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2376    </xsl:call-template>
     2377
     2378    <!-- auxiliary methods (public) -->
     2379    <xsl:call-template name="emitAuxMethodDefs">
     2380        <xsl:with-param name="iface" select="$iface"/>
     2381    </xsl:call-template>
     2382
     2383    <xsl:apply-templates select="$iface" mode="codefooter">
     2384        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2385    </xsl:apply-templates>
     2386    <xsl:apply-templates select="$iface" mode="endfile">
     2387        <xsl:with-param name="file" select="$filename"/>
     2388    </xsl:apply-templates>
    23942389</xsl:template>
    23952390
     
    24012396    <xsl:param name="addinterfaces"/>
    24022397
    2403     <xsl:if test="$generating != 'dtrace-probes'">
     2398    <xsl:if test="$generating != 'dtrace-probes'"> <!-- Paranoia -->
    24042399        <xsl:message terminate="yes">
    24052400            Did not expect generating='<xsl:value-of select="$generating"/>' in the emitDTraceProbes template.
Note: See TracChangeset for help on using the changeset viewer.

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