VirtualBox

Changeset 53942 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 23, 2015 2:35:01 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97820
Message:

COMWrappers.xsl: Simplified and optimized a few /interface and /enum search, inserted regular text output element flush hacks. Execution time dwon from 10-11 seconds to below 2 seconds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/COMWrappers.xsl

    r53460 r53942  
    2323<xsl:strip-space elements="*"/>
    2424
    25 
    26 <!--
    27  *  Capitalizes the first letter:
    28 -->
    29 <xsl:template name="capitalize">
    30   <xsl:param name="str" select="."/>
    31   <xsl:value-of select="
    32     concat(
    33       translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
    34       substring($str,2)
    35     )
    36   "/>
    37 </xsl:template>
    38 
    39 <!--
    40  *  Uncapitalizes the first letter only if the second one is not capital
    41  *  otherwise leaves the string unchanged:
    42 -->
    43 <xsl:template name="uncapitalize">
    44   <xsl:param name="str" select="."/>
    45   <xsl:choose>
    46     <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
    47       <xsl:value-of select="
    48         concat(
    49           translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
    50           substring($str,2)
    51         )
    52       "/>
    53     </xsl:when>
    54     <xsl:otherwise>
    55       <xsl:value-of select="string($str)"/>
    56     </xsl:otherwise>
    57   </xsl:choose>
    58 </xsl:template>
    59 
    60 
    61 <!--
    62  *  Translates the string to uppercase:
    63 -->
    64 <xsl:template name="uppercase">
    65   <xsl:param name="str" select="."/>
    66   <xsl:value-of select="
    67     translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    68   "/>
    69 </xsl:template>
     25<xsl:include href="../../../../Main/idl/typemap-shared.inc.xsl" />
     26
     27
     28<!--
     29 * Keys for more efficiently looking up of types.
     30-->
     31<xsl:key name="G_keyEnumsByName" match="//enum[@name]" use="@name"/>
     32<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
    7033
    7134
     
    8346<xsl:template name="endFile">
    8447  <xsl:param name="file" />
    85   <xsl:value-of select="concat('&#10;// ##### ENDFILE &quot;', $file, '&quot;&#10;&#10;')" />
     48  <xsl:call-template name="xsltprocNewlineOutputHack"/>
     49  <xsl:value-of select="concat('// ##### ENDFILE &quot;', $file, '&quot;&#10;&#10;')" />
    8650</xsl:template>
    8751
     
    682646  <xsl:text>// </xsl:text>
    683647  <xsl:value-of select="@name"/>
    684   <xsl:text> wrapper&#x0A;&#x0A;</xsl:text>
     648  <xsl:text> wrapper&#x0A;</xsl:text>
     649  <xsl:call-template name="xsltprocNewlineOutputHack"/>
    685650
    686651  <xsl:if test="name()='interface'">
     
    12681233<xsl:template name="tryComposeFetchErrorInfo">
    12691234  <xsl:param name="mode" select="''"/>
     1235
    12701236  <xsl:variable name="ifaceSupportsErrorInfo" select="
    12711237    ancestor-or-self::interface[1]/@supportsErrorInfo
    12721238  "/>
    12731239  <xsl:variable name="librarySupportsErrorInfo" select="ancestor::library/@supportsErrorInfo"/>
     1240
    12741241  <xsl:choose>
    12751242    <xsl:when test="$ifaceSupportsErrorInfo">
     
    12911258  <xsl:param name="supports" select="''"/>
    12921259  <xsl:param name="mode" select="''"/>
     1260
    12931261  <xsl:choose>
    12941262    <xsl:when test="$mode='getBaseClassName'">
     
    13121280
    13131281<xsl:template name="composeMethodCallParam">
    1314 
    13151282  <xsl:param name="isIn" select="@dir='in'"/>
    13161283  <xsl:param name="isOut" select="@dir='out' or @dir='return'"/>
    1317 
    1318   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    13191284
    13201285  <xsl:choose>
     
    13541319    </xsl:when>
    13551320    <!-- enum types -->
    1356     <xsl:when test="
    1357       (ancestor::library/enum[@name=current()/@type]) or
    1358       (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
    1359     ">
     1321    <xsl:when test="count(key('G_keyEnumsByName', current()/@type)) > 0">
    13601322      <xsl:choose>
    13611323        <xsl:when test="$isIn">
     
    13811343    </xsl:when>
    13821344    <!-- interface types -->
    1383     <xsl:when test="
    1384       @type='$unknown' or
    1385       ((ancestor::library/interface[@name=current()/@type]) or
    1386        (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
    1387       )
    1388     ">
     1345    <xsl:when test="@type='$unknown' or (count(key('G_keyInterfacesByName', current()/@type)) > 0)">
    13891346      <xsl:choose>
    13901347        <xsl:when test="$isIn">
     
    14331390-->
    14341391<xsl:template match="attribute/@type | param/@type">
    1435   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    1436 
    14371392  <xsl:choose>
    14381393    <!-- modifiers -->
     
    15231478        <!-- system interface types -->
    15241479        <xsl:when test=".='$unknown'">CUnknown</xsl:when>
     1480        <!-- enum types -->
     1481        <xsl:when test="count(key('G_keyEnumsByName', current())) > 0">
     1482          <xsl:value-of select="concat('K',string(.))"/>
     1483        </xsl:when>
     1484        <!-- custom interface types -->
     1485        <xsl:when test="count(key('G_keyInterfacesByName', current())) > 0">
     1486          <xsl:value-of select="concat('C',substring(.,2))"/>
     1487        </xsl:when>
     1488        <!-- other types -->
    15251489        <xsl:otherwise>
    1526           <xsl:choose>
    1527             <!-- enum types -->
    1528             <xsl:when test="
    1529               (ancestor::library/enum[@name=current()]) or
    1530               (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    1531             ">
    1532               <xsl:value-of select="concat('K',string(.))"/>
    1533             </xsl:when>
    1534             <!-- custom interface types -->
    1535             <xsl:when test="
    1536               ((ancestor::library/interface[@name=current()]) or
    1537                (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1538               )
    1539             ">
    1540               <xsl:value-of select="concat('C',substring(.,2))"/>
    1541             </xsl:when>
    1542             <!-- other types -->
    1543             <xsl:otherwise>
    1544               <xsl:message terminate="yes">
    1545                 <xsl:text>Unknown parameter type: </xsl:text>
    1546                 <xsl:value-of select="."/>
    1547               </xsl:message>
    1548             </xsl:otherwise>
    1549           </xsl:choose>
     1490          <xsl:message terminate="yes"><xsl:text>Unknown parameter type: </xsl:text><xsl:value-of select="."/></xsl:message>
    15501491        </xsl:otherwise>
    15511492      </xsl:choose>
     
    15641505-->
    15651506<xsl:template match="attribute/@type | param/@type" mode="initializer">
    1566 
    1567   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    1568 
    15691507  <xsl:choose>
    15701508    <!-- safearrays don't need initializers -->
     
    16381576        <xsl:when test=".='string'"> = NULL</xsl:when>
    16391577        <xsl:when test=".='wchar'"> = 0</xsl:when>
    1640         <xsl:otherwise>
    1641           <xsl:choose>
    1642             <!-- enum types initialized with 0 -->
    1643             <xsl:when test="
    1644               (ancestor::library/enum[@name=current()]) or
    1645               (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    1646             ">
    1647               <xsl:value-of select="concat(' = (K',string(.),') 0')"/>
    1648             </xsl:when>
    1649           </xsl:choose>
    1650         </xsl:otherwise>
     1578        <!-- enum types initialized with 0 -->
     1579        <xsl:when test="count(key('G_keyEnumsByName', current())) > 0">
     1580          <xsl:value-of select="concat(' = (K',string(.),') 0')"/>
     1581        </xsl:when>
    16511582      </xsl:choose>
    16521583    </xsl:otherwise>
     
    16591590-->
    16601591<xsl:template match="attribute/@type | param/@type" mode="param">
    1661 
    1662   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    1663 
    16641592  <xsl:choose>
    16651593    <!-- class types -->
    16661594    <xsl:when test="
    1667       .='string' or
    1668       .='wstring' or
    1669       ../@safearray='yes' or
    1670       ((ancestor::library/enum[@name=current()]) or
    1671        (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    1672       ) or
    1673       .='$unknown' or
    1674       ((ancestor::library/interface[@name=current()]) or
    1675        (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1676       )
     1595         . = 'string'
     1596      or . = 'wstring'
     1597      or . = '$unknown'
     1598      or ../@safearray = 'yes'
     1599      or (count(key('G_keyEnumsByName',      current())) > 0)
     1600      or (count(key('G_keyInterfacesByName', current())) > 0)
    16771601    ">
    16781602      <xsl:choose>
     
    17271651-->
    17281652<xsl:template match="attribute/@type | param/@type" mode="com">
    1729 
    1730   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    1731 
    17321653  <xsl:choose>
    17331654    <!-- modifiers -->
     
    18031724        <!-- system interface types -->
    18041725        <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
     1726        <!-- enum types -->
     1727        <xsl:when test="count(key('G_keyEnumsByName', current())) > 0">
     1728          <xsl:value-of select="."/>
     1729        </xsl:when>
     1730        <!-- custom interface types -->
     1731        <xsl:when test="count(key('G_keyInterfacesByName', current())) > 0">
     1732          <xsl:value-of select="."/><xsl:text> *</xsl:text>
     1733        </xsl:when>
     1734        <!-- other types -->
    18051735        <xsl:otherwise>
    1806           <xsl:choose>
    1807             <!-- enum types -->
    1808             <xsl:when test="
    1809               (ancestor::library/enum[@name=current()]) or
    1810               (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    1811             ">
    1812               <xsl:value-of select="."/>
    1813             </xsl:when>
    1814             <!-- custom interface types -->
    1815             <xsl:when test="
    1816               ((ancestor::library/interface[@name=current()]) or
    1817                (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    1818               )
    1819             ">
    1820               <xsl:value-of select="."/><xsl:text> *</xsl:text>
    1821             </xsl:when>
    1822             <!-- other types -->
    1823             <xsl:otherwise>
    1824               <xsl:message terminate="yes">
    1825                 <xsl:text>Unknown parameter type: </xsl:text>
    1826                 <xsl:value-of select="."/>
    1827               </xsl:message>
    1828             </xsl:otherwise>
    1829           </xsl:choose>
     1736          <xsl:message terminate="yes">
     1737            <xsl:text>Unknown parameter type: </xsl:text>
     1738            <xsl:value-of select="."/>
     1739          </xsl:message>
    18301740        </xsl:otherwise>
    18311741      </xsl:choose>
     
    18471757-->
    18481758<xsl:template name="hooks">
    1849 
    18501759  <xsl:param name="when" select="''"/>
    18511760  <xsl:param name="isSetter" select="''"/>
    18521761
    1853   <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    1854 
    1855   <xsl:variable name="is_iface" select="(
    1856     ((ancestor::library/interface[@name=current()/@type]) or
    1857      (ancestor::library/if[@target=$self_target]/interface[@name=current()/@type])
    1858     )
    1859   )"/>
    1860 
    1861   <xsl:variable name="is_enum" select="(
    1862     (ancestor::library/enum[@name=current()/@type]) or
    1863     (ancestor::library/if[@target=$self_target]/enum[@name=current()/@type])
    1864   )"/>
    1865 
     1762  <xsl:variable name="is_iface" select="count(key('G_keyInterfacesByName', current()/@type)) > 0"/>
    18661763  <xsl:variable name="is_out" select="(
    18671764      (name()='attribute' and not($isSetter)) or
     
    18711768  <xsl:choose>
    18721769    <xsl:when test="$when='pre-call'">
     1770      <xsl:variable name="is_enum" select="count(key('G_keyEnumsByName', current()/@type)) > 0"/>
    18731771      <xsl:choose>
    18741772        <xsl:when test="@safearray='yes'">
Note: See TracChangeset for help on using the changeset viewer.

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