VirtualBox

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


Ignore:
Timestamp:
Jan 21, 2015 4:58:34 PM (10 years ago)
Author:
vboxsync
Message:

apiwrap-server.xsl: Use xsl:key + key() to lookup interfaces and enums by @name. Since key works on current document, the super tricky stuff needed to make sure $G_root was select as current, so I took it one step further and make the interface[@name=$addifname] current as well. Pushing that a step further, and the need for $iface was eliminated. Changes save 5-6 seconds here on a 30 second run.

File:
1 edited

Legend:

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

    r53886 r53903  
    4747
    4848<xsl:include href="typemap-shared.inc.xsl"/>
     49
     50<!-- - - - - - - - - - - - - - - - - - - - - - -
     51  keys for more efficiently looking up 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
    4957
    5058<!-- - - - - - - - - - - - - - - - - - - - - - -
     
    98106</xsl:template>
    99107
     108<!-- Emits COM_INTERFACE_ENTRY statements for the current interface node and whatever it inherits from. -->
    100109<xsl:template name="emitCOMInterfaces">
    101     <xsl:param name="iface"/>
    102 
    103     <xsl:value-of select="concat('        COM_INTERFACE_ENTRY(', $iface/@name, ')' , $G_sNewLine)"/>
     110    <xsl:value-of select="concat('        COM_INTERFACE_ENTRY(', @name, ')' , $G_sNewLine)"/>
    104111    <!-- now recurse to emit all base interfaces -->
    105     <xsl:variable name="extends" select="$iface/@extends"/>
     112    <xsl:variable name="extends" select="@extends"/>
    106113    <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
    107         <xsl:call-template name="emitCOMInterfaces">
    108             <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
    109         </xsl:call-template>
     114        <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
     115            <xsl:call-template name="emitCOMInterfaces"/>
     116        </xsl:for-each>
    110117    </xsl:if>
    111118</xsl:template>
     
    150157    <xsl:text>        COM_INTERFACE_ENTRY(ISupportErrorInfo)
    151158</xsl:text>
    152     <xsl:call-template name="emitCOMInterfaces">
    153         <xsl:with-param name="iface" select="."/>
    154     </xsl:call-template>
     159    <xsl:call-template name="emitCOMInterfaces"/>
    155160    <xsl:value-of select="concat('        COM_INTERFACE_ENTRY2(IDispatch, ', @name, ')', $G_sNewLine)"/>
    156161    <xsl:variable name="manualAddInterfaces">
     
    162167    <xsl:if test="not($manualAddInterfaces = 'true')">
    163168        <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    164             <!-- This is super tricky, as the for-each switches to the node
    165                  set, which means the normal document isn't available any more.
    166                  So need to use the global root node to get back into the
    167                  documemt to find corresponding interface data. -->
     169            <!-- This is super tricky, as the for-each switches to the node set,
     170                 which means the normal document isn't available any more.  We get
     171                 the data we need, uses a for-each to switch document and then a
     172                 key() to look up the interface by name. -->
    168173            <xsl:variable name="addifname">
    169174                <xsl:value-of select="string(.)"/>
    170175            </xsl:variable>
    171             <xsl:call-template name="emitCOMInterfaces">
    172                 <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    173             </xsl:call-template>
     176            <xsl:for-each select="$G_root">
     177                <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
     178                    <xsl:call-template name="emitCOMInterfaces"/>
     179                </xsl:for-each>
     180            </xsl:for-each>
    174181        </xsl:for-each>
    175182    </xsl:if>
     
    210217    <xsl:choose>
    211218        <xsl:when test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
    212             <xsl:variable name="newextends" select="//interface[@name=$extends]/@extends"/>
     219            <xsl:variable name="newextends" select="key('G_keyInterfacesByName', $extends)/@extends"/>
    213220            <xsl:variable name="newiflist" select="concat($interfacelist, ', ', $extends)"/>
    214221            <xsl:call-template name="emitISupports">
     
    225232                <xsl:when test="count($addinterfaces_ns/token) > 0">
    226233                    <xsl:variable name="addifname" select="$addinterfaces_ns/token[1]"/>
    227                     <xsl:variable name="addif" select="//interface[@name=$addifname]/@extends"/>
     234                    <xsl:variable name="addif" select="key('G_keyInterfacesByName', $addifname)/@extends"/>
    228235                    <xsl:variable name="newextends" select="$addif/@extends"/>
    229236                    <xsl:variable name="newaddinterfaces" select="$addinterfaces_ns/token[position() > 1]"/>
     
    346353                </xsl:when>
    347354
    348                 <xsl:when test="//interface[@name=$type]">
    349                     <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    350                     <xsl:variable name="thatifname" select="$thatif/@name"/>
    351                     <xsl:value-of select="concat($thatifname, ' *')"/>
    352                 </xsl:when>
    353 
    354                 <xsl:when test="//enum[@name=$type]">
     355                <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     356                    <xsl:value-of select="concat($type, ' *')"/>
     357                </xsl:when>
     358
     359                <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    355360                    <xsl:value-of select="concat($type, '_T')"/>
    356361                </xsl:when>
     
    406411                </xsl:when>
    407412
    408                 <xsl:when test="//interface[@name=$type]">
    409                     <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    410                     <xsl:variable name="thatifname" select="$thatif/@name"/>
     413                <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    411414                    <xsl:if test="$dir='in' and not($safearray='yes')">
    412415                        <xsl:text>const </xsl:text>
    413416                    </xsl:if>
    414                     <xsl:value-of select="concat('ComPtr&lt;', $thatifname, '&gt; &amp;')"/>
    415                 </xsl:when>
    416 
    417                 <xsl:when test="//enum[@name=$type]">
     417                    <xsl:value-of select="concat('ComPtr&lt;', $type, '&gt; &amp;')"/>
     418                </xsl:when>
     419
     420                <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    418421                    <xsl:value-of select="concat($type, '_T')"/>
    419422                </xsl:when>
     
    451454            <xsl:value-of select="$wrapfmt"/>
    452455        </xsl:when>
    453         <xsl:when test="//enum[@name=$type]">
    454             <xsl:text>%RU32</xsl:text>
    455         </xsl:when>
    456456        <xsl:when test="$type='$unknown'">
    457457            <xsl:text>%p</xsl:text>
    458458        </xsl:when>
    459         <xsl:when test="//interface[@name=$type]">
     459        <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
     460            <xsl:text>%RU32</xsl:text>
     461        </xsl:when>
     462        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    460463            <xsl:text>%p</xsl:text>
    461464        </xsl:when>
     
    483486            <xsl:text>void *</xsl:text>
    484487        </xsl:when>
    485         <xsl:when test="//enum[@name=$type]">
     488        <xsl:when test="count(key('G_keyEnumsByName', $type)) > 0">
    486489            <!-- <xsl:value-of select="concat($type, '_T')"/> - later we can emit enums into dtrace the library -->
    487490            <xsl:text>int</xsl:text>
    488491        </xsl:when>
    489         <xsl:when test="//interface[@name=$type]">
     492        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
    490493            <!--
    491             <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    492             <xsl:variable name="thatifname" select="$thatif/@name"/>
    493             <xsl:value-of select="concat('struct ', $thatifname, ' *')"/>
     494            <xsl:value-of select="concat('struct ', $type, ' *')"/>
    494495            -->
    495496            <xsl:text>void *</xsl:text>
     
    511512 - - - - - - - - - - - - - - - - - - - - - - -->
    512513
     514<!-- Called on interface node. -->
    513515<xsl:template name="emitInterface">
    514     <xsl:param name="iface"/>
    515 
    516516    <xsl:choose>
    517517        <xsl:when test="$generating != 'filelist'">
     
    519519            <xsl:variable name="addinterfaces">
    520520                <xsl:call-template name="getattrlist">
    521                     <xsl:with-param name="val" select="$iface/@wrap-hint-server-addinterfaces"/>
     521                    <xsl:with-param name="val" select="@wrap-hint-server-addinterfaces"/>
    522522                </xsl:call-template>
    523523            </xsl:variable>
     524
    524525            <xsl:choose>
    525526                <xsl:when test="$generating = 'sources'">
    526527                    <xsl:call-template name="emitCode">
    527                         <xsl:with-param name="iface" select="$iface"/>
    528528                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    529529                    </xsl:call-template>
     
    531531                <xsl:when test="$generating = 'headers'">
    532532                    <xsl:call-template name="emitHeader">
    533                         <xsl:with-param name="iface" select="$iface"/>
    534533                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    535534                    </xsl:call-template>
     
    537536                <xsl:when test="$generating = 'dtrace-probes'">
    538537                    <xsl:call-template name="emitDTraceProbes">
    539                         <xsl:with-param name="iface" select="$iface"/>
    540538                        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    541539                    </xsl:call-template>
     
    750748                    <xsl:text>.ptr()</xsl:text>
    751749                </xsl:when>
     750                <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     751                    <xsl:text>(void *)</xsl:text>
     752                    <xsl:value-of select="$tmpname"/>
     753                    <xsl:text>.ptr()</xsl:text>
     754                </xsl:when>
    752755                <xsl:otherwise>
    753                     <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    754                     <xsl:choose>
    755                         <xsl:when test="$thatif">
    756                             <xsl:text>(void *)</xsl:text>
    757                             <xsl:value-of select="$tmpname"/>
    758                             <xsl:text>.ptr()</xsl:text>
    759                         </xsl:when>
    760                         <xsl:otherwise>
    761                             <xsl:value-of select="$tmpname"/>
    762                         </xsl:otherwise>
    763                     </xsl:choose>
     756                    <xsl:value-of select="$tmpname"/>
    764757                </xsl:otherwise>
    765758            </xsl:choose>
     
    867860            <xsl:text>yes</xsl:text>
    868861        </xsl:when>
    869         <!-- Micro optimizations: Postpone calculating $thatif. -->
    870         <xsl:when test="$type = 'boolean' or $type = 'long' or $type = 'long' or $type = 'long long'"/>
    871         <xsl:otherwise>
    872             <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    873             <xsl:if test="$thatif">
    874                 <xsl:text>yes</xsl:text>
    875             </xsl:if>
    876         </xsl:otherwise>
     862        <xsl:when test="$type = 'boolean' or $type = 'long' or $type = 'long' or $type = 'long long'"/> <!-- XXX: drop this? -->
     863        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     864            <xsl:text>yes</xsl:text>
     865        </xsl:when>
    877866    </xsl:choose>
    878867</xsl:template>
     
    926915        </xsl:when>
    927916
    928         <!-- Micro optimizations: Delay calculating thatif. -->
    929         <xsl:otherwise>
    930             <xsl:variable name="thatif" select="//interface[@name=$type]"/>
     917        <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     918            <xsl:if test="../@safearray='yes'">
     919                <xsl:text>Array</xsl:text>
     920            </xsl:if>
    931921            <xsl:choose>
    932                 <xsl:when test="$thatif">
    933                     <xsl:if test="../@safearray='yes'">
    934                         <xsl:text>Array</xsl:text>
    935                     </xsl:if>
    936                     <xsl:choose>
    937                         <xsl:when test="$dir='in'">
    938                             <xsl:text>ComTypeInConverter</xsl:text>
    939                         </xsl:when>
    940                         <xsl:otherwise>
    941                             <xsl:text>ComTypeOutConverter</xsl:text>
    942                         </xsl:otherwise>
    943                     </xsl:choose>
    944                     <xsl:variable name="thatifname" select="$thatif/@name"/>
    945                     <xsl:value-of select="concat('&lt;', $thatifname, '&gt;')"/>
    946                 </xsl:when>
    947 
    948                 <xsl:when test="../@safearray='yes'">
    949                     <xsl:text>Array</xsl:text>
    950                     <xsl:choose>
    951                         <xsl:when test="$dir='in'">
    952                             <xsl:text>InConverter</xsl:text>
    953                         </xsl:when>
    954                         <xsl:otherwise>
    955                             <xsl:text>OutConverter</xsl:text>
    956                         </xsl:otherwise>
    957                     </xsl:choose>
    958                     <xsl:variable name="gluetype">
    959                         <xsl:call-template name="translatepublictype">
    960                             <xsl:with-param name="type" select="."/>
    961                             <xsl:with-param name="dir" select="$dir"/>
    962                             <xsl:with-param name="mod" select="../@mod"/>
    963                         </xsl:call-template>
    964                     </xsl:variable>
    965                     <xsl:value-of select="concat('&lt;', $gluetype, '&gt;')"/>
    966                 </xsl:when>
     922                <xsl:when test="$dir='in'">
     923                    <xsl:text>ComTypeInConverter</xsl:text>
     924                </xsl:when>
     925                <xsl:otherwise>
     926                    <xsl:text>ComTypeOutConverter</xsl:text>
     927                </xsl:otherwise>
    967928            </xsl:choose>
    968         </xsl:otherwise>
     929            <xsl:value-of select="concat('&lt;', $type, '&gt;')"/>
     930        </xsl:when>
     931
     932        <xsl:when test="../@safearray='yes'">
     933            <xsl:text>Array</xsl:text>
     934            <xsl:choose>
     935                <xsl:when test="$dir='in'">
     936                    <xsl:text>InConverter</xsl:text>
     937                </xsl:when>
     938                <xsl:otherwise>
     939                    <xsl:text>OutConverter</xsl:text>
     940                </xsl:otherwise>
     941            </xsl:choose>
     942            <xsl:variable name="gluetype">
     943                <xsl:call-template name="translatepublictype">
     944                    <xsl:with-param name="type" select="."/>
     945                    <xsl:with-param name="dir" select="$dir"/>
     946                    <xsl:with-param name="mod" select="../@mod"/>
     947                </xsl:call-template>
     948            </xsl:variable>
     949            <xsl:value-of select="concat('&lt;', $gluetype, '&gt;')"/>
     950        </xsl:when>
    969951    </xsl:choose>
    970952</xsl:template>
     
    10401022                    <xsl:text>.ptr()</xsl:text>
    10411023                </xsl:when>
     1024                <xsl:when test="count(key('G_keyInterfacesByName', $type)) > 0">
     1025                    <xsl:text>.ptr()</xsl:text>
     1026                </xsl:when>
    10421027                <xsl:otherwise>
    1043                     <xsl:variable name="thatif" select="//interface[@name=$type]"/>
    1044                     <xsl:if test="$thatif">
    1045                         <xsl:text>.ptr()</xsl:text>
    1046                     </xsl:if>
     1028                    <xsl:message terminate="yes">Oops #1</xsl:message>
    10471029                </xsl:otherwise>
    10481030            </xsl:choose>
     
    14971479
    14981480<!-- - - - - - - - - - - - - - - - - - - - - - -
    1499   emit all attributes of an interface
     1481  Emit all attributes of an interface (current node).
    15001482  - - - - - - - - - - - - - - - - - - - - - - -->
    15011483<xsl:template name="emitAttributes">
    1502     <xsl:param name="iface"/>
    15031484    <xsl:param name="topclass"/>
    15041485    <xsl:param name="dtracetopclass"/>
     
    15061487
    15071488    <!-- first recurse to emit all base interfaces -->
    1508     <xsl:variable name="extends" select="$iface/@extends"/>
     1489    <xsl:variable name="extends" select="@extends"/>
    15091490    <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
    1510         <xsl:call-template name="emitAttributes">
    1511             <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
    1512             <xsl:with-param name="topclass" select="$topclass"/>
    1513             <xsl:with-param name="pmode" select="$pmode"/>
    1514             <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    1515         </xsl:call-template>
     1491        <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
     1492            <xsl:call-template name="emitAttributes">
     1493                <xsl:with-param name="topclass" select="$topclass"/>
     1494                <xsl:with-param name="pmode" select="$pmode"/>
     1495                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     1496            </xsl:call-template>
     1497        </xsl:for-each>
    15161498    </xsl:if>
    15171499
     
    15201502            <xsl:text>//
    15211503</xsl:text>
    1522             <xsl:value-of select="concat('// ', $iface/@name, ' properties')"/>
     1504            <xsl:value-of select="concat('// ', @name, ' properties')"/>
    15231505            <xsl:text>
    15241506//
     
    15291511        </xsl:when>
    15301512        <xsl:otherwise>
    1531             <xsl:value-of select="concat($G_sNewLine, '    // ', $pmode, ' ', $iface/@name, ' properties', $G_sNewLine)"/>
     1513            <xsl:value-of select="concat($G_sNewLine, '    // ', $pmode, ' ', @name, ' properties', $G_sNewLine)"/>
    15321514        </xsl:otherwise>
    15331515    </xsl:choose>
    15341516    <xsl:choose>
    15351517        <xsl:when test="$pmode='public'">
    1536             <xsl:apply-templates select="$iface/attribute | $iface/if" mode="public">
     1518            <xsl:apply-templates select="./attribute | ./if" mode="public">
    15371519                <xsl:with-param name="emitmode" select="'attribute'"/>
    15381520            </xsl:apply-templates>
    15391521        </xsl:when>
    15401522        <xsl:when test="$pmode='wrapped'">
    1541             <xsl:apply-templates select="$iface/attribute | $iface/if" mode="wrapped">
     1523            <xsl:apply-templates select="./attribute | ./if" mode="wrapped">
    15421524                <xsl:with-param name="emitmode" select="'attribute'"/>
    15431525            </xsl:apply-templates>
    15441526        </xsl:when>
    15451527        <xsl:when test="$pmode='code'">
    1546             <xsl:apply-templates select="$iface/attribute | $iface/if" mode="code">
     1528            <xsl:apply-templates select="./attribute | ./if" mode="code">
    15471529                <xsl:with-param name="topclass" select="$topclass"/>
    15481530                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     
    15511533        </xsl:when>
    15521534        <xsl:when test="$pmode = 'dtrace-probes'">
    1553             <xsl:apply-templates select="$iface/attribute | $iface/if" mode="dtrace-probes">
     1535            <xsl:apply-templates select="./attribute | ./if" mode="dtrace-probes">
    15541536                <xsl:with-param name="topclass" select="$topclass"/>
    15551537                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     
    21122094
    21132095<!-- - - - - - - - - - - - - - - - - - - - - - -
    2114   emit all methods of an interface
     2096  emit all methods of the current interface
    21152097  - - - - - - - - - - - - - - - - - - - - - - -->
    21162098<xsl:template name="emitMethods">
    2117     <xsl:param name="iface"/>
    21182099    <xsl:param name="topclass"/>
    21192100    <xsl:param name="pmode"/>
     
    21212102
    21222103    <!-- first recurse to emit all base interfaces -->
    2123     <xsl:variable name="extends" select="$iface/@extends"/>
     2104    <xsl:variable name="extends" select="@extends"/>
    21242105    <xsl:if test="$extends and not($extends='$unknown') and not($extends='$errorinfo')">
    2125         <xsl:call-template name="emitMethods">
    2126             <xsl:with-param name="iface" select="//interface[@name=$extends]"/>
    2127             <xsl:with-param name="topclass" select="$topclass"/>
    2128             <xsl:with-param name="pmode" select="$pmode"/>
    2129             <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    2130         </xsl:call-template>
     2106        <xsl:for-each select="key('G_keyInterfacesByName', $extends)">
     2107            <xsl:call-template name="emitMethods">
     2108                <xsl:with-param name="topclass" select="$topclass"/>
     2109                <xsl:with-param name="pmode" select="$pmode"/>
     2110                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     2111            </xsl:call-template>
     2112        </xsl:for-each>
    21312113    </xsl:if>
    21322114
     
    21352117            <xsl:text>//
    21362118</xsl:text>
    2137             <xsl:value-of select="concat('// ', $iface/@name, ' methods')"/>
     2119            <xsl:value-of select="concat('// ', @name, ' methods')"/>
    21382120            <xsl:text>
    21392121//
     
    21432125        <xsl:when test="$pmode='dtrace-probes'"/>
    21442126        <xsl:otherwise>
    2145             <xsl:value-of select="concat($G_sNewLine, '    // ', $pmode, ' ', $iface/@name, ' methods', $G_sNewLine)"/>
     2127            <xsl:value-of select="concat($G_sNewLine, '    // ', $pmode, ' ', @name, ' methods', $G_sNewLine)"/>
    21462128        </xsl:otherwise>
    21472129    </xsl:choose>
    21482130    <xsl:choose>
    21492131        <xsl:when test="$pmode='public'">
    2150             <xsl:apply-templates select="$iface/method | $iface/if" mode="public">
     2132            <xsl:apply-templates select="./method | ./if" mode="public">
    21512133                <xsl:with-param name="emitmode" select="'method'"/>
    21522134            </xsl:apply-templates>
    21532135        </xsl:when>
    21542136        <xsl:when test="$pmode='wrapped'">
    2155             <xsl:apply-templates select="$iface/method | $iface/if" mode="wrapped">
     2137            <xsl:apply-templates select="./method | ./if" mode="wrapped">
    21562138                <xsl:with-param name="emitmode" select="'method'"/>
    21572139            </xsl:apply-templates>
    21582140        </xsl:when>
    21592141        <xsl:when test="$pmode='code'">
    2160             <xsl:apply-templates select="$iface/method | $iface/if" mode="code">
     2142            <xsl:apply-templates select="./method | ./if" mode="code">
    21612143                <xsl:with-param name="topclass" select="$topclass"/>
    21622144                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     
    21652147        </xsl:when>
    21662148        <xsl:when test="$pmode='dtrace-probes'">
    2167             <xsl:apply-templates select="$iface/method | $iface/if" mode="dtrace-probes">
     2149            <xsl:apply-templates select="./method | ./if" mode="dtrace-probes">
    21682150                <xsl:with-param name="topclass" select="$topclass"/>
    21692151                <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     
    21762158
    21772159<!-- - - - - - - - - - - - - - - - - - - - - - -
    2178   emit all attributes and methods declarations of an interface
     2160  emit all attributes and methods declarations of the current interface
    21792161  - - - - - - - - - - - - - - - - - - - - - - -->
    21802162<xsl:template name="emitInterfaceDecls">
    2181     <xsl:param name="iface"/>
    21822163    <xsl:param name="pmode"/>
    21832164
    21842165    <!-- attributes -->
    21852166    <xsl:call-template name="emitAttributes">
    2186         <xsl:with-param name="iface" select="$iface"/>
    21872167        <xsl:with-param name="pmode" select="$pmode"/>
    21882168    </xsl:call-template>
     
    21902170    <!-- methods -->
    21912171    <xsl:call-template name="emitMethods">
    2192         <xsl:with-param name="iface" select="$iface"/>
    21932172        <xsl:with-param name="pmode" select="$pmode"/>
    21942173    </xsl:call-template>
     
    21962175
    21972176<!-- - - - - - - - - - - - - - - - - - - - - - -
    2198   emit auxiliary method declarations of an interface
     2177  emit auxiliary method declarations of the current interface
    21992178  - - - - - - - - - - - - - - - - - - - - - - -->
    22002179<xsl:template name="emitAuxMethodDecls">
    2201     <xsl:param name="iface"/>
    22022180    <!-- currently nothing, maybe later some generic FinalConstruct/... helper declaration for ComObjPtr -->
    22032181</xsl:template>
    22042182
    22052183<!-- - - - - - - - - - - - - - - - - - - - - - -
    2206   emit the header file of an interface
     2184  emit the header file of the current interface
    22072185  - - - - - - - - - - - - - - - - - - - - - - -->
    22082186<xsl:template name="emitHeader">
    2209     <xsl:param name="iface"/>
    22102187    <xsl:param name="addinterfaces"/>
    22112188
    2212     <xsl:if test="$generating != 'headers'"> <!-- Paranoia -->
    2213         <xsl:message terminate="yes">
    2214             Did not expect generating='<xsl:value-of select="$generating"/>' in the emitHeader template.
    2215         </xsl:message>
    2216     </xsl:if>
    2217 
    22182189    <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.h')"/>
    22192190
    2220     <xsl:apply-templates select="$iface" mode="startfile">
     2191    <xsl:apply-templates select="." mode="startfile">
    22212192        <xsl:with-param name="file" select="$filename"/>
    22222193    </xsl:apply-templates>
     
    22262197        <xsl:with-param name="type" select="'header'"/>
    22272198    </xsl:call-template>
    2228     <xsl:apply-templates select="$iface" mode="classheader">
     2199    <xsl:apply-templates select="." mode="classheader">
    22292200        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    22302201    </xsl:apply-templates>
     
    22322203    <!-- interface attributes/methods (public) -->
    22332204    <xsl:call-template name="emitInterfaceDecls">
    2234         <xsl:with-param name="iface" select="$iface"/>
    22352205        <xsl:with-param name="pmode" select="'public'"/>
    22362206    </xsl:call-template>
    22372207
    22382208    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    2239         <!-- This is super tricky, as the for-each switches to the node
    2240              set, which means the normal document isn't available any
    2241              more. So need to use the global root node to get back into
    2242              the documemt to find corresponding interface data. -->
     2209        <!-- This is super tricky, as the for-each switches to the node set,
     2210             which means the normal document isn't available any more.  We get
     2211             the data we need, uses a for-each to switch document and then a
     2212             key() to look up the interface by name. -->
    22432213        <xsl:variable name="addifname">
    22442214            <xsl:value-of select="string(.)"/>
    22452215        </xsl:variable>
    2246         <xsl:call-template name="emitInterfaceDecls">
    2247             <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2248             <xsl:with-param name="pmode" select="'public'"/>
    2249         </xsl:call-template>
     2216        <xsl:for-each select="$G_root">
     2217            <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
     2218                <xsl:call-template name="emitInterfaceDecls">
     2219                    <xsl:with-param name="pmode" select="'public'"/>
     2220                </xsl:call-template>
     2221            </xsl:for-each>
     2222        </xsl:for-each>
    22502223    </xsl:for-each>
    22512224
    22522225    <!-- auxiliary methods (public) -->
    2253     <xsl:call-template name="emitAuxMethodDecls">
    2254         <xsl:with-param name="iface" select="$iface"/>
    2255     </xsl:call-template>
     2226    <xsl:call-template name="emitAuxMethodDecls"/>
    22562227
    22572228    <!-- switch to private -->
     
    22612232    <!-- wrapped interface attributes/methods (private) -->
    22622233    <xsl:call-template name="emitInterfaceDecls">
    2263         <xsl:with-param name="iface" select="$iface"/>
    22642234        <xsl:with-param name="pmode" select="'wrapped'"/>
    22652235    </xsl:call-template>
    22662236
    22672237    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    2268         <!-- This is super tricky, as the for-each switches to the node
    2269              set, which means the normal document isn't available any
    2270              more. So need to use the global root node to get back into
    2271              the documemt to find corresponding interface data. -->
     2238        <!-- This is super tricky, as the for-each switches to the node set,
     2239             which means the normal document isn't available any more.  We get
     2240             the data we need, uses a for-each to switch document and then a
     2241             key() to look up the interface by name. -->
    22722242        <xsl:variable name="addifname">
    22732243            <xsl:value-of select="string(.)"/>
    22742244        </xsl:variable>
    2275         <xsl:call-template name="emitInterfaceDecls">
    2276             <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2277             <xsl:with-param name="pmode" select="'wrapped'"/>
    2278         </xsl:call-template>
     2245        <xsl:for-each select="$G_root">
     2246            <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
     2247                <xsl:call-template name="emitInterfaceDecls">
     2248                    <xsl:with-param name="pmode" select="'wrapped'"/>
     2249                </xsl:call-template>
     2250            </xsl:for-each>
     2251        </xsl:for-each>
    22792252    </xsl:for-each>
    22802253
    2281     <xsl:apply-templates select="$iface" mode="classfooter"/>
    2282     <xsl:apply-templates select="$iface" mode="endfile">
     2254    <xsl:apply-templates select="." mode="classfooter"/>
     2255    <xsl:apply-templates select="." mode="endfile">
    22832256        <xsl:with-param name="file" select="$filename"/>
    22842257    </xsl:apply-templates>
     
    22862259
    22872260<!-- - - - - - - - - - - - - - - - - - - - - - -
    2288   emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of an interface
     2261  emit all attributes and methods definitions (pmode=code) or probes (pmode=dtrace-probes) of the current interface
    22892262  - - - - - - - - - - - - - - - - - - - - - - -->
    22902263<xsl:template name="emitInterfaceDefs">
    2291     <xsl:param name="iface"/>
    22922264    <xsl:param name="addinterfaces"/>
    22932265    <xsl:param name="pmode" select="'code'"/>
    22942266
    2295     <xsl:if test="$pmode = 'code'">
    2296         <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', substring($iface/@name, 2), 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
    2297     </xsl:if>
    2298 
     2267    <xsl:variable name="topclass" select="substring(@name, 2)"/>
    22992268    <xsl:variable name="dtracetopclass">
    23002269        <xsl:choose>
    2301             <xsl:when test="$iface/@dtracename"><xsl:value-of select="$iface/@dtracename"/></xsl:when>
    2302             <xsl:otherwise><xsl:value-of select="substring($iface/@name, 2)"/></xsl:otherwise>
     2270            <xsl:when test="@dtracename"><xsl:value-of select="@dtracename"/></xsl:when>
     2271            <xsl:otherwise><xsl:value-of select="$topclass"/></xsl:otherwise>
    23032272        </xsl:choose>
    23042273    </xsl:variable>
     2274
     2275    <xsl:if test="$pmode = 'code'">
     2276        <xsl:value-of select="concat('DEFINE_EMPTY_CTOR_DTOR(', $topclass, 'Wrap)', $G_sNewLine, $G_sNewLine)"/>
     2277    </xsl:if>
    23052278
    23062279    <!-- attributes -->
    23072280    <xsl:call-template name="emitAttributes">
    2308         <xsl:with-param name="iface" select="$iface"/>
    2309         <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
     2281        <xsl:with-param name="topclass" select="$topclass"/>
    23102282        <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    23112283        <xsl:with-param name="pmode" select="$pmode"/>
     
    23142286    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    23152287        <!-- This is super tricky, as the for-each switches to the node set,
    2316              which means the normal document isn't available any more. So need
    2317              to use the global root node to get back into the documemt to find
    2318              corresponding interface data. -->
     2288             which means the normal document isn't available any more.  We get
     2289             the data we need, uses a for-each to switch document and then a
     2290             key() to look up the interface by name. -->
    23192291        <xsl:variable name="addifname">
    23202292            <xsl:value-of select="string(.)"/>
    23212293        </xsl:variable>
    2322         <xsl:call-template name="emitAttributes">
    2323             <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2324             <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
    2325             <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    2326             <xsl:with-param name="pmode" select="$pmode"/>
    2327         </xsl:call-template>
     2294        <xsl:for-each select="$G_root">
     2295            <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
     2296                <xsl:call-template name="emitAttributes">
     2297                    <xsl:with-param name="topclass" select="$topclass"/>
     2298                    <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     2299                    <xsl:with-param name="pmode" select="$pmode"/>
     2300                </xsl:call-template>
     2301            </xsl:for-each>
     2302        </xsl:for-each>
    23282303    </xsl:for-each>
    23292304
    23302305    <!-- methods -->
    23312306    <xsl:call-template name="emitMethods">
    2332         <xsl:with-param name="iface" select="$iface"/>
    2333         <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
     2307        <xsl:with-param name="topclass" select="$topclass"/>
    23342308        <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    23352309        <xsl:with-param name="pmode" select="$pmode"/>
     
    23382312    <xsl:for-each select="exsl:node-set($addinterfaces)/token">
    23392313        <!-- This is super tricky, as the for-each switches to the node set,
    2340              which means the normal document isn't available any more. So need
    2341              to use the global root node to get back into the documemt to find
    2342              corresponding interface data. -->
     2314             which means the normal document isn't available any more.  We get
     2315             the data we need, uses a for-each to switch document and then a
     2316             key() to look up the interface by name. -->
    23432317        <xsl:variable name="addifname">
    23442318            <xsl:value-of select="string(.)"/>
    23452319        </xsl:variable>
    2346         <xsl:call-template name="emitMethods">
    2347             <xsl:with-param name="iface" select="$G_root//interface[@name=$addifname]"/>
    2348             <xsl:with-param name="topclass" select="substring($iface/@name, 2)"/>
    2349             <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
    2350             <xsl:with-param name="pmode" select="$pmode"/>
    2351         </xsl:call-template>
     2320        <xsl:for-each select="$G_root">
     2321            <xsl:for-each select="key('G_keyInterfacesByName', $addifname)">
     2322                <xsl:call-template name="emitMethods">
     2323                    <xsl:with-param name="topclass" select="$topclass"/>
     2324                    <xsl:with-param name="dtracetopclass" select="$dtracetopclass"/>
     2325                    <xsl:with-param name="pmode" select="$pmode"/>
     2326                </xsl:call-template>
     2327            </xsl:for-each>
     2328        </xsl:for-each>
    23522329    </xsl:for-each>
    23532330</xsl:template>
    23542331
    23552332<!-- - - - - - - - - - - - - - - - - - - - - - -
    2356   emit auxiliary method declarations of an interface
     2333  emit auxiliary method declarations of the current interface
    23572334  - - - - - - - - - - - - - - - - - - - - - - -->
    23582335<xsl:template name="emitAuxMethodDefs">
    2359     <xsl:param name="iface"/>
    23602336    <xsl:param name="pmode" select="'code'"/>
    23612337    <!-- currently nothing, maybe later some generic FinalConstruct/... implementation -->
     
    23642340
    23652341<!-- - - - - - - - - - - - - - - - - - - - - - -
    2366   emit the code file of an interface
     2342  emit the code file of the current interface
    23672343  - - - - - - - - - - - - - - - - - - - - - - -->
    23682344<xsl:template name="emitCode">
    2369     <xsl:param name="iface"/>
    23702345    <xsl:param name="addinterfaces"/>
    23712346
    2372     <xsl:if test="$generating != 'sources'"> <!-- Paranoia -->
    2373         <xsl:message terminate="yes">
    2374             Did not expect generating='<xsl:value-of select="$generating"/>' in the emitCode template.
    2375         </xsl:message>
    2376     </xsl:if>
    2377 
    23782347    <xsl:variable name="filename" select="concat(substring(@name, 2), 'Wrap.cpp')"/>
    23792348
    2380     <xsl:apply-templates select="$iface" mode="startfile">
     2349    <xsl:apply-templates select="." mode="startfile">
    23812350        <xsl:with-param name="file" select="$filename"/>
    23822351    </xsl:apply-templates>
     
    23862355        <xsl:with-param name="type" select="'code'"/>
    23872356    </xsl:call-template>
    2388     <xsl:apply-templates select="$iface" mode="codeheader">
     2357    <xsl:apply-templates select="." mode="codeheader">
    23892358        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    23902359    </xsl:apply-templates>
     
    23922361    <!-- interface attributes/methods (public) -->
    23932362    <xsl:call-template name="emitInterfaceDefs">
    2394         <xsl:with-param name="iface" select="$iface"/>
    23952363        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2364    </xsl:call-template>
     2365
     2366    <!-- auxiliary methods (public) -->
     2367    <xsl:call-template name="emitAuxMethodDefs"/>
     2368
     2369    <xsl:apply-templates select="." mode="codefooter">
     2370        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2371    </xsl:apply-templates>
     2372    <xsl:apply-templates select="." mode="endfile">
     2373        <xsl:with-param name="file" select="$filename"/>
     2374    </xsl:apply-templates>
     2375</xsl:template>
     2376
     2377<!-- - - - - - - - - - - - - - - - - - - - - - -
     2378  emit the DTrace probes for the current interface
     2379  - - - - - - - - - - - - - - - - - - - - - - -->
     2380<xsl:template name="emitDTraceProbes">
     2381    <xsl:param name="addinterfaces"/>
     2382
     2383    <!-- interface attributes/methods (public) -->
     2384    <xsl:call-template name="emitInterfaceDefs">
     2385        <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
     2386        <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
    23962387    </xsl:call-template>
    23972388
    23982389    <!-- auxiliary methods (public) -->
    23992390    <xsl:call-template name="emitAuxMethodDefs">
    2400         <xsl:with-param name="iface" select="$iface"/>
    2401     </xsl:call-template>
    2402 
    2403     <xsl:apply-templates select="$iface" mode="codefooter">
    2404         <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2405     </xsl:apply-templates>
    2406     <xsl:apply-templates select="$iface" mode="endfile">
    2407         <xsl:with-param name="file" select="$filename"/>
    2408     </xsl:apply-templates>
    2409 </xsl:template>
    2410 
    2411 <!-- - - - - - - - - - - - - - - - - - - - - - -
    2412   emit the DTrace probes for an interface
    2413   - - - - - - - - - - - - - - - - - - - - - - -->
    2414 <xsl:template name="emitDTraceProbes">
    2415     <xsl:param name="iface"/>
    2416     <xsl:param name="addinterfaces"/>
    2417 
    2418     <xsl:if test="$generating != 'dtrace-probes'"> <!-- Paranoia -->
    2419         <xsl:message terminate="yes">
    2420             Did not expect generating='<xsl:value-of select="$generating"/>' in the emitDTraceProbes template.
    2421         </xsl:message>
    2422     </xsl:if>
    2423 
    2424     <!-- interface attributes/methods (public) -->
    2425     <xsl:call-template name="emitInterfaceDefs">
    2426         <xsl:with-param name="iface" select="$iface"/>
    2427         <xsl:with-param name="addinterfaces" select="$addinterfaces"/>
    2428         <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
    2429     </xsl:call-template>
    2430 
    2431     <!-- auxiliary methods (public) -->
    2432     <xsl:call-template name="emitAuxMethodDefs">
    2433         <xsl:with-param name="iface" select="$iface"/>
    24342391        <xsl:with-param name="pmode">dtrace-probes</xsl:with-param>
    24352392    </xsl:call-template>
     
    24602417<xsl:template match="interface">
    24612418    <xsl:if test="not(@internal='yes') and not(@supportsErrorInfo='no')">
    2462         <xsl:call-template name="emitInterface">
    2463             <xsl:with-param name="iface" select="."/>
    2464         </xsl:call-template>
     2419        <xsl:call-template name="emitInterface"/>
    24652420    </xsl:if>
    24662421</xsl: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