VirtualBox

Changeset 53925 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jan 22, 2015 4:31:55 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97798
Message:

websrv-wsdl2gsoapH.xsl: Use xsl:key and key() to optimize four expensive lookups, don't use emitNewline, call xsltprocNewlineOutputHack once in a while. Execution time went from 14-15 seconds to less than half a second.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/websrv-wsdl2gsoapH.xsl

    r45483 r53925  
    5353
    5454<!-- - - - - - - - - - - - - - - - - - - - - - -
     55  Keys for more efficiently looking up of stuff
     56 - - - - - - - - - - - - - - - - - - - - - - -->
     57
     58<xsl:key name="G_keyMessagesByName" match="//wsdl:message[@name]" use="@name"/>
     59<xsl:key name="G_keySimpleTypesByName" match="//xsd:simpleType[@name]" use="@name"/>
     60<xsl:key name="G_keyComplexTypesByName" match="//xsd:complexType[@name]" use="@name"/>
     61
     62
     63<!-- - - - - - - - - - - - - - - - - - - - - - -
    5564  root match
    5665 - - - - - - - - - - - - - - - - - - - - - - -->
     
    92101    void *fault;
    93102    _XML __any;
    94 };</xsl:text>
    95   <xsl:call-template name="emitNewline" />
     103};
     104</xsl:text>
    96105
    97106  <xsl:apply-templates />
     
    102111  <xsl:param name="ctype" />
    103112
    104   <xsl:value-of select="concat('class ', $ctype)" />
    105   <xsl:call-template name="emitNewline" />
    106   <xsl:text>{</xsl:text>
    107   <xsl:call-template name="emitNewline" />
    108   <xsl:text>    public:</xsl:text>
    109   <xsl:call-template name="emitNewline" />
     113  <xsl:value-of select="concat('class ', $ctype, $G_sNewLine)" />
     114  <xsl:text>{
     115    public:
     116</xsl:text>
    110117  <xsl:for-each select="xsd:element">
    111118    <xsl:variable name="typefield" select="@type" />
     
    127134      </xsl:when>
    128135      <!-- is there an enum of this type? (look up in simple types) -->
    129       <xsl:when test="//xsd:simpleType[@name=$withoutvboxtypefield]">
     136      <xsl:when test="count(key('G_keySimpleTypesByName', $withoutvboxtypefield)) > 0">
    130137        <xsl:variable name="enumname">
    131138          <xsl:value-of select="concat('enum vbox__', $withoutvboxtypefield)" />
     
    141148      </xsl:when>
    142149      <!-- is this one of the vbox types? (look up in complex types) -->
    143       <xsl:when test="//xsd:complexType[@name=$withoutvboxtypefield]">
     150      <xsl:when test="count(key('G_keyComplexTypesByName', $withoutvboxtypefield)) > 0">
    144151        <!-- array or simple type: depends on whether maxOccurs="unbounded" is in WSDL -->
    145152        <xsl:choose>
     
    161168        </xsl:call-template>
    162169    </xsl:variable>
    163     <xsl:value-of select="concat(' ', $underscoredname, ' 1;')" />
    164     <xsl:call-template name="emitNewline" />
    165   </xsl:for-each>
    166   <xsl:text>        struct soap *soap;</xsl:text>
    167   <xsl:call-template name="emitNewline" />
    168   <xsl:text>};</xsl:text>
    169   <xsl:call-template name="emitNewline" />
    170   <xsl:call-template name="emitNewline" />
     170    <xsl:value-of select="concat(' ', $underscoredname, ' 1;', $G_sNewLine)" />
     171  </xsl:for-each>
     172  <xsl:text>        struct soap *soap;
     173};
     174</xsl:text>
     175<xsl:call-template name="xsltprocNewlineOutputHack"/>
     176
    171177</xsl:template>
    172178
     
    178184    <xsl:for-each select="xsd:restriction">
    179185      <xsl:value-of select="concat('enum ', $ctype)" />
    180       <xsl:call-template name="emitNewline" />
    181       <xsl:text>{</xsl:text>
    182       <xsl:call-template name="emitNewline" />
     186      <xsl:text>
     187{
     188</xsl:text>
    183189      <xsl:for-each select="xsd:enumeration">
    184190        <xsl:variable name="underscoredname">
     
    191197          <xsl:text >,</xsl:text>
    192198        </xsl:if>
    193         <xsl:call-template name="emitNewline" />
     199        <xsl:text>
     200</xsl:text>
    194201      </xsl:for-each>
    195       <xsl:text>};</xsl:text>
    196       <xsl:call-template name="emitNewline" />
    197       <xsl:call-template name="emitNewline" />
     202      <xsl:text>};
     203
     204</xsl:text>
    198205    </xsl:for-each>
    199206  </xsl:for-each>
     
    233240<xsl:template match="wsdl:portType">
    234241
    235   <xsl:value-of select="concat('//gsoap vbox service name: vbox', $G_bindingSuffix)" />
    236   <xsl:call-template name="emitNewline" />
    237   <xsl:value-of select="concat('//gsoap vbox service type: vbox', $G_portTypeSuffix)" />
    238   <xsl:call-template name="emitNewline" />
    239   <xsl:value-of select="concat('//gsoap vbox service namespace: ', $G_targetNamespace, $G_targetNamespaceSeparator)" />
    240   <xsl:call-template name="emitNewline" />
    241   <xsl:value-of select="concat('//gsoap vbox service transport: ', 'http://schemas.xmlsoap.org/soap/http')" />
    242   <xsl:call-template name="emitNewline" />
     242  <xsl:value-of select="concat('//gsoap vbox service name: vbox', $G_bindingSuffix, $G_sNewLine)" />
     243  <xsl:value-of select="concat('//gsoap vbox service type: vbox', $G_portTypeSuffix, $G_sNewLine)" />
     244  <xsl:value-of select="concat('//gsoap vbox service namespace: ', $G_targetNamespace, $G_targetNamespaceSeparator, $G_sNewLine)" />
     245  <xsl:value-of select="concat('//gsoap vbox service transport: ', 'http://schemas.xmlsoap.org/soap/http', $G_sNewLine)" />
    243246
    244247  <xsl:for-each select="wsdl:operation">
     
    252255    <xsl:variable name="responsemsg" select="concat($methodname, $G_methodResponse)" />
    253256
    254     <xsl:call-template name="emitNewline" />
    255     <xsl:value-of select="concat('//gsoap vbox service method-style:    ', $cmethodname, ' ', $G_basefmt)" />
    256     <xsl:call-template name="emitNewline" />
    257     <xsl:value-of select="concat('//gsoap vbox service method-encoding: ', $cmethodname, ' ', $G_parmfmt)" />
    258     <xsl:call-template name="emitNewline" />
    259     <xsl:value-of select="concat('//gsoap vbox service method-action:   ', $cmethodname, ' &quot;&quot;')" />
    260     <xsl:call-template name="emitNewline" />
    261     <xsl:value-of select="concat('//gsoap vbox service method-fault:    ', $cmethodname, ' vbox__InvalidObjectFault')" />
    262     <xsl:call-template name="emitNewline" />
    263     <xsl:value-of select="concat('//gsoap vbox service method-fault:    ', $cmethodname, ' vbox__RuntimeFault')" />
    264     <xsl:call-template name="emitNewline" />
    265     <xsl:value-of select="concat('int __vbox__', $cmethodname, '(')" />
    266     <xsl:call-template name="emitNewline" />
     257    <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-style:    ', $cmethodname, ' ', $G_basefmt)" />
     258    <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-encoding: ', $cmethodname, ' ', $G_parmfmt)" />
     259    <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-action:   ', $cmethodname, ' &quot;&quot;')" />
     260    <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-fault:    ', $cmethodname, ' vbox__InvalidObjectFault')" />
     261    <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-fault:    ', $cmethodname, ' vbox__RuntimeFault')" />
     262    <xsl:value-of select="concat($G_sNewLine, 'int __vbox__', $cmethodname, '(', $G_sNewLine)" />
    267263
    268264    <!-- request element -->
    269     <xsl:variable name="reqtype" select="//wsdl:message[@name=$requestmsg]/wsdl:part/@element" />
     265    <xsl:variable name="reqtype" select="key('G_keyMessagesByName', $requestmsg)/wsdl:part/@element" />
    270266    <xsl:if test="not($reqtype)">
    271267      <xsl:call-template name="fatalError">
     
    278274      </xsl:call-template>
    279275    </xsl:variable>
    280     <xsl:value-of select="concat('    _vbox__', $creqtype, '* vbox__', $creqtype, ',')"/>
    281     <xsl:call-template name="emitNewline" />
     276    <xsl:value-of select="concat('    _vbox__', $creqtype, '* vbox__', $creqtype, ',', $G_sNewLine)"/>
    282277    <!-- response element -->
    283     <xsl:variable name="resptype" select="//wsdl:message[@name=$responsemsg]/wsdl:part/@element" />
     278    <xsl:variable name="resptype" select="key('G_keyMessagesByName', $responsemsg)/wsdl:part/@element" />
    284279    <xsl:if test="not($resptype)">
    285280      <xsl:call-template name="fatalError">
     
    292287      </xsl:call-template>
    293288    </xsl:variable>
    294     <xsl:value-of select="concat('    _vbox__', $cresptype, '* vbox__', $cresptype)"/>
    295     <xsl:call-template name="emitNewline" />
     289    <xsl:value-of select="concat('    _vbox__', $cresptype, '* vbox__', $cresptype, $G_sNewLine)"/>
    296290
    297291    <xsl:text>);</xsl:text>
    298     <xsl:call-template name="emitNewline" />
     292    <xsl:call-template name="xsltprocNewlineOutputHack"/>
    299293
    300294  </xsl:for-each>
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