VirtualBox

Changeset 53938 in vbox


Ignore:
Timestamp:
Jan 22, 2015 8:58:37 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97814
Message:

capiidl.xsl: Must use xsl:key+key() to access interface[@name=?]. Moved uppercase/lowercase code to shared style sheet.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/cbinding/Makefile.kmk

    r53805 r53938  
    6464$$(CAPIHeaders_0_OUTDIR)/VBoxCAPI.h: \
    6565                $(PATH_SUB_CURRENT)/capiidl.xsl \
     66                $(PATH_SUB_CURRENT)/../idl/typemap-shared.inc.xsl \
    6667                $(VBOX_XIDL_FILE) \
    6768                | $$(dir $$@)
  • trunk/src/VBox/Main/cbinding/capiidl.xsl

    r52848 r53938  
    88 *  compiler (which simultaneously supports C and C++, unlike XPCOM).
    99
    10     Copyright (C) 2008-2014 Oracle Corporation
     10    Copyright (C) 2008-2015 Oracle Corporation
    1111
    1212    This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525
    2626
     27<xsl:include href="../idl/typemap-shared.inc.xsl"/>
     28
    2729<!--
    28 //  helper definitions
     30//  Keys for more efficiently looking up of types.
    2931/////////////////////////////////////////////////////////////////////////////
    3032-->
    3133
    32 <!--
    33  *  capitalizes the first letter
    34 -->
    35 <xsl:template name="capitalize">
    36   <xsl:param name="str" select="."/>
    37   <xsl:value-of select="
    38     concat(
    39       translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
    40       substring($str,2)
    41     )
    42   "/>
    43 </xsl:template>
    44 
    45 <!--
    46  *  uncapitalizes the first letter only if the second one is not capital
    47  *  otherwise leaves the string unchanged
    48 -->
    49 <xsl:template name="uncapitalize">
    50   <xsl:param name="str" select="."/>
    51   <xsl:choose>
    52     <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
    53       <xsl:value-of select="
    54         concat(
    55           translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
    56           substring($str,2)
    57         )
    58       "/>
    59     </xsl:when>
    60     <xsl:otherwise>
    61       <xsl:value-of select="string($str)"/>
    62     </xsl:otherwise>
    63   </xsl:choose>
    64 </xsl:template>
    65 
    66 <!--
    67  *  translates the string to uppercase
    68 -->
    69 <xsl:template name="uppercase">
    70   <xsl:param name="str" select="."/>
    71   <xsl:value-of select="
    72     translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    73   "/>
    74 </xsl:template>
    75 
    76 
    77 <!--
    78  *  translates the string to lowercase
    79 -->
    80 <xsl:template name="lowercase">
    81   <xsl:param name="str" select="."/>
    82   <xsl:value-of select="
    83     translate($str,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')
    84   "/>
    85 </xsl:template>
     34<xsl:key name="G_keyInterfacesByName" match="//interface[@name]" use="@name"/>
    8635
    8736
     
    12473
    12574/*
    126  * Copyright (C) 2008-2014 Oracle Corporation
     75 * Copyright (C) 2008-2015 Oracle Corporation
    12776 *
    12877 * This file is part of a free software library; you can redistribute
     
    12581207#endif /* !VBOX_WITH_GLUE */
    12591208};
    1260 
    12611209</xsl:text>
     1210 <xsl:call-template name="xsltprocNewlineOutputHack"/>
    12621211 <xsl:apply-templates/>
    12631212 <xsl:text>
     
    16271576<xsl:template match="library">
    16281577  <!-- result codes -->
    1629   <xsl:text>&#x0A;</xsl:text>
     1578  <xsl:call-template name="xsltprocNewlineOutputHack"/>
    16301579  <xsl:for-each select="result">
    16311580    <xsl:apply-templates select="."/>
    16321581  </xsl:for-each>
    1633   <xsl:text>&#x0A;&#x0A;</xsl:text>
     1582  <xsl:call-template name="xsltprocNewlineOutputHack"/>
     1583  <xsl:call-template name="xsltprocNewlineOutputHack"/>
    16341584  <!-- forward declarations -->
    16351585  <xsl:apply-templates select="interface | if/interface" mode="forward"/>
    1636   <xsl:text>&#x0A;</xsl:text>
     1586  <xsl:call-template name="xsltprocNewlineOutputHack"/>
    16371587  <!-- typedef'ing the struct declarations -->
    16381588  <xsl:apply-templates select="interface | if/interface" mode="typedef"/>
    1639   <xsl:text>&#x0A;</xsl:text>
     1589  <xsl:call-template name="xsltprocNewlineOutputHack"/>
    16401590  <!-- all enums go first -->
    16411591  <xsl:apply-templates select="enum | if/enum"/>
     
    17701720    </xsl:when>
    17711721    <xsl:otherwise>
    1772       <xsl:apply-templates select="//interface[@name=$extends]" mode="cobjmacro">
     1722      <xsl:apply-templates select="key('G_keyInterfacesByName', $extends)" mode="cobjmacro">
    17731723        <xsl:with-param name="iface" select="$iface"/>
    17741724      </xsl:apply-templates>
     
    18471797    </xsl:when>
    18481798    <xsl:otherwise>
    1849       <xsl:apply-templates select="//interface[@name=$extends]" mode="vtab_flat">
     1799      <xsl:apply-templates select="key('G_keyInterfacesByName', $extends)" mode="vtab_flat">
    18501800        <xsl:with-param name="iface" select="$iface"/>
    18511801      </xsl:apply-templates>
     
    18721822    <xsl:text> declaration */&#x0A;</xsl:text>
    18731823    <xsl:text>#define </xsl:text>
    1874     <xsl:call-template name="uppercase">
     1824    <xsl:call-template name="string-to-upper">
    18751825      <xsl:with-param name="str" select="@name"/>
    18761826    </xsl:call-template>
     
    18781828    <xsl:text>&#x0A;</xsl:text>
    18791829    <xsl:text>#define </xsl:text>
    1880     <xsl:call-template name="uppercase">
     1830    <xsl:call-template name="string-to-upper">
    18811831      <xsl:with-param name="str" select="@name"/>
    18821832    </xsl:call-template>
     
    19111861        <xsl:value-of select="@extends"/>
    19121862        <xsl:text>_vtbl </xsl:text>
    1913         <xsl:call-template name="lowercase">
     1863        <xsl:call-template name="string-to-lower">
    19141864          <xsl:with-param name="str" select="@extends"/>
    19151865        </xsl:call-template>
     
    19531903    <xsl:text>/* End of struct </xsl:text>
    19541904    <xsl:value-of select="@name"/>
    1955     <xsl:text> declaration */&#x0A;&#x0A;&#x0A;</xsl:text>
     1905    <xsl:text> declaration */&#x0A;&#x0A;</xsl:text>
     1906    <xsl:call-template name="xsltprocNewlineOutputHack"/>
    19561907  </xsl:if>
    19571908</xsl:template>
     
    22212172  <xsl:text>&#x0A;</xsl:text>
    22222173  <xsl:text>#define NS_</xsl:text>
    2223   <xsl:call-template name="uppercase">
     2174  <xsl:call-template name="string-to-upper">
    22242175    <xsl:with-param name="str" select="@name"/>
    22252176  </xsl:call-template>
     
    22392190  <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
    22402191  <xsl:text>#define NS_</xsl:text>
    2241   <xsl:call-template name="uppercase">
     2192  <xsl:call-template name="string-to-upper">
    22422193    <xsl:with-param name="str" select="@name"/>
    22432194  </xsl:call-template>
     
    22652216  <xsl:text> declaration */&#x0A;</xsl:text>
    22662217  <xsl:text>#define </xsl:text>
    2267   <xsl:call-template name="uppercase">
     2218  <xsl:call-template name="string-to-upper">
    22682219    <xsl:with-param name="str" select="@name"/>
    22692220  </xsl:call-template>
     
    22712222  <xsl:text>&#x0A;</xsl:text>
    22722223  <xsl:text>#define </xsl:text>
    2273   <xsl:call-template name="uppercase">
     2224  <xsl:call-template name="string-to-upper">
    22742225    <xsl:with-param name="str" select="@name"/>
    22752226  </xsl:call-template>
  • trunk/src/VBox/Main/idl/typemap-shared.inc.xsl

    r53934 r53938  
    386386</xsl:template>
    387387
     388
     389<!--
     390    string-to-upper - translates the string to uppercase.
     391    -->
     392<xsl:template name="string-to-upper">
     393  <xsl:param name="str" select="."/>
     394  <xsl:value-of select="translate($str, $G_lowerCase, $G_upperCase)"/>
     395</xsl:template>
     396
     397<!--
     398    string-to-lower - translates the string to lowercase.
     399    -->
     400<xsl:template name="string-to-lower">
     401  <xsl:param name="str" select="."/>
     402  <xsl:value-of select="translate($str, $G_upperCase, $G_lowerCase)"/>
     403</xsl:template>
     404
    388405<!--
    389406    string-replace - Replace all occurencees of needle in haystack.
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