VirtualBox

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


Ignore:
Timestamp:
Feb 29, 2008 11:36:31 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28535
Message:

Main/xml: Ident 4 -> 2.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/doxygen.xsl

    r6875 r7216  
    3333-->
    3434<xsl:template name="uncapitalize">
    35     <xsl:param name="str" select="."/>
    36     <xsl:choose>
    37         <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
    38             <xsl:value-of select="
    39                 concat(
    40                     translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
    41                     substring($str,2)
    42                 )
    43             "/>
    44         </xsl:when>
    45         <xsl:otherwise>
    46             <xsl:value-of select="string($str)"/>
    47         </xsl:otherwise>
    48     </xsl:choose>
     35  <xsl:param name="str" select="."/>
     36  <xsl:choose>
     37    <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
     38      <xsl:value-of select="
     39        concat(
     40          translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
     41          substring($str,2)
     42        )
     43      "/>
     44    </xsl:when>
     45    <xsl:otherwise>
     46      <xsl:value-of select="string($str)"/>
     47    </xsl:otherwise>
     48  </xsl:choose>
    4949</xsl:template>
    5050
     
    5353-->
    5454<xsl:template name="uppercase">
    55     <xsl:param name="str" select="."/>
    56     <xsl:value-of select="
    57         translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    58     "/>
     55  <xsl:param name="str" select="."/>
     56  <xsl:value-of select="
     57    translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
     58  "/>
    5959</xsl:template>
    6060
     
    7878-->
    7979<xsl:template match="desc//*">
    80     <xsl:copy>
    81         <xsl:apply-templates/>
    82     </xsl:copy>
     80  <xsl:copy>
     81    <xsl:apply-templates/>
     82  </xsl:copy>
    8383</xsl:template>
    8484
     
    8787-->
    8888<xsl:template match="desc//p">
    89     <xsl:text>&#x0A;</xsl:text>
    90     <xsl:apply-templates/>
    91     <xsl:text>&#x0A;</xsl:text>
     89  <xsl:text>&#x0A;</xsl:text>
     90  <xsl:apply-templates/>
     91  <xsl:text>&#x0A;</xsl:text>
    9292</xsl:template>
    9393
     
    9696-->
    9797<xsl:template match="desc//link">
    98     <xsl:text>@link </xsl:text>
    99     <!--
    100      *  sometimes Doxygen is stupid and cannot resolve global enums properly,
    101      *  thinking they are members of the current class. Fix it by adding ::
    102      *  in front of any @to value that doesn't start with #.
    103     -->
    104     <xsl:choose>
    105         <xsl:when test="not(starts-with(@to, '#')) and not(contains(@to, '::'))">
    106             <xsl:text>::</xsl:text>
     98  <xsl:text>@link </xsl:text>
     99  <!--
     100   *  sometimes Doxygen is stupid and cannot resolve global enums properly,
     101   *  thinking they are members of the current class. Fix it by adding ::
     102   *  in front of any @to value that doesn't start with #.
     103  -->
     104  <xsl:choose>
     105    <xsl:when test="not(starts-with(@to, '#')) and not(contains(@to, '::'))">
     106      <xsl:text>::</xsl:text>
     107    </xsl:when>
     108  </xsl:choose>
     109  <!--
     110   *  Doxygen doesn't understand autolinks like Class::func() if Class
     111   *  doesn't actually contain a func with no arguments. Fix it.
     112  -->
     113  <xsl:choose>
     114    <xsl:when test="substring(@to, string-length(@to)-1)='()'">
     115      <xsl:value-of select="substring-before(@to, '()')"/>
     116    </xsl:when>
     117    <xsl:otherwise>
     118      <xsl:value-of select="@to"/>
     119    </xsl:otherwise>
     120  </xsl:choose>
     121  <xsl:text> </xsl:text>
     122  <xsl:choose>
     123    <xsl:when test="normalize-space(text())">
     124      <xsl:value-of select="normalize-space(text())"/>
     125    </xsl:when>
     126    <xsl:otherwise>
     127      <xsl:choose>
     128        <xsl:when test="starts-with(@to, '#')">
     129          <xsl:value-of select="substring-after(@to, '#')"/>
    107130        </xsl:when>
    108     </xsl:choose>
    109     <!--
    110      *  Doxygen doesn't understand autolinks like Class::func() if Class
    111      *  doesn't actually contain a func with no arguments. Fix it.
    112     -->
    113     <xsl:choose>
    114         <xsl:when test="substring(@to, string-length(@to)-1)='()'">
    115             <xsl:value-of select="substring-before(@to, '()')"/>
     131        <xsl:when test="starts-with(@to, '::')">
     132          <xsl:value-of select="substring-after(@to, '::')"/>
    116133        </xsl:when>
    117134        <xsl:otherwise>
    118             <xsl:value-of select="@to"/>
     135          <xsl:value-of select="@to"/>
    119136        </xsl:otherwise>
    120     </xsl:choose>
    121     <xsl:text> </xsl:text>
    122     <xsl:choose>
    123         <xsl:when test="normalize-space(text())">
    124             <xsl:value-of select="normalize-space(text())"/>
    125         </xsl:when>
    126         <xsl:otherwise>
    127             <xsl:choose>
    128                 <xsl:when test="starts-with(@to, '#')">
    129                     <xsl:value-of select="substring-after(@to, '#')"/>
    130                 </xsl:when>
    131                 <xsl:when test="starts-with(@to, '::')">
    132                     <xsl:value-of select="substring-after(@to, '::')"/>
    133                 </xsl:when>
    134                 <xsl:otherwise>
    135                     <xsl:value-of select="@to"/>
    136                 </xsl:otherwise>
    137             </xsl:choose>
    138         </xsl:otherwise>
    139     </xsl:choose>
    140     <xsl:text>@endlink</xsl:text>
    141     <!--
    142      *  insert a dummy empty B element to distinctly separate @endlink
    143      *  from the following text
    144      -->
    145     <xsl:element name="b"/>
     137      </xsl:choose>
     138    </xsl:otherwise>
     139  </xsl:choose>
     140  <xsl:text>@endlink</xsl:text>
     141  <!--
     142   *  insert a dummy empty B element to distinctly separate @endlink
     143   *  from the following text
     144   -->
     145  <xsl:element name="b"/>
    146146</xsl:template>
    147147
     
    150150-->
    151151<xsl:template match="desc/note">
    152     <xsl:text>&#x0A;@note </xsl:text>
    153     <xsl:apply-templates/>
    154     <xsl:text>&#x0A;</xsl:text>
     152  <xsl:text>&#x0A;@note </xsl:text>
     153  <xsl:apply-templates/>
     154  <xsl:text>&#x0A;</xsl:text>
    155155</xsl:template>
    156156
     
    159159-->
    160160<xsl:template match="desc/see">
    161     <xsl:text>&#x0A;@see </xsl:text>
    162     <xsl:apply-templates/>
    163     <xsl:text>&#x0A;</xsl:text>
     161  <xsl:text>&#x0A;@see </xsl:text>
     162  <xsl:apply-templates/>
     163  <xsl:text>&#x0A;</xsl:text>
    164164</xsl:template>
    165165
     
    168168-->
    169169<xsl:template match="interface/desc">
    170     <xsl:text>/**&#x0A;</xsl:text>
    171     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    172     <xsl:apply-templates select="note"/>
    173     <xsl:apply-templates select="see"/>
     170  <xsl:text>/**&#x0A;</xsl:text>
     171  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     172  <xsl:apply-templates select="note"/>
     173  <xsl:apply-templates select="see"/>
    174174@par Interface ID:
    175175<tt>{<xsl:call-template name="uppercase">
    176         <xsl:with-param name="str" select="../@uuid"/>
    177     </xsl:call-template>}</tt>
    178     <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     176    <xsl:with-param name="str" select="../@uuid"/>
     177  </xsl:call-template>}</tt>
     178  <xsl:text>&#x0A;*/&#x0A;</xsl:text>
    179179</xsl:template>
    180180
     
    183183-->
    184184<xsl:template match="attribute/desc">
    185     <xsl:text>/**&#x0A;</xsl:text>
    186     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    187     <xsl:apply-templates select="note"/>
    188     <xsl:if test="../@mod='ptr'">
    189         <xsl:text>
     185  <xsl:text>/**&#x0A;</xsl:text>
     186  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     187  <xsl:apply-templates select="note"/>
     188  <xsl:if test="../@mod='ptr'">
     189    <xsl:text>
    190190
    191191@warning This attribute is non-scriptable. In particular, this also means that an
     
    193193owns the object will most likely fail or crash your application.
    194194</xsl:text>
    195     </xsl:if>
    196     <xsl:apply-templates select="see"/>
    197     <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     195  </xsl:if>
     196  <xsl:apply-templates select="see"/>
     197  <xsl:text>&#x0A;*/&#x0A;</xsl:text>
    198198</xsl:template>
    199199
     
    202202-->
    203203<xsl:template match="method/desc">
    204     <xsl:text>/**&#x0A;</xsl:text>
    205     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    206     <xsl:for-each select="../param">
    207         <xsl:apply-templates select="desc"/>
    208     </xsl:for-each>
    209     <xsl:apply-templates select="note"/>
    210     <xsl:apply-templates select="../param/desc/note"/>
    211     <xsl:if test="../param/@mod='ptr'">
    212         <xsl:text>
     204  <xsl:text>/**&#x0A;</xsl:text>
     205  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     206  <xsl:for-each select="../param">
     207    <xsl:apply-templates select="desc"/>
     208  </xsl:for-each>
     209  <xsl:apply-templates select="note"/>
     210  <xsl:apply-templates select="../param/desc/note"/>
     211  <xsl:if test="../param/@mod='ptr'">
     212    <xsl:text>
    213213
    214214@warning This method is non-scriptable. In particluar, this also means that an
     
    216216owns the object will most likely fail or crash your application.
    217217</xsl:text>
    218     </xsl:if>
    219     <xsl:apply-templates select="see"/>
    220     <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     218  </xsl:if>
     219  <xsl:apply-templates select="see"/>
     220  <xsl:text>&#x0A;*/&#x0A;</xsl:text>
    221221</xsl:template>
    222222
     
    225225-->
    226226<xsl:template match="method/param/desc">
    227     <xsl:text>&#x0A;@param </xsl:text>
    228     <xsl:value-of select="../@name"/>
    229     <xsl:text> </xsl:text>
    230     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    231     <xsl:text>&#x0A;</xsl:text>
     227  <xsl:text>&#x0A;@param </xsl:text>
     228  <xsl:value-of select="../@name"/>
     229  <xsl:text> </xsl:text>
     230  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     231  <xsl:text>&#x0A;</xsl:text>
    232232</xsl:template>
    233233
     
    236236-->
    237237<xsl:template match="enum/desc">
    238     <xsl:text>/**&#x0A;</xsl:text>
    239     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    240     <xsl:apply-templates select="note"/>
    241     <xsl:apply-templates select="see"/>
     238  <xsl:text>/**&#x0A;</xsl:text>
     239  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     240  <xsl:apply-templates select="note"/>
     241  <xsl:apply-templates select="see"/>
    242242@par Interface ID:
    243243<tt>{<xsl:call-template name="uppercase">
    244         <xsl:with-param name="str" select="../@uuid"/>
    245     </xsl:call-template>}</tt>
    246     <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     244    <xsl:with-param name="str" select="../@uuid"/>
     245  </xsl:call-template>}</tt>
     246  <xsl:text>&#x0A;*/&#x0A;</xsl:text>
    247247</xsl:template>
    248248
     
    251251-->
    252252<xsl:template match="enum/const/desc">
    253     <xsl:text>/** @brief </xsl:text>
    254     <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    255     <xsl:apply-templates select="note"/>
    256     <xsl:apply-templates select="see"/>
    257     <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     253  <xsl:text>/** @brief </xsl:text>
     254  <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
     255  <xsl:apply-templates select="note"/>
     256  <xsl:apply-templates select="see"/>
     257  <xsl:text>&#x0A;*/&#x0A;</xsl:text>
    258258</xsl:template>
    259259
     
    322322 *  <i>must not</i> be used for programming.
    323323 */
    324     <xsl:text>&#x0A;</xsl:text>
    325     <xsl:apply-templates/>
     324  <xsl:text>&#x0A;</xsl:text>
     325  <xsl:apply-templates/>
    326326</xsl:template>
    327327
     
    331331-->
    332332<xsl:template match="if">
    333     <xsl:apply-templates/>
     333  <xsl:apply-templates/>
    334334</xsl:template>
    335335
     
    346346-->
    347347<xsl:template match="@if" mode="begin">
    348     <xsl:text>#if </xsl:text>
    349     <xsl:value-of select="."/>
    350     <xsl:text>&#x0A;</xsl:text>
     348  <xsl:text>#if </xsl:text>
     349  <xsl:value-of select="."/>
     350  <xsl:text>&#x0A;</xsl:text>
    351351</xsl:template>
    352352<xsl:template match="@if" mode="end">
    353     <xsl:text>#endif&#x0A;</xsl:text>
     353  <xsl:text>#endif&#x0A;</xsl:text>
    354354</xsl:template>
    355355
     
    359359-->
    360360<xsl:template match="library">
    361     <!-- all enums go first -->
    362     <xsl:apply-templates select="enum | if/enum"/>
    363     <!-- everything else but enums -->
    364     <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
     361  <!-- all enums go first -->
     362  <xsl:apply-templates select="enum | if/enum"/>
     363  <!-- everything else but enums -->
     364  <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
    365365</xsl:template>
    366366
     
    370370-->
    371371<xsl:template match="interface">
    372     <xsl:apply-templates select="desc"/>
    373     <xsl:text>interface </xsl:text>
    374     <xsl:value-of select="@name"/>
    375     <xsl:text> : </xsl:text>
    376     <xsl:value-of select="@extends"/>
    377     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    378     <!-- attributes (properties) -->
    379     <xsl:apply-templates select="attribute"/>
    380     <!-- methods -->
    381     <xsl:apply-templates select="method"/>
    382     <!-- 'if' enclosed elements, unsorted -->
    383     <xsl:apply-templates select="if"/>
    384     <!-- -->
    385     <xsl:text>}; /* interface </xsl:text>
    386     <xsl:value-of select="@name"/>
    387     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     372  <xsl:apply-templates select="desc"/>
     373  <xsl:text>interface </xsl:text>
     374  <xsl:value-of select="@name"/>
     375  <xsl:text> : </xsl:text>
     376  <xsl:value-of select="@extends"/>
     377  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     378  <!-- attributes (properties) -->
     379  <xsl:apply-templates select="attribute"/>
     380  <!-- methods -->
     381  <xsl:apply-templates select="method"/>
     382  <!-- 'if' enclosed elements, unsorted -->
     383  <xsl:apply-templates select="if"/>
     384  <!-- -->
     385  <xsl:text>}; /* interface </xsl:text>
     386  <xsl:value-of select="@name"/>
     387  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    388388</xsl:template>
    389389
     
    394394<xsl:template match="interface//attribute | collection//attribute">
    395395  <xsl:if test="@array">
    396       <xsl:message terminate="yes">
    397           <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    398           <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
    399       </xsl:message>
    400   </xsl:if>
    401     <xsl:apply-templates select="@if" mode="begin"/>
     396    <xsl:message terminate="yes">
     397      <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     398      <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
     399    </xsl:message>
     400  </xsl:if>
     401  <xsl:apply-templates select="@if" mode="begin"/>
     402  <xsl:apply-templates select="desc"/>
     403  <xsl:text>    </xsl:text>
     404  <xsl:if test="@readonly='yes'">
     405    <xsl:text>readonly </xsl:text>
     406  </xsl:if>
     407  <xsl:text>attribute </xsl:text>
     408  <xsl:apply-templates select="@type"/>
     409  <xsl:text> </xsl:text>
     410  <xsl:value-of select="@name"/>
     411  <xsl:text>;&#x0A;</xsl:text>
     412  <xsl:apply-templates select="@if" mode="end"/>
     413  <xsl:text>&#x0A;</xsl:text>
     414</xsl:template>
     415
     416<!--
     417 *  methods
     418-->
     419<xsl:template match="interface//method | collection//method">
     420  <xsl:apply-templates select="@if" mode="begin"/>
     421  <xsl:apply-templates select="desc"/>
     422  <xsl:text>    void </xsl:text>
     423  <xsl:value-of select="@name"/>
     424  <xsl:if test="param">
     425    <xsl:text> (&#x0A;</xsl:text>
     426    <xsl:for-each select="param [position() != last()]">
     427      <xsl:text>        </xsl:text>
     428      <xsl:apply-templates select="."/>
     429      <xsl:text>,&#x0A;</xsl:text>
     430    </xsl:for-each>
     431    <xsl:text>        </xsl:text>
     432    <xsl:apply-templates select="param [last()]"/>
     433    <xsl:text>&#x0A;    );&#x0A;</xsl:text>
     434  </xsl:if>
     435  <xsl:if test="not(param)">
     436    <xsl:text>();&#x0A;</xsl:text>
     437  </xsl:if>
     438  <xsl:apply-templates select="@if" mode="end"/>
     439  <xsl:text>&#x0A;</xsl:text>
     440</xsl:template>
     441
     442
     443<!--
     444 *  co-classes
     445-->
     446<xsl:template match="module/class">
     447  <!-- class and contract id: later -->
     448  <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32: later -->
     449</xsl:template>
     450
     451
     452<!--
     453 *  enumerators
     454-->
     455<xsl:template match="enumerator">
     456  <xsl:text>interface </xsl:text>
     457  <xsl:value-of select="@name"/>
     458  <xsl:text> : $unknown&#x0A;{&#x0A;</xsl:text>
     459  <!-- HasMore -->
     460  <xsl:text>    void hasMore ([retval] out boolean more);&#x0A;&#x0A;</xsl:text>
     461  <!-- GetNext -->
     462  <xsl:text>    void getNext ([retval] out </xsl:text>
     463  <xsl:apply-templates select="@type"/>
     464  <xsl:text> next);&#x0A;&#x0A;</xsl:text>
     465  <!-- -->
     466  <xsl:text>}; /* interface </xsl:text>
     467  <xsl:value-of select="@name"/>
     468  <xsl:text> */&#x0A;&#x0A;</xsl:text>
     469</xsl:template>
     470
     471
     472<!--
     473 *  collections
     474-->
     475<xsl:template match="collection">
     476  <xsl:if test="not(@readonly='yes')">
     477    <xsl:message terminate="yes">
     478      <xsl:value-of select="concat(@name,': ')"/>
     479      <xsl:text>non-readonly collections are not currently supported</xsl:text>
     480    </xsl:message>
     481  </xsl:if>
     482  <xsl:text>interface </xsl:text>
     483  <xsl:value-of select="@name"/>
     484  <xsl:text> : $unknown&#x0A;{&#x0A;</xsl:text>
     485  <!-- Count -->
     486  <xsl:text>    readonly attribute unsigned long count;&#x0A;&#x0A;</xsl:text>
     487  <!-- GetItemAt -->
     488  <xsl:text>    void getItemAt (in unsigned long index, [retval] out </xsl:text>
     489  <xsl:apply-templates select="@type"/>
     490  <xsl:text> item);&#x0A;&#x0A;</xsl:text>
     491  <!-- Enumerate -->
     492  <xsl:text>    void enumerate ([retval] out </xsl:text>
     493  <xsl:apply-templates select="@enumerator"/>
     494  <xsl:text> enumerator);&#x0A;&#x0A;</xsl:text>
     495  <!-- other extra attributes (properties) -->
     496  <xsl:apply-templates select="attribute"/>
     497  <!-- other extra methods -->
     498  <xsl:apply-templates select="method"/>
     499  <!-- 'if' enclosed elements, unsorted -->
     500  <xsl:apply-templates select="if"/>
     501  <!-- -->
     502  <xsl:text>}; /* interface </xsl:text>
     503  <xsl:value-of select="@name"/>
     504  <xsl:text> */&#x0A;&#x0A;</xsl:text>
     505</xsl:template>
     506
     507
     508<!--
     509 *  enums
     510-->
     511<xsl:template match="enum">
     512  <xsl:apply-templates select="desc"/>
     513  <xsl:text>enum </xsl:text>
     514  <xsl:value-of select="@name"/>
     515  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     516  <xsl:for-each select="const">
    402517    <xsl:apply-templates select="desc"/>
    403518    <xsl:text>    </xsl:text>
    404     <xsl:if test="@readonly='yes'">
    405         <xsl:text>readonly </xsl:text>
     519    <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
     520    <xsl:text>,&#x0A;</xsl:text>
     521  </xsl:for-each>
     522  <xsl:text>};&#x0A;&#x0A;</xsl:text>
     523</xsl:template>
     524
     525
     526<!--
     527 *  method parameters
     528-->
     529<xsl:template match="method/param">
     530  <xsl:if test="@array">
     531    <xsl:if test="@dir='return'">
     532      <xsl:message terminate="yes">
     533        <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     534        <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
     535      </xsl:message>
    406536    </xsl:if>
    407     <xsl:text>attribute </xsl:text>
    408     <xsl:apply-templates select="@type"/>
    409     <xsl:text> </xsl:text>
    410     <xsl:value-of select="@name"/>
    411     <xsl:text>;&#x0A;</xsl:text>
    412     <xsl:apply-templates select="@if" mode="end"/>
    413     <xsl:text>&#x0A;</xsl:text>
    414 </xsl:template>
    415 
    416 <!--
    417  *  methods
    418 -->
    419 <xsl:template match="interface//method | collection//method">
    420     <xsl:apply-templates select="@if" mode="begin"/>
    421     <xsl:apply-templates select="desc"/>
    422     <xsl:text>    void </xsl:text>
    423     <xsl:value-of select="@name"/>
    424     <xsl:if test="param">
    425         <xsl:text> (&#x0A;</xsl:text>
    426         <xsl:for-each select="param [position() != last()]">
    427             <xsl:text>        </xsl:text>
    428             <xsl:apply-templates select="."/>
    429             <xsl:text>,&#x0A;</xsl:text>
    430         </xsl:for-each>
    431         <xsl:text>        </xsl:text>
    432         <xsl:apply-templates select="param [last()]"/>
    433         <xsl:text>&#x0A;    );&#x0A;</xsl:text>
    434     </xsl:if>
    435     <xsl:if test="not(param)">
    436         <xsl:text>();&#x0A;</xsl:text>
    437     </xsl:if>
    438     <xsl:apply-templates select="@if" mode="end"/>
    439     <xsl:text>&#x0A;</xsl:text>
    440 </xsl:template>
    441 
    442 
    443 <!--
    444  *  co-classes
    445 -->
    446 <xsl:template match="module/class">
    447     <!-- class and contract id: later -->
    448     <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32: later -->
    449 </xsl:template>
    450 
    451 
    452 <!--
    453  *  enumerators
    454 -->
    455 <xsl:template match="enumerator">
    456     <xsl:text>interface </xsl:text>
    457     <xsl:value-of select="@name"/>
    458     <xsl:text> : $unknown&#x0A;{&#x0A;</xsl:text>
    459     <!-- HasMore -->
    460     <xsl:text>    void hasMore ([retval] out boolean more);&#x0A;&#x0A;</xsl:text>
    461     <!-- GetNext -->
    462     <xsl:text>    void getNext ([retval] out </xsl:text>
    463     <xsl:apply-templates select="@type"/>
    464     <xsl:text> next);&#x0A;&#x0A;</xsl:text>
    465     <!-- -->
    466     <xsl:text>}; /* interface </xsl:text>
    467     <xsl:value-of select="@name"/>
    468     <xsl:text> */&#x0A;&#x0A;</xsl:text>
    469 </xsl:template>
    470 
    471 
    472 <!--
    473  *  collections
    474 -->
    475 <xsl:template match="collection">
    476     <xsl:if test="not(@readonly='yes')">
     537    <xsl:text>[array, </xsl:text>
     538    <xsl:choose>
     539      <xsl:when test="../param[@name=current()/@array]">
     540        <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
     541          <xsl:message terminate="yes">
     542            <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
     543            <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
     544            <xsl:text> must have the same direction</xsl:text>
     545          </xsl:message>
     546        </xsl:if>
     547        <xsl:text>size_is(</xsl:text>
     548        <xsl:if test="@dir='out'">
     549          <xsl:text>, </xsl:text>
     550        </xsl:if>
     551        <xsl:if test="../param[@name=current()/@array]/@dir='out'">
     552          <xsl:text>*</xsl:text>
     553        </xsl:if>
     554        <xsl:value-of select="@array"/>
     555        <xsl:text>)</xsl:text>
     556      </xsl:when>
     557      <xsl:otherwise>
    477558        <xsl:message terminate="yes">
    478             <xsl:value-of select="concat(@name,': ')"/>
    479             <xsl:text>non-readonly collections are not currently supported</xsl:text>
     559          <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     560          <xsl:text>array attribute refers to non-existent param: </xsl:text>
     561          <xsl:value-of select="@array"/>
    480562        </xsl:message>
    481     </xsl:if>
    482     <xsl:text>interface </xsl:text>
    483     <xsl:value-of select="@name"/>
    484     <xsl:text> : $unknown&#x0A;{&#x0A;</xsl:text>
    485     <!-- Count -->
    486     <xsl:text>    readonly attribute unsigned long count;&#x0A;&#x0A;</xsl:text>
    487     <!-- GetItemAt -->
    488     <xsl:text>    void getItemAt (in unsigned long index, [retval] out </xsl:text>
    489     <xsl:apply-templates select="@type"/>
    490     <xsl:text> item);&#x0A;&#x0A;</xsl:text>
    491     <!-- Enumerate -->
    492     <xsl:text>    void enumerate ([retval] out </xsl:text>
    493     <xsl:apply-templates select="@enumerator"/>
    494     <xsl:text> enumerator);&#x0A;&#x0A;</xsl:text>
    495     <!-- other extra attributes (properties) -->
    496     <xsl:apply-templates select="attribute"/>
    497     <!-- other extra methods -->
    498     <xsl:apply-templates select="method"/>
    499     <!-- 'if' enclosed elements, unsorted -->
    500     <xsl:apply-templates select="if"/>
    501     <!-- -->
    502     <xsl:text>}; /* interface </xsl:text>
    503     <xsl:value-of select="@name"/>
    504     <xsl:text> */&#x0A;&#x0A;</xsl:text>
    505 </xsl:template>
    506 
    507 
    508 <!--
    509  *  enums
    510 -->
    511 <xsl:template match="enum">
    512     <xsl:apply-templates select="desc"/>
    513     <xsl:text>enum </xsl:text>
    514     <xsl:value-of select="@name"/>
    515     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    516     <xsl:for-each select="const">
    517         <xsl:apply-templates select="desc"/>
    518         <xsl:text>    </xsl:text>
    519         <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
    520         <xsl:text>,&#x0A;</xsl:text>
    521     </xsl:for-each>
    522     <xsl:text>};&#x0A;&#x0A;</xsl:text>
    523 </xsl:template>
    524 
    525 
    526 <!--
    527  *  method parameters
    528 -->
    529 <xsl:template match="method/param">
    530     <xsl:if test="@array">
    531         <xsl:if test="@dir='return'">
    532             <xsl:message terminate="yes">
    533                 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    534                 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
    535             </xsl:message>
    536         </xsl:if>
    537         <xsl:text>[array, </xsl:text>
    538         <xsl:choose>
    539             <xsl:when test="../param[@name=current()/@array]">
    540                 <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
    541                     <xsl:message terminate="yes">
    542                         <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
    543                         <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
    544                         <xsl:text> must have the same direction</xsl:text>
    545                     </xsl:message>
    546                 </xsl:if>
    547                 <xsl:text>size_is(</xsl:text>
    548                     <xsl:if test="@dir='out'">
    549                         <xsl:text>, </xsl:text>
    550                     </xsl:if>
    551                     <xsl:if test="../param[@name=current()/@array]/@dir='out'">
    552                         <xsl:text>*</xsl:text>
    553                     </xsl:if>
    554                     <xsl:value-of select="@array"/>
    555                 <xsl:text>)</xsl:text>
     563      </xsl:otherwise>
     564    </xsl:choose>
     565    <xsl:text>] </xsl:text>
     566  </xsl:if>
     567  <xsl:choose>
     568    <xsl:when test="@dir='in'">in </xsl:when>
     569    <xsl:when test="@dir='out'">out </xsl:when>
     570    <xsl:when test="@dir='return'">[retval] out </xsl:when>
     571    <xsl:otherwise>in</xsl:otherwise>
     572  </xsl:choose>
     573  <xsl:apply-templates select="@type"/>
     574  <xsl:text> </xsl:text>
     575  <xsl:value-of select="@name"/>
     576</xsl:template>
     577
     578
     579<!--
     580 *  attribute/parameter type conversion
     581-->
     582<xsl:template match="
     583  attribute/@type | param/@type |
     584  enumerator/@type | collection/@type | collection/@enumerator
     585">
     586  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
     587
     588  <xsl:if test="../@array and ../@safearray='yes'">
     589    <xsl:message terminate="yes">
     590      <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     591      <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
     592    </xsl:message>
     593  </xsl:if>
     594
     595  <xsl:choose>
     596    <!-- modifiers (ignored for 'enumeration' attributes)-->
     597    <xsl:when test="name(current())='type' and ../@mod">
     598      <xsl:choose>
     599        <xsl:when test="../@mod='ptr'">
     600          <xsl:choose>
     601            <!-- standard types -->
     602            <!--xsl:when test=".='result'">??</xsl:when-->
     603            <xsl:when test=".='boolean'">booeanPtr</xsl:when>
     604            <xsl:when test=".='octet'">octetPtr</xsl:when>
     605            <xsl:when test=".='short'">shortPtr</xsl:when>
     606            <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
     607            <xsl:when test=".='long'">longPtr</xsl:when>
     608            <xsl:when test=".='long long'">llongPtr</xsl:when>
     609            <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
     610            <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
     611            <xsl:when test=".='char'">charPtr</xsl:when>
     612            <!--xsl:when test=".='string'">??</xsl:when-->
     613            <xsl:when test=".='wchar'">wcharPtr</xsl:when>
     614            <!--xsl:when test=".='wstring'">??</xsl:when-->
     615            <xsl:otherwise>
     616              <xsl:message terminate="yes">
     617                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     618                <xsl:text>attribute 'mod=</xsl:text>
     619                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     620                <xsl:text>' cannot be used with type </xsl:text>
     621                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     622              </xsl:message>
     623            </xsl:otherwise>
     624          </xsl:choose>
     625        </xsl:when>
     626        <xsl:otherwise>
     627          <xsl:message terminate="yes">
     628            <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     629            <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     630            <xsl:text>of attibute 'mod' is invalid!</xsl:text>
     631          </xsl:message>
     632        </xsl:otherwise>
     633      </xsl:choose>
     634    </xsl:when>
     635    <!-- no modifiers -->
     636    <xsl:otherwise>
     637      <xsl:choose>
     638        <!-- standard types -->
     639        <xsl:when test=".='result'">result</xsl:when>
     640        <xsl:when test=".='boolean'">boolean</xsl:when>
     641        <xsl:when test=".='octet'">octet</xsl:when>
     642        <xsl:when test=".='short'">short</xsl:when>
     643        <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
     644        <xsl:when test=".='long'">long</xsl:when>
     645        <xsl:when test=".='long long'">long long</xsl:when>
     646        <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
     647        <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
     648        <xsl:when test=".='char'">char</xsl:when>
     649        <xsl:when test=".='wchar'">wchar</xsl:when>
     650        <xsl:when test=".='string'">string</xsl:when>
     651        <xsl:when test=".='wstring'">wstring</xsl:when>
     652        <!-- UUID type -->
     653        <xsl:when test=".='uuid'">uuid</xsl:when>
     654        <!-- system interface types -->
     655        <xsl:when test=".='$unknown'">$unknown</xsl:when>
     656        <xsl:otherwise>
     657          <xsl:choose>
     658            <!-- enum types -->
     659            <xsl:when test="
     660              (ancestor::library/enum[@name=current()]) or
     661              (ancestor::library/if[@target=$self_target]/enum[@name=current()])
     662            ">
     663              <xsl:value-of select="."/>
    556664            </xsl:when>
     665            <!-- custom interface types -->
     666            <xsl:when test="
     667              (name(current())='enumerator' and
     668               ((ancestor::library/enumerator[@name=current()]) or
     669                (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
     670              ) or
     671              ((ancestor::library/interface[@name=current()]) or
     672               (ancestor::library/if[@target=$self_target]/interface[@name=current()])
     673              ) or
     674              ((ancestor::library/collection[@name=current()]) or
     675               (ancestor::library/if[@target=$self_target]/collection[@name=current()])
     676              )
     677            ">
     678              <xsl:value-of select="."/>
     679            </xsl:when>
     680            <!-- other types -->
    557681            <xsl:otherwise>
    558                 <xsl:message terminate="yes">
    559                     <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    560                     <xsl:text>array attribute refers to non-existent param: </xsl:text>
    561                     <xsl:value-of select="@array"/>
    562                 </xsl:message>
     682              <xsl:message terminate="yes">
     683                <xsl:text>Unknown parameter type: </xsl:text>
     684                <xsl:value-of select="."/>
     685              </xsl:message>
    563686            </xsl:otherwise>
    564         </xsl:choose>
    565         <xsl:text>] </xsl:text>
    566     </xsl:if>
    567     <xsl:choose>
    568         <xsl:when test="@dir='in'">in </xsl:when>
    569         <xsl:when test="@dir='out'">out </xsl:when>
    570         <xsl:when test="@dir='return'">[retval] out </xsl:when>
    571         <xsl:otherwise>in</xsl:otherwise>
    572     </xsl:choose>
    573     <xsl:apply-templates select="@type"/>
    574     <xsl:text> </xsl:text>
    575     <xsl:value-of select="@name"/>
    576 </xsl:template>
    577 
    578 
    579 <!--
    580  *  attribute/parameter type conversion
    581 -->
    582 <xsl:template match="
    583     attribute/@type | param/@type |
    584     enumerator/@type | collection/@type | collection/@enumerator
    585 ">
    586     <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    587 
    588     <xsl:if test="../@array and ../@safearray='yes'">
    589         <xsl:message terminate="yes">
    590             <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    591             <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
    592         </xsl:message>
    593     </xsl:if>
    594 
    595     <xsl:choose>
    596         <!-- modifiers (ignored for 'enumeration' attributes)-->
    597         <xsl:when test="name(current())='type' and ../@mod">
    598             <xsl:choose>
    599                 <xsl:when test="../@mod='ptr'">
    600                     <xsl:choose>
    601                         <!-- standard types -->
    602                         <!--xsl:when test=".='result'">??</xsl:when-->
    603                         <xsl:when test=".='boolean'">booeanPtr</xsl:when>
    604                         <xsl:when test=".='octet'">octetPtr</xsl:when>
    605                         <xsl:when test=".='short'">shortPtr</xsl:when>
    606                         <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
    607                         <xsl:when test=".='long'">longPtr</xsl:when>
    608                         <xsl:when test=".='long long'">llongPtr</xsl:when>
    609                         <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
    610                         <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
    611                         <xsl:when test=".='char'">charPtr</xsl:when>
    612                         <!--xsl:when test=".='string'">??</xsl:when-->
    613                         <xsl:when test=".='wchar'">wcharPtr</xsl:when>
    614                         <!--xsl:when test=".='wstring'">??</xsl:when-->
    615                         <xsl:otherwise>
    616                             <xsl:message terminate="yes">
    617                                 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    618                                 <xsl:text>attribute 'mod=</xsl:text>
    619                                 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
    620                                 <xsl:text>' cannot be used with type </xsl:text>
    621                                 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
    622                             </xsl:message>
    623                         </xsl:otherwise>
    624                     </xsl:choose>
    625                 </xsl:when>
    626                 <xsl:otherwise>
    627                     <xsl:message terminate="yes">
    628                         <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    629                         <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
    630                         <xsl:text>of attibute 'mod' is invalid!</xsl:text>
    631                     </xsl:message>
    632                 </xsl:otherwise>
    633             </xsl:choose>
    634         </xsl:when>
    635         <!-- no modifiers -->
    636         <xsl:otherwise>
    637             <xsl:choose>
    638                 <!-- standard types -->
    639                 <xsl:when test=".='result'">result</xsl:when>
    640                 <xsl:when test=".='boolean'">boolean</xsl:when>
    641                 <xsl:when test=".='octet'">octet</xsl:when>
    642                 <xsl:when test=".='short'">short</xsl:when>
    643                 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
    644                 <xsl:when test=".='long'">long</xsl:when>
    645                 <xsl:when test=".='long long'">long long</xsl:when>
    646                 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
    647                 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
    648                 <xsl:when test=".='char'">char</xsl:when>
    649                 <xsl:when test=".='wchar'">wchar</xsl:when>
    650                 <xsl:when test=".='string'">string</xsl:when>
    651                 <xsl:when test=".='wstring'">wstring</xsl:when>
    652                 <!-- UUID type -->
    653                 <xsl:when test=".='uuid'">uuid</xsl:when>
    654                 <!-- system interface types -->
    655                 <xsl:when test=".='$unknown'">$unknown</xsl:when>
    656                 <xsl:otherwise>
    657                     <xsl:choose>
    658                         <!-- enum types -->
    659                         <xsl:when test="
    660                             (ancestor::library/enum[@name=current()]) or
    661                             (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    662                         ">
    663                             <xsl:value-of select="."/>
    664                         </xsl:when>
    665                         <!-- custom interface types -->
    666                         <xsl:when test="
    667                             (name(current())='enumerator' and
    668                              ((ancestor::library/enumerator[@name=current()]) or
    669                               (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
    670                             ) or
    671                             ((ancestor::library/interface[@name=current()]) or
    672                              (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    673                             ) or
    674                             ((ancestor::library/collection[@name=current()]) or
    675                              (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    676                             )
    677                         ">
    678                             <xsl:value-of select="."/>
    679                         </xsl:when>
    680                         <!-- other types -->
    681                         <xsl:otherwise>
    682                             <xsl:message terminate="yes">
    683                                 <xsl:text>Unknown parameter type: </xsl:text>
    684                                 <xsl:value-of select="."/>
    685                             </xsl:message>
    686                         </xsl:otherwise>
    687                     </xsl:choose>
    688                 </xsl:otherwise>
    689             </xsl:choose>
     687          </xsl:choose>
    690688        </xsl:otherwise>
    691     </xsl:choose>
     689      </xsl:choose>
     690    </xsl:otherwise>
     691  </xsl:choose>
    692692  <xsl:if test="../@safearray='yes'">
    693693    <xsl:text>[]</xsl:text>
  • trunk/src/VBox/Main/idl/midl.xsl

    r7207 r7216  
    3131-->
    3232<xsl:template name="capitalize">
    33     <xsl:param name="str" select="."/>
    34     <xsl:value-of select="
    35         concat(
    36             translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
    37             substring($str,2)
    38         )
    39     "/>
     33  <xsl:param name="str" select="."/>
     34  <xsl:value-of select="
     35    concat(
     36      translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
     37      substring($str,2)
     38    )
     39  "/>
    4040</xsl:template>
    4141
     
    4545-->
    4646<xsl:template name="uncapitalize">
    47     <xsl:param name="str" select="."/>
    48     <xsl:choose>
    49         <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
    50             <xsl:value-of select="
    51                 concat(
    52                     translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
    53                     substring($str,2)
    54                 )
    55             "/>
    56         </xsl:when>
    57         <xsl:otherwise>
    58             <xsl:value-of select="string($str)"/>
    59         </xsl:otherwise>
    60     </xsl:choose>
     47  <xsl:param name="str" select="."/>
     48  <xsl:choose>
     49    <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
     50      <xsl:value-of select="
     51        concat(
     52          translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
     53          substring($str,2)
     54        )
     55      "/>
     56    </xsl:when>
     57    <xsl:otherwise>
     58      <xsl:value-of select="string($str)"/>
     59    </xsl:otherwise>
     60  </xsl:choose>
    6161</xsl:template>
    6262
     
    7272-->
    7373<xsl:template match="/idl">
    74     <xsl:text>
     74  <xsl:text>
    7575/*
    7676 *  DO NOT EDIT! This is a generated file.
     
    8282 *  Generator : src/VBox/Main/idl/midl.xsl
    8383 */
    84     </xsl:text>
    85     <xsl:text>&#x0A;</xsl:text>
    86     <xsl:text>import "unknwn.idl";&#x0A;&#x0A;</xsl:text>
     84  </xsl:text>
     85  <xsl:text>&#x0A;</xsl:text>
     86  <xsl:text>import "unknwn.idl";&#x0A;&#x0A;</xsl:text>
     87  <xsl:apply-templates/>
     88</xsl:template>
     89
     90
     91<!--
     92 *  ignore all |if|s except those for MIDL target
     93-->
     94<xsl:template match="if">
     95  <xsl:if test="@target='midl'">
    8796    <xsl:apply-templates/>
    88 </xsl:template>
    89 
    90 
    91 <!--
    92  *  ignore all |if|s except those for MIDL target
    93 -->
    94 <xsl:template match="if">
    95     <xsl:if test="@target='midl'">
    96         <xsl:apply-templates/>
    97     </xsl:if>
     97  </xsl:if>
    9898</xsl:template>
    9999<xsl:template match="if" mode="forward">
    100     <xsl:if test="@target='midl'">
    101         <xsl:apply-templates mode="forward"/>
    102     </xsl:if>
     100  <xsl:if test="@target='midl'">
     101    <xsl:apply-templates mode="forward"/>
     102  </xsl:if>
    103103</xsl:template>
    104104
     
    108108-->
    109109<xsl:template match="cpp">
    110     <xsl:text>cpp_quote("</xsl:text>
    111     <xsl:value-of select="@line"/>
    112     <xsl:text>")&#x0A;&#x0A;</xsl:text>
     110  <xsl:text>cpp_quote("</xsl:text>
     111  <xsl:value-of select="@line"/>
     112  <xsl:text>")&#x0A;&#x0A;</xsl:text>
    113113</xsl:template>
    114114
     
    118118-->
    119119<xsl:template match="@if" mode="begin">
    120     <xsl:text>#if </xsl:text>
    121     <xsl:value-of select="."/>
    122     <xsl:text>&#x0A;</xsl:text>
     120  <xsl:text>#if </xsl:text>
     121  <xsl:value-of select="."/>
     122  <xsl:text>&#x0A;</xsl:text>
    123123</xsl:template>
    124124<xsl:template match="@if" mode="end">
    125     <xsl:text>#endif&#x0A;</xsl:text>
     125  <xsl:text>#endif&#x0A;</xsl:text>
    126126</xsl:template>
    127127
     
    136136]
    137137<xsl:text>library </xsl:text>
    138     <xsl:value-of select="@name"/>
    139     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    140     <xsl:text>&#x0A;importlib("stdole2.tlb");&#x0A;&#x0A;</xsl:text>
    141     <!-- forward declarations -->
    142     <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
    143     <xsl:text>&#x0A;</xsl:text>
    144     <!-- all enums go first -->
    145     <xsl:apply-templates select="enum | if/enum"/>
    146     <!-- everything else but enums -->
    147     <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
    148     <!-- -->
    149     <xsl:text>}; /* library </xsl:text>
    150     <xsl:value-of select="@name"/>
    151     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     138  <xsl:value-of select="@name"/>
     139  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     140  <xsl:text>&#x0A;importlib("stdole2.tlb");&#x0A;&#x0A;</xsl:text>
     141  <!-- forward declarations -->
     142  <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
     143  <xsl:text>&#x0A;</xsl:text>
     144  <!-- all enums go first -->
     145  <xsl:apply-templates select="enum | if/enum"/>
     146  <!-- everything else but enums -->
     147  <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
     148  <!-- -->
     149  <xsl:text>}; /* library </xsl:text>
     150  <xsl:value-of select="@name"/>
     151  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    152152</xsl:template>
    153153
     
    157157-->
    158158<xsl:template match="interface | collection | enumerator" mode="forward">
    159     <xsl:text>interface </xsl:text>
    160     <xsl:value-of select="@name"/>
    161     <xsl:text>;&#x0A;</xsl:text>
     159  <xsl:text>interface </xsl:text>
     160  <xsl:value-of select="@name"/>
     161  <xsl:text>;&#x0A;</xsl:text>
    162162</xsl:template>
    163163
     
    172172]
    173173<xsl:text>interface </xsl:text>
    174     <xsl:value-of select="@name"/>
    175     <xsl:text> : </xsl:text>
    176     <xsl:choose>
    177         <xsl:when test="@extends='$unknown'">IUnknown</xsl:when>
    178         <xsl:when test="@extends='$dispatched'">IDispatch</xsl:when>
    179         <xsl:when test="@extends='$errorinfo'">IErrorInfo</xsl:when>
    180         <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
    181     </xsl:choose>
    182     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    183     <!-- attributes (properties) -->
    184     <xsl:apply-templates select="attribute"/>
    185     <!-- methods -->
    186     <xsl:apply-templates select="method"/>
    187     <!-- 'if' enclosed elements, unsorted -->
    188     <xsl:apply-templates select="if"/>
    189     <!-- -->
    190     <xsl:text>}; /* interface </xsl:text>
    191     <xsl:value-of select="@name"/>
    192     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     174  <xsl:value-of select="@name"/>
     175  <xsl:text> : </xsl:text>
     176  <xsl:choose>
     177    <xsl:when test="@extends='$unknown'">IUnknown</xsl:when>
     178    <xsl:when test="@extends='$dispatched'">IDispatch</xsl:when>
     179    <xsl:when test="@extends='$errorinfo'">IErrorInfo</xsl:when>
     180    <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
     181  </xsl:choose>
     182  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     183  <!-- attributes (properties) -->
     184  <xsl:apply-templates select="attribute"/>
     185  <!-- methods -->
     186  <xsl:apply-templates select="method"/>
     187  <!-- 'if' enclosed elements, unsorted -->
     188  <xsl:apply-templates select="if"/>
     189  <!-- -->
     190  <xsl:text>}; /* interface </xsl:text>
     191  <xsl:value-of select="@name"/>
     192  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    193193</xsl:template>
    194194
     
    198198-->
    199199<xsl:template match="interface//attribute | collection//attribute">
    200     <xsl:apply-templates select="@if" mode="begin"/>
    201     <xsl:if test="@array">
    202         <xsl:message terminate="yes">
    203             <xsl:value-of select="concat(../@name,'::',@name,': ')"/>
    204             <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
    205         </xsl:message>
     200  <xsl:apply-templates select="@if" mode="begin"/>
     201  <xsl:if test="@array">
     202    <xsl:message terminate="yes">
     203      <xsl:value-of select="concat(../@name,'::',@name,': ')"/>
     204      <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
     205    </xsl:message>
     206  </xsl:if>
     207  <!-- getter -->
     208  <xsl:text>    [propget] HRESULT </xsl:text>
     209  <xsl:call-template name="capitalize">
     210    <xsl:with-param name="str" select="@name"/>
     211  </xsl:call-template>
     212  <xsl:text> ([out, retval] </xsl:text>
     213  <xsl:if test="@safearray='yes'">
     214    <xsl:text>SAFEARRAY(</xsl:text>
     215  </xsl:if>
     216  <xsl:apply-templates select="@type"/>
     217  <xsl:if test="@safearray='yes'">
     218    <xsl:text>)</xsl:text>
     219  </xsl:if>
     220  <xsl:text> * a</xsl:text>
     221  <xsl:call-template name="capitalize">
     222    <xsl:with-param name="str" select="@name"/>
     223  </xsl:call-template>
     224  <xsl:text>);&#x0A;</xsl:text>
     225  <!-- setter -->
     226  <xsl:if test="not(@readonly='yes')">
     227    <xsl:text>    [propput] HRESULT </xsl:text>
     228    <xsl:call-template name="capitalize">
     229      <xsl:with-param name="str" select="@name"/>
     230    </xsl:call-template>
     231    <xsl:text> ([in</xsl:text>
     232    <xsl:if test="@safearray='yes'">
     233      <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
     234      <xsl:text>, out</xsl:text>
    206235    </xsl:if>
    207     <!-- getter -->
    208     <xsl:text>    [propget] HRESULT </xsl:text>
    209     <xsl:call-template name="capitalize">
    210         <xsl:with-param name="str" select="@name"/>
    211     </xsl:call-template>
    212     <xsl:text> ([out, retval] </xsl:text>
     236    <xsl:text>] </xsl:text>
    213237    <xsl:if test="@safearray='yes'">
    214         <xsl:text>SAFEARRAY(</xsl:text>
     238      <xsl:text>SAFEARRAY(</xsl:text>
    215239    </xsl:if>
    216240    <xsl:apply-templates select="@type"/>
    217241    <xsl:if test="@safearray='yes'">
    218         <xsl:text>)</xsl:text>
     242      <xsl:text>) *</xsl:text>
    219243    </xsl:if>
    220     <xsl:text> * a</xsl:text>
     244    <xsl:text> a</xsl:text>
    221245    <xsl:call-template name="capitalize">
    222         <xsl:with-param name="str" select="@name"/>
     246      <xsl:with-param name="str" select="@name"/>
    223247    </xsl:call-template>
    224248    <xsl:text>);&#x0A;</xsl:text>
    225     <!-- setter -->
    226     <xsl:if test="not(@readonly='yes')">
    227         <xsl:text>    [propput] HRESULT </xsl:text>
    228         <xsl:call-template name="capitalize">
    229             <xsl:with-param name="str" select="@name"/>
    230         </xsl:call-template>
    231         <xsl:text> ([in</xsl:text>
    232         <xsl:if test="@safearray='yes'">
    233             <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
    234             <xsl:text>, out</xsl:text>
    235         </xsl:if>
    236         <xsl:text>] </xsl:text>
    237         <xsl:if test="@safearray='yes'">
    238             <xsl:text>SAFEARRAY(</xsl:text>
    239         </xsl:if>
    240         <xsl:apply-templates select="@type"/>
    241         <xsl:if test="@safearray='yes'">
    242             <xsl:text>) *</xsl:text>
    243         </xsl:if>
    244         <xsl:text> a</xsl:text>
    245         <xsl:call-template name="capitalize">
    246             <xsl:with-param name="str" select="@name"/>
    247         </xsl:call-template>
    248         <xsl:text>);&#x0A;</xsl:text>
    249     </xsl:if>
    250     <xsl:apply-templates select="@if" mode="end"/>
    251     <xsl:text>&#x0A;</xsl:text>
     249  </xsl:if>
     250  <xsl:apply-templates select="@if" mode="end"/>
     251  <xsl:text>&#x0A;</xsl:text>
    252252</xsl:template>
    253253
     
    257257-->
    258258<xsl:template match="interface//method | collection//method">
    259     <xsl:apply-templates select="@if" mode="begin"/>
    260     <xsl:text>    HRESULT </xsl:text>
    261     <xsl:call-template name="capitalize">
    262         <xsl:with-param name="str" select="@name"/>
    263     </xsl:call-template>
    264     <xsl:if test="param">
    265         <xsl:text> (&#x0A;</xsl:text>
    266         <xsl:for-each select="param [position() != last()]">
    267             <xsl:text>        </xsl:text>
    268             <xsl:apply-templates select="."/>
    269             <xsl:text>,&#x0A;</xsl:text>
    270         </xsl:for-each>
    271         <xsl:text>        </xsl:text>
    272         <xsl:apply-templates select="param [last()]"/>
    273         <xsl:text>&#x0A;    );&#x0A;</xsl:text>
    274     </xsl:if>
    275     <xsl:if test="not(param)">
    276         <xsl:text>();&#x0A;</xsl:text>
    277     </xsl:if>
    278     <xsl:apply-templates select="@if" mode="end"/>
    279     <xsl:text>&#x0A;</xsl:text>
     259  <xsl:apply-templates select="@if" mode="begin"/>
     260  <xsl:text>    HRESULT </xsl:text>
     261  <xsl:call-template name="capitalize">
     262    <xsl:with-param name="str" select="@name"/>
     263  </xsl:call-template>
     264  <xsl:if test="param">
     265    <xsl:text> (&#x0A;</xsl:text>
     266    <xsl:for-each select="param [position() != last()]">
     267      <xsl:text>        </xsl:text>
     268      <xsl:apply-templates select="."/>
     269      <xsl:text>,&#x0A;</xsl:text>
     270    </xsl:for-each>
     271    <xsl:text>        </xsl:text>
     272    <xsl:apply-templates select="param [last()]"/>
     273    <xsl:text>&#x0A;    );&#x0A;</xsl:text>
     274  </xsl:if>
     275  <xsl:if test="not(param)">
     276    <xsl:text>();&#x0A;</xsl:text>
     277  </xsl:if>
     278  <xsl:apply-templates select="@if" mode="end"/>
     279  <xsl:text>&#x0A;</xsl:text>
    280280</xsl:template>
    281281
     
    288288]
    289289<xsl:text>coclass </xsl:text>
     290  <xsl:value-of select="@name"/>
     291  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     292  <xsl:for-each select="interface">
     293    <xsl:text>    </xsl:text>
     294    <xsl:if test="@default='yes'">
     295      <xsl:text>[default] </xsl:text>
     296    </xsl:if>
     297    <xsl:text>interface </xsl:text>
    290298    <xsl:value-of select="@name"/>
    291     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    292     <xsl:for-each select="interface">
    293         <xsl:text>    </xsl:text>
    294         <xsl:if test="@default='yes'">
    295             <xsl:text>[default] </xsl:text>
    296         </xsl:if>
    297         <xsl:text>interface </xsl:text>
    298         <xsl:value-of select="@name"/>
    299         <xsl:text>;&#x0A;</xsl:text>
    300     </xsl:for-each>
    301     <xsl:text>&#x0A;}; /* coclass </xsl:text>
    302     <xsl:value-of select="@name"/>
    303     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     299    <xsl:text>;&#x0A;</xsl:text>
     300  </xsl:for-each>
     301  <xsl:text>&#x0A;}; /* coclass </xsl:text>
     302  <xsl:value-of select="@name"/>
     303  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    304304</xsl:template>
    305305
     
    314314]
    315315<xsl:text>interface </xsl:text>
    316     <xsl:value-of select="@name"/>
    317     <xsl:text> : IUnknown&#x0A;{&#x0A;</xsl:text>
    318     <!-- HasMore -->
    319     <xsl:text>    HRESULT HasMore ([out, retval] BOOL * more);&#x0A;&#x0A;</xsl:text>
    320     <!-- GetNext -->
    321     <xsl:text>    HRESULT GetNext ([out, retval] </xsl:text>
    322     <xsl:apply-templates select="@type"/>
    323     <xsl:text> * next);&#x0A;&#x0A;</xsl:text>
    324     <!-- -->
    325     <xsl:text>&#x0A;}; /* interface </xsl:text>
    326     <xsl:value-of select="@name"/>
    327     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     316  <xsl:value-of select="@name"/>
     317  <xsl:text> : IUnknown&#x0A;{&#x0A;</xsl:text>
     318  <!-- HasMore -->
     319  <xsl:text>    HRESULT HasMore ([out, retval] BOOL * more);&#x0A;&#x0A;</xsl:text>
     320  <!-- GetNext -->
     321  <xsl:text>    HRESULT GetNext ([out, retval] </xsl:text>
     322  <xsl:apply-templates select="@type"/>
     323  <xsl:text> * next);&#x0A;&#x0A;</xsl:text>
     324  <!-- -->
     325  <xsl:text>&#x0A;}; /* interface </xsl:text>
     326  <xsl:value-of select="@name"/>
     327  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    328328</xsl:template>
    329329
     
    333333-->
    334334<xsl:template match="collection">
    335     <xsl:if test="not(@readonly='yes')">
    336         <xsl:message terminate="yes">
    337             <xsl:value-of select="concat(@name,': ')"/>
    338             <xsl:text>non-readonly collections are not currently supported</xsl:text>
    339         </xsl:message>
    340     </xsl:if>[
     335  <xsl:if test="not(@readonly='yes')">
     336    <xsl:message terminate="yes">
     337      <xsl:value-of select="concat(@name,': ')"/>
     338      <xsl:text>non-readonly collections are not currently supported</xsl:text>
     339    </xsl:message>
     340  </xsl:if>[
    341341    uuid(<xsl:value-of select="@uuid"/>),
    342342    object,
     
    344344]
    345345<xsl:text>interface </xsl:text>
    346     <xsl:value-of select="@name"/>
    347     <xsl:text> : IUnknown&#x0A;{&#x0A;</xsl:text>
    348     <!-- Count -->
    349     <xsl:text>    [propget] HRESULT Count ([out, retval] ULONG * count);&#x0A;&#x0A;</xsl:text>
    350     <!-- GetItemAt -->
    351     <xsl:text>    HRESULT GetItemAt ([in] ULONG index, [out, retval] </xsl:text>
    352     <xsl:apply-templates select="@type"/>
    353     <xsl:text> * item);&#x0A;&#x0A;</xsl:text>
    354     <!-- Enumerate -->
    355     <xsl:text>    HRESULT Enumerate ([out, retval] </xsl:text>
    356     <xsl:apply-templates select="@enumerator"/>
    357     <xsl:text> * enumerator);&#x0A;&#x0A;</xsl:text>
    358     <!-- other extra attributes (properties) -->
    359     <xsl:apply-templates select="attribute"/>
    360     <!-- other extra methods -->
    361     <xsl:apply-templates select="method"/>
    362     <!-- 'if' enclosed elements, unsorted -->
    363     <xsl:apply-templates select="if"/>
    364     <!-- -->
    365     <xsl:text>&#x0A;}; /* interface </xsl:text>
    366     <xsl:value-of select="@name"/>
    367     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     346  <xsl:value-of select="@name"/>
     347  <xsl:text> : IUnknown&#x0A;{&#x0A;</xsl:text>
     348  <!-- Count -->
     349  <xsl:text>    [propget] HRESULT Count ([out, retval] ULONG * count);&#x0A;&#x0A;</xsl:text>
     350  <!-- GetItemAt -->
     351  <xsl:text>    HRESULT GetItemAt ([in] ULONG index, [out, retval] </xsl:text>
     352  <xsl:apply-templates select="@type"/>
     353  <xsl:text> * item);&#x0A;&#x0A;</xsl:text>
     354  <!-- Enumerate -->
     355  <xsl:text>    HRESULT Enumerate ([out, retval] </xsl:text>
     356  <xsl:apply-templates select="@enumerator"/>
     357  <xsl:text> * enumerator);&#x0A;&#x0A;</xsl:text>
     358  <!-- other extra attributes (properties) -->
     359  <xsl:apply-templates select="attribute"/>
     360  <!-- other extra methods -->
     361  <xsl:apply-templates select="method"/>
     362  <!-- 'if' enclosed elements, unsorted -->
     363  <xsl:apply-templates select="if"/>
     364  <!-- -->
     365  <xsl:text>&#x0A;}; /* interface </xsl:text>
     366  <xsl:value-of select="@name"/>
     367  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    368368</xsl:template>
    369369
     
    377377]
    378378<xsl:text>typedef enum &#x0A;{&#x0A;</xsl:text>
    379     <xsl:for-each select="const">
    380         <xsl:text>    </xsl:text>
    381         <xsl:value-of select="concat(../@name,'_',@name)"/> = <xsl:value-of select="@value"/>
    382         <xsl:choose>
    383             <xsl:when test="position()!=last()"><xsl:text>,&#x0A;</xsl:text></xsl:when>
    384             <xsl:otherwise><xsl:text>&#x0A;</xsl:text></xsl:otherwise>
    385         </xsl:choose>
    386     </xsl:for-each>
    387     <xsl:text>} </xsl:text>
    388     <xsl:value-of select="@name"/>
    389     <xsl:text>;&#x0A;&#x0A;</xsl:text>
    390     <!-- -->
    391     <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
    392     <xsl:value-of select="concat('cpp_quote(&quot;#define ', @name, '_T', ' ',
    393                                  @name, '&quot;)&#x0A;&#x0A;')"/>
    394     <xsl:text>&#x0A;&#x0A;</xsl:text>
     379  <xsl:for-each select="const">
     380    <xsl:text>    </xsl:text>
     381    <xsl:value-of select="concat(../@name,'_',@name)"/> = <xsl:value-of select="@value"/>
     382    <xsl:choose>
     383      <xsl:when test="position()!=last()"><xsl:text>,&#x0A;</xsl:text></xsl:when>
     384      <xsl:otherwise><xsl:text>&#x0A;</xsl:text></xsl:otherwise>
     385    </xsl:choose>
     386  </xsl:for-each>
     387  <xsl:text>} </xsl:text>
     388  <xsl:value-of select="@name"/>
     389  <xsl:text>;&#x0A;&#x0A;</xsl:text>
     390  <!-- -->
     391  <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
     392  <xsl:value-of select="concat('cpp_quote(&quot;#define ', @name, '_T', ' ',
     393                               @name, '&quot;)&#x0A;&#x0A;')"/>
     394  <xsl:text>&#x0A;&#x0A;</xsl:text>
    395395</xsl:template>
    396396
     
    400400-->
    401401<xsl:template match="method/param">
    402     <xsl:text>[</xsl:text>
     402  <xsl:text>[</xsl:text>
     403  <xsl:choose>
     404    <xsl:when test="@dir='in'">in</xsl:when>
     405    <xsl:when test="@dir='out'">out</xsl:when>
     406    <xsl:when test="@dir='return'">out, retval</xsl:when>
     407    <xsl:otherwise>in</xsl:otherwise>
     408  </xsl:choose>
     409  <xsl:if test="@safearray='yes'">
     410    <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
     411    <xsl:if test="@dir='in'">, out</xsl:if>
     412  </xsl:if>
     413  <xsl:if test="@array">
     414    <xsl:if test="@dir='return'">
     415      <xsl:message terminate="yes">
     416        <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     417        <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
     418      </xsl:message>
     419    </xsl:if>
    403420    <xsl:choose>
    404         <xsl:when test="@dir='in'">in</xsl:when>
    405         <xsl:when test="@dir='out'">out</xsl:when>
    406         <xsl:when test="@dir='return'">out, retval</xsl:when>
    407         <xsl:otherwise>in</xsl:otherwise>
     421      <xsl:when test="../param[@name=current()/@array]">
     422        <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
     423          <xsl:message terminate="yes">
     424            <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
     425            <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
     426            <xsl:text> must have the same direction</xsl:text>
     427          </xsl:message>
     428        </xsl:if>
     429        <xsl:text>, size_is(</xsl:text>
     430        <xsl:if test="@dir='out'">
     431          <xsl:text>, *</xsl:text>
     432        </xsl:if>
     433        <xsl:text>a</xsl:text>
     434        <xsl:call-template name="capitalize">
     435          <xsl:with-param name="str" select="@array"/>
     436        </xsl:call-template>
     437        <xsl:text>)</xsl:text>
     438      </xsl:when>
     439      <xsl:otherwise>
     440        <xsl:message terminate="yes">
     441          <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     442          <xsl:text>array attribute refers to non-existent param: </xsl:text>
     443          <xsl:value-of select="@array"/>
     444        </xsl:message>
     445      </xsl:otherwise>
    408446    </xsl:choose>
    409     <xsl:if test="@safearray='yes'">
    410         <!-- VB supports only [in, out], [out] and [out, retval] arrays -->
    411         <xsl:if test="@dir='in'">, out</xsl:if>
    412     </xsl:if>
    413     <xsl:if test="@array">
    414         <xsl:if test="@dir='return'">
    415             <xsl:message terminate="yes">
    416                 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    417                 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
    418             </xsl:message>
    419         </xsl:if>
    420         <xsl:choose>
    421             <xsl:when test="../param[@name=current()/@array]">
    422                 <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
    423                     <xsl:message terminate="yes">
    424                         <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
    425                         <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
    426                         <xsl:text> must have the same direction</xsl:text>
    427                     </xsl:message>
    428                 </xsl:if>
    429                 <xsl:text>, size_is(</xsl:text>
    430                     <xsl:if test="@dir='out'">
    431                         <xsl:text>, *</xsl:text>
    432                     </xsl:if>
    433                     <xsl:text>a</xsl:text>
    434                     <xsl:call-template name="capitalize">
    435                         <xsl:with-param name="str" select="@array"/>
    436                     </xsl:call-template>
    437                 <xsl:text>)</xsl:text>
     447  </xsl:if>
     448  <xsl:text>] </xsl:text>
     449  <xsl:if test="@safearray='yes'">
     450    <xsl:text>SAFEARRAY(</xsl:text>
     451  </xsl:if>
     452  <xsl:apply-templates select="@type"/>
     453  <xsl:if test="@safearray='yes'">
     454    <xsl:text>)</xsl:text>
     455  </xsl:if>
     456  <xsl:if test="@array">
     457    <xsl:text> *</xsl:text>
     458  </xsl:if>
     459  <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'">
     460    <xsl:text> *</xsl:text>
     461  </xsl:if>
     462  <xsl:text> a</xsl:text>
     463  <xsl:call-template name="capitalize">
     464    <xsl:with-param name="str" select="@name"/>
     465  </xsl:call-template>
     466</xsl:template>
     467
     468
     469<!--
     470 *  attribute/parameter type conversion
     471-->
     472<xsl:template match="
     473  attribute/@type | param/@type |
     474  enumerator/@type | collection/@type | collection/@enumerator
     475">
     476  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
     477
     478  <xsl:if test="../@array and ../@safearray='yes'">
     479    <xsl:message terminate="yes">
     480      <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     481      <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
     482    </xsl:message>
     483  </xsl:if>
     484
     485  <xsl:choose>
     486    <!-- modifiers (ignored for 'enumeration' attributes)-->
     487    <xsl:when test="name(current())='type' and ../@mod">
     488      <xsl:choose>
     489        <xsl:when test="../@mod='ptr'">
     490          <xsl:choose>
     491            <!-- standard types -->
     492            <!--xsl:when test=".='result'">??</xsl:when-->
     493            <xsl:when test=".='boolean'">BOOL *</xsl:when>
     494            <xsl:when test=".='octet'">BYTE *</xsl:when>
     495            <xsl:when test=".='short'">SHORT *</xsl:when>
     496            <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
     497            <xsl:when test=".='long'">LONG *</xsl:when>
     498            <xsl:when test=".='long long'">LONG64 *</xsl:when>
     499            <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
     500            <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
     501            <xsl:when test=".='char'">CHAR *</xsl:when>
     502            <!--xsl:when test=".='string'">??</xsl:when-->
     503            <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
     504            <!--xsl:when test=".='wstring'">??</xsl:when-->
     505            <xsl:otherwise>
     506              <xsl:message terminate="yes">
     507                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     508                <xsl:text>attribute 'mod=</xsl:text>
     509                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     510                <xsl:text>' cannot be used with type </xsl:text>
     511                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     512              </xsl:message>
     513            </xsl:otherwise>
     514          </xsl:choose>
     515        </xsl:when>
     516        <xsl:otherwise>
     517          <xsl:message terminate="yes">
     518            <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     519            <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     520            <xsl:text>of attribute 'mod' is invalid!</xsl:text>
     521          </xsl:message>
     522        </xsl:otherwise>
     523      </xsl:choose>
     524    </xsl:when>
     525    <!-- no modifiers -->
     526    <xsl:otherwise>
     527      <xsl:choose>
     528        <!-- standard types -->
     529        <xsl:when test=".='result'">HRESULT</xsl:when>
     530        <xsl:when test=".='boolean'">BOOL</xsl:when>
     531        <xsl:when test=".='octet'">BYTE</xsl:when>
     532        <xsl:when test=".='short'">SHORT</xsl:when>
     533        <xsl:when test=".='unsigned short'">USHORT</xsl:when>
     534        <xsl:when test=".='long'">LONG</xsl:when>
     535        <xsl:when test=".='long long'">LONG64</xsl:when>
     536        <xsl:when test=".='unsigned long'">ULONG</xsl:when>
     537        <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
     538        <xsl:when test=".='char'">CHAR</xsl:when>
     539        <xsl:when test=".='string'">CHAR *</xsl:when>
     540        <xsl:when test=".='wchar'">OLECHAR</xsl:when>
     541        <xsl:when test=".='wstring'">BSTR</xsl:when>
     542        <!-- UUID type -->
     543        <xsl:when test=".='uuid'">GUID</xsl:when>
     544        <!-- system interface types -->
     545        <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
     546        <xsl:otherwise>
     547          <xsl:choose>
     548            <!-- enum types -->
     549            <xsl:when test="
     550              (ancestor::library/enum[@name=current()]) or
     551              (ancestor::library/if[@target=$self_target]/enum[@name=current()])
     552            ">
     553              <xsl:value-of select="."/>
    438554            </xsl:when>
     555            <!-- custom interface types -->
     556            <xsl:when test="
     557              (name(current())='enumerator' and
     558               ((ancestor::library/enumerator[@name=current()]) or
     559                (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
     560              ) or
     561              ((ancestor::library/interface[@name=current()]) or
     562               (ancestor::library/if[@target=$self_target]/interface[@name=current()])
     563              ) or
     564              ((ancestor::library/collection[@name=current()]) or
     565               (ancestor::library/if[@target=$self_target]/collection[@name=current()])
     566              )
     567            ">
     568              <xsl:value-of select="."/><xsl:text> *</xsl:text>
     569            </xsl:when>
     570            <!-- other types -->
    439571            <xsl:otherwise>
    440                 <xsl:message terminate="yes">
    441                     <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    442                     <xsl:text>array attribute refers to non-existent param: </xsl:text>
    443                     <xsl:value-of select="@array"/>
    444                 </xsl:message>
     572              <xsl:message terminate="yes">
     573                <xsl:text>Unknown parameter type: </xsl:text>
     574                <xsl:value-of select="."/>
     575              </xsl:message>
    445576            </xsl:otherwise>
    446         </xsl:choose>
    447     </xsl:if>
    448     <xsl:text>] </xsl:text>
    449     <xsl:if test="@safearray='yes'">
    450         <xsl:text>SAFEARRAY(</xsl:text>
    451     </xsl:if>
    452     <xsl:apply-templates select="@type"/>
    453     <xsl:if test="@safearray='yes'">
    454         <xsl:text>)</xsl:text>
    455     </xsl:if>
    456     <xsl:if test="@array">
    457         <xsl:text> *</xsl:text>
    458     </xsl:if>
    459     <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'">
    460         <xsl:text> *</xsl:text>
    461     </xsl:if>
    462     <xsl:text> a</xsl:text>
    463     <xsl:call-template name="capitalize">
    464         <xsl:with-param name="str" select="@name"/>
    465     </xsl:call-template>
    466 </xsl:template>
    467 
    468 
    469 <!--
    470  *  attribute/parameter type conversion
    471 -->
    472 <xsl:template match="
    473     attribute/@type | param/@type |
    474     enumerator/@type | collection/@type | collection/@enumerator
    475 ">
    476     <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    477 
    478     <xsl:if test="../@array and ../@safearray='yes'">
    479         <xsl:message terminate="yes">
    480             <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    481             <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
    482         </xsl:message>
    483     </xsl:if>
    484 
    485     <xsl:choose>
    486         <!-- modifiers (ignored for 'enumeration' attributes)-->
    487         <xsl:when test="name(current())='type' and ../@mod">
    488             <xsl:choose>
    489                 <xsl:when test="../@mod='ptr'">
    490                     <xsl:choose>
    491                         <!-- standard types -->
    492                         <!--xsl:when test=".='result'">??</xsl:when-->
    493                         <xsl:when test=".='boolean'">BOOL *</xsl:when>
    494                         <xsl:when test=".='octet'">BYTE *</xsl:when>
    495                         <xsl:when test=".='short'">SHORT *</xsl:when>
    496                         <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
    497                         <xsl:when test=".='long'">LONG *</xsl:when>
    498                         <xsl:when test=".='long long'">LONG64 *</xsl:when>
    499                         <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
    500                         <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
    501                         <xsl:when test=".='char'">CHAR *</xsl:when>
    502                         <!--xsl:when test=".='string'">??</xsl:when-->
    503                         <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
    504                         <!--xsl:when test=".='wstring'">??</xsl:when-->
    505                         <xsl:otherwise>
    506                             <xsl:message terminate="yes">
    507                                 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    508                                 <xsl:text>attribute 'mod=</xsl:text>
    509                                 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
    510                                 <xsl:text>' cannot be used with type </xsl:text>
    511                                 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
    512                             </xsl:message>
    513                         </xsl:otherwise>
    514                     </xsl:choose>
    515                 </xsl:when>
    516                 <xsl:otherwise>
    517                     <xsl:message terminate="yes">
    518                         <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    519                         <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
    520                         <xsl:text>of attribute 'mod' is invalid!</xsl:text>
    521                     </xsl:message>
    522                 </xsl:otherwise>
    523             </xsl:choose>
    524         </xsl:when>
    525         <!-- no modifiers -->
    526         <xsl:otherwise>
    527             <xsl:choose>
    528                 <!-- standard types -->
    529                 <xsl:when test=".='result'">HRESULT</xsl:when>
    530                 <xsl:when test=".='boolean'">BOOL</xsl:when>
    531                 <xsl:when test=".='octet'">BYTE</xsl:when>
    532                 <xsl:when test=".='short'">SHORT</xsl:when>
    533                 <xsl:when test=".='unsigned short'">USHORT</xsl:when>
    534                 <xsl:when test=".='long'">LONG</xsl:when>
    535                 <xsl:when test=".='long long'">LONG64</xsl:when>
    536                 <xsl:when test=".='unsigned long'">ULONG</xsl:when>
    537                 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
    538                 <xsl:when test=".='char'">CHAR</xsl:when>
    539                 <xsl:when test=".='string'">CHAR *</xsl:when>
    540                 <xsl:when test=".='wchar'">OLECHAR</xsl:when>
    541                 <xsl:when test=".='wstring'">BSTR</xsl:when>
    542                 <!-- UUID type -->
    543                 <xsl:when test=".='uuid'">GUID</xsl:when>
    544                 <!-- system interface types -->
    545                 <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
    546                 <xsl:otherwise>
    547                     <xsl:choose>
    548                         <!-- enum types -->
    549                         <xsl:when test="
    550                             (ancestor::library/enum[@name=current()]) or
    551                             (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    552                         ">
    553                             <xsl:value-of select="."/>
    554                         </xsl:when>
    555                         <!-- custom interface types -->
    556                         <xsl:when test="
    557                             (name(current())='enumerator' and
    558                              ((ancestor::library/enumerator[@name=current()]) or
    559                               (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
    560                             ) or
    561                             ((ancestor::library/interface[@name=current()]) or
    562                              (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    563                             ) or
    564                             ((ancestor::library/collection[@name=current()]) or
    565                              (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    566                             )
    567                         ">
    568                             <xsl:value-of select="."/><xsl:text> *</xsl:text>
    569                         </xsl:when>
    570                         <!-- other types -->
    571                         <xsl:otherwise>
    572                             <xsl:message terminate="yes">
    573                                 <xsl:text>Unknown parameter type: </xsl:text>
    574                                 <xsl:value-of select="."/>
    575                             </xsl:message>
    576                         </xsl:otherwise>
    577                     </xsl:choose>
    578                 </xsl:otherwise>
    579             </xsl:choose>
     577          </xsl:choose>
    580578        </xsl:otherwise>
    581     </xsl:choose>
     579      </xsl:choose>
     580    </xsl:otherwise>
     581  </xsl:choose>
    582582</xsl:template>
    583583
  • trunk/src/VBox/Main/idl/xpidl.xsl

    r6851 r7216  
    66
    77     Copyright (C) 2006-2007 innotek GmbH
    8    
     8
    99     This file is part of VirtualBox Open Source Edition (OSE), as
    1010     available from http://www.virtualbox.org. This file is free software;
     
    3131-->
    3232<xsl:template name="capitalize">
    33     <xsl:param name="str" select="."/>
    34     <xsl:value-of select="
    35         concat(
    36             translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
    37             substring($str,2)
    38         )
    39     "/>
     33  <xsl:param name="str" select="."/>
     34  <xsl:value-of select="
     35    concat(
     36      translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
     37      substring($str,2)
     38    )
     39  "/>
    4040</xsl:template>
    4141
     
    4545-->
    4646<xsl:template name="uncapitalize">
    47     <xsl:param name="str" select="."/>
    48     <xsl:choose>
    49         <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
    50             <xsl:value-of select="
    51                 concat(
    52                     translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
    53                     substring($str,2)
    54                 )
    55             "/>
    56         </xsl:when>
    57         <xsl:otherwise>
    58             <xsl:value-of select="string($str)"/>
    59         </xsl:otherwise>
    60     </xsl:choose>
     47  <xsl:param name="str" select="."/>
     48  <xsl:choose>
     49    <xsl:when test="not(contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', substring($str,2,1)))">
     50      <xsl:value-of select="
     51        concat(
     52          translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
     53          substring($str,2)
     54        )
     55      "/>
     56    </xsl:when>
     57    <xsl:otherwise>
     58      <xsl:value-of select="string($str)"/>
     59    </xsl:otherwise>
     60  </xsl:choose>
    6161</xsl:template>
    6262
     
    6565-->
    6666<xsl:template name="uppercase">
    67     <xsl:param name="str" select="."/>
    68     <xsl:value-of select="
    69         translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    70     "/>
     67  <xsl:param name="str" select="."/>
     68  <xsl:value-of select="
     69    translate($str,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')
     70  "/>
    7171</xsl:template>
    7272
     
    8282-->
    8383<xsl:template match="/idl">
    84     <xsl:text>
     84  <xsl:text>
    8585/*
    8686 *  DO NOT EDIT! This is a generated file.
     
    9696#include "nsIException.idl"
    9797</xsl:text>
    98     <!-- native typedefs for the 'mod="ptr"' attribute -->
    99     <xsl:text>
     98  <!-- native typedefs for the 'mod="ptr"' attribute -->
     99  <xsl:text>
    100100[ptr] native booeanPtr  (PRBool);
    101101[ptr] native octetPtr   (PRUint8);
     
    113113
    114114</xsl:text>
     115  <xsl:apply-templates/>
     116</xsl:template>
     117
     118
     119<!--
     120 *  ignore all |if|s except those for XPIDL target
     121-->
     122<xsl:template match="if">
     123  <xsl:if test="@target='xpidl'">
    115124    <xsl:apply-templates/>
    116 </xsl:template>
    117 
    118 
    119 <!--
    120  *  ignore all |if|s except those for XPIDL target
    121 -->
    122 <xsl:template match="if">
    123     <xsl:if test="@target='xpidl'">
    124         <xsl:apply-templates/>
    125     </xsl:if>
     125  </xsl:if>
    126126</xsl:template>
    127127<xsl:template match="if" mode="forward">
    128     <xsl:if test="@target='xpidl'">
    129         <xsl:apply-templates mode="forward"/>
    130     </xsl:if>
     128  <xsl:if test="@target='xpidl'">
     129    <xsl:apply-templates mode="forward"/>
     130  </xsl:if>
    131131</xsl:template>
    132132
     
    136136-->
    137137<xsl:template match="cpp">
    138     <xsl:if test="text()">
    139         <xsl:text>%{C++</xsl:text>
    140         <xsl:value-of select="text()"/>
    141         <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
    142     </xsl:if>
    143     <xsl:if test="not(text()) and @line">
    144         <xsl:text>%{C++&#x0A;</xsl:text>
    145         <xsl:value-of select="@line"/>
    146         <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
    147     </xsl:if>
     138  <xsl:if test="text()">
     139    <xsl:text>%{C++</xsl:text>
     140    <xsl:value-of select="text()"/>
     141    <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
     142  </xsl:if>
     143  <xsl:if test="not(text()) and @line">
     144    <xsl:text>%{C++&#x0A;</xsl:text>
     145    <xsl:value-of select="@line"/>
     146    <xsl:text>&#x0A;%}&#x0A;&#x0A;</xsl:text>
     147  </xsl:if>
    148148</xsl:template>
    149149
     
    157157-->
    158158<xsl:template match="@if" mode="begin">
    159     <xsl:message terminate="yes">
    160         @if attributes are not currently allowed because xpidl lacks
    161         support of #ifdef and stuff.
    162     </xsl:message>
    163     <xsl:text>#if </xsl:text>
    164     <xsl:value-of select="."/>
    165     <xsl:text>&#x0A;</xsl:text>
     159  <xsl:message terminate="yes">
     160    @if attributes are not currently allowed because xpidl lacks
     161    support of #ifdef and stuff.
     162  </xsl:message>
     163  <xsl:text>#if </xsl:text>
     164  <xsl:value-of select="."/>
     165  <xsl:text>&#x0A;</xsl:text>
    166166</xsl:template>
    167167<xsl:template match="@if" mode="end">
    168     <xsl:text>#endif&#x0A;</xsl:text>
     168  <xsl:text>#endif&#x0A;</xsl:text>
    169169</xsl:template>
    170170
     
    174174-->
    175175<xsl:template match="library">
    176     <!-- forward declarations -->
    177     <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
    178     <xsl:text>&#x0A;</xsl:text>
    179     <!-- all enums go first -->
    180     <xsl:apply-templates select="enum | if/enum"/>
    181     <!-- everything else but enums -->
    182     <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
     176  <!-- forward declarations -->
     177  <xsl:apply-templates select="if | interface | collection | enumerator" mode="forward"/>
     178  <xsl:text>&#x0A;</xsl:text>
     179  <!-- all enums go first -->
     180  <xsl:apply-templates select="enum | if/enum"/>
     181  <!-- everything else but enums -->
     182  <xsl:apply-templates select="*[not(self::enum) and not(self::if[enum])]"/>
    183183</xsl:template>
    184184
     
    188188-->
    189189<xsl:template match="interface | collection | enumerator" mode="forward">
    190     <xsl:text>interface </xsl:text>
    191     <xsl:value-of select="@name"/>
    192     <xsl:text>;&#x0A;</xsl:text>
     190  <xsl:text>interface </xsl:text>
     191  <xsl:value-of select="@name"/>
     192  <xsl:text>;&#x0A;</xsl:text>
    193193</xsl:template>
    194194
     
    202202]
    203203<xsl:text>interface </xsl:text>
    204     <xsl:value-of select="@name"/>
    205     <xsl:text> : </xsl:text>
    206     <xsl:choose>
    207         <xsl:when test="@extends='$unknown'">nsISupports</xsl:when>
    208         <xsl:when test="@extends='$dispatched'">nsISupports</xsl:when>
    209         <xsl:when test="@extends='$errorinfo'">nsIException</xsl:when>
    210         <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
    211     </xsl:choose>
    212     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    213     <!-- attributes (properties) -->
    214     <xsl:apply-templates select="attribute"/>
    215     <!-- methods -->
    216     <xsl:apply-templates select="method"/>
    217     <!-- 'if' enclosed elements, unsorted -->
    218     <xsl:apply-templates select="if"/>
    219     <!-- -->
    220     <xsl:text>}; /* interface </xsl:text>
    221     <xsl:value-of select="@name"/>
    222     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     204  <xsl:value-of select="@name"/>
     205  <xsl:text> : </xsl:text>
     206  <xsl:choose>
     207      <xsl:when test="@extends='$unknown'">nsISupports</xsl:when>
     208      <xsl:when test="@extends='$dispatched'">nsISupports</xsl:when>
     209      <xsl:when test="@extends='$errorinfo'">nsIException</xsl:when>
     210      <xsl:otherwise><xsl:value-of select="@extends"/></xsl:otherwise>
     211  </xsl:choose>
     212  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     213  <!-- attributes (properties) -->
     214  <xsl:apply-templates select="attribute"/>
     215  <!-- methods -->
     216  <xsl:apply-templates select="method"/>
     217  <!-- 'if' enclosed elements, unsorted -->
     218  <xsl:apply-templates select="if"/>
     219  <!-- -->
     220  <xsl:text>}; /* interface </xsl:text>
     221  <xsl:value-of select="@name"/>
     222  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    223223</xsl:template>
    224224
     
    227227-->
    228228<xsl:template match="interface//attribute | collection//attribute">
    229     <xsl:if test="@array">
    230         <xsl:message terminate="yes">
    231             <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    232             <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
    233         </xsl:message>
    234     </xsl:if>
    235     <xsl:apply-templates select="@if" mode="begin"/>
    236     <xsl:if test="@mod='ptr'">
    237         <!-- attributes using native types must be non-scriptable -->
    238         <xsl:text>    [noscript]&#x0A;</xsl:text>
    239     </xsl:if>
    240     <xsl:choose>
    241         <!-- safearray pseudo attribute -->
    242         <xsl:when test="@safearray='yes'">
    243             <!-- getter -->
    244             <xsl:text>    void get</xsl:text>
    245             <xsl:call-template name="capitalize">
    246                 <xsl:with-param name="str" select="@name"/>
    247             </xsl:call-template>
    248             <xsl:text> (&#x0A;</xsl:text>
    249             <!-- array size -->
    250             <xsl:text>        out unsigned long </xsl:text>
    251             <xsl:value-of select="@name"/>
    252             <xsl:text>Size,&#x0A;</xsl:text>
    253             <!-- array pointer -->
    254             <xsl:text>        [array, size_is(</xsl:text>
    255             <xsl:value-of select="@name"/>
    256             <xsl:text>Size), retval] out </xsl:text>
    257             <xsl:apply-templates select="@type"/>
    258             <xsl:text> </xsl:text>
    259             <xsl:value-of select="@name"/>
    260             <xsl:text>&#x0A;    );&#x0A;</xsl:text>
    261             <!-- setter -->
    262             <xsl:if test="not(@readonly='yes')">
    263                 <xsl:text>    void set</xsl:text>
    264                 <xsl:call-template name="capitalize">
    265                     <xsl:with-param name="str" select="@name"/>
    266                 </xsl:call-template>
    267                 <xsl:text> (&#x0A;</xsl:text>
    268                 <!-- array size -->
    269                 <xsl:text>        in unsigned long </xsl:text>
    270                 <xsl:value-of select="@name"/>
    271                 <xsl:text>Size,&#x0A;</xsl:text>
    272                 <!-- array pointer -->
    273                 <xsl:text>        [array, size_is(</xsl:text>
    274                 <xsl:value-of select="@name"/>
    275                 <xsl:text>Size)] in </xsl:text>
    276                 <xsl:apply-templates select="@type"/>
    277                 <xsl:text> </xsl:text>
    278                 <xsl:value-of select="@name"/>
    279                 <xsl:text>&#x0A;    );&#x0A;</xsl:text>
    280             </xsl:if>
    281         </xsl:when>
    282         <!-- normal attribute -->
    283         <xsl:otherwise>
    284             <xsl:text>    </xsl:text>
    285             <xsl:if test="@readonly='yes'">
    286                 <xsl:text>readonly </xsl:text>
    287             </xsl:if>
    288             <xsl:text>attribute </xsl:text>
    289             <xsl:apply-templates select="@type"/>
    290             <xsl:text> </xsl:text>
    291             <xsl:value-of select="@name"/>
    292             <xsl:text>;&#x0A;</xsl:text>
    293         </xsl:otherwise>
    294     </xsl:choose>
    295     <xsl:apply-templates select="@if" mode="end"/>
    296     <xsl:text>&#x0A;</xsl:text>
     229  <xsl:if test="@array">
     230    <xsl:message terminate="yes">
     231      <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     232      <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text>
     233    </xsl:message>
     234  </xsl:if>
     235  <xsl:apply-templates select="@if" mode="begin"/>
     236  <xsl:if test="@mod='ptr'">
     237    <!-- attributes using native types must be non-scriptable -->
     238    <xsl:text>    [noscript]&#x0A;</xsl:text>
     239  </xsl:if>
     240  <xsl:choose>
     241    <!-- safearray pseudo attribute -->
     242    <xsl:when test="@safearray='yes'">
     243      <!-- getter -->
     244      <xsl:text>    void get</xsl:text>
     245      <xsl:call-template name="capitalize">
     246        <xsl:with-param name="str" select="@name"/>
     247      </xsl:call-template>
     248      <xsl:text> (&#x0A;</xsl:text>
     249      <!-- array size -->
     250      <xsl:text>        out unsigned long </xsl:text>
     251      <xsl:value-of select="@name"/>
     252      <xsl:text>Size,&#x0A;</xsl:text>
     253      <!-- array pointer -->
     254      <xsl:text>        [array, size_is(</xsl:text>
     255      <xsl:value-of select="@name"/>
     256      <xsl:text>Size), retval] out </xsl:text>
     257      <xsl:apply-templates select="@type"/>
     258      <xsl:text> </xsl:text>
     259      <xsl:value-of select="@name"/>
     260      <xsl:text>&#x0A;    );&#x0A;</xsl:text>
     261      <!-- setter -->
     262      <xsl:if test="not(@readonly='yes')">
     263        <xsl:text>    void set</xsl:text>
     264        <xsl:call-template name="capitalize">
     265          <xsl:with-param name="str" select="@name"/>
     266        </xsl:call-template>
     267        <xsl:text> (&#x0A;</xsl:text>
     268        <!-- array size -->
     269        <xsl:text>        in unsigned long </xsl:text>
     270        <xsl:value-of select="@name"/>
     271        <xsl:text>Size,&#x0A;</xsl:text>
     272        <!-- array pointer -->
     273        <xsl:text>        [array, size_is(</xsl:text>
     274        <xsl:value-of select="@name"/>
     275        <xsl:text>Size)] in </xsl:text>
     276        <xsl:apply-templates select="@type"/>
     277        <xsl:text> </xsl:text>
     278        <xsl:value-of select="@name"/>
     279        <xsl:text>&#x0A;    );&#x0A;</xsl:text>
     280      </xsl:if>
     281    </xsl:when>
     282    <!-- normal attribute -->
     283    <xsl:otherwise>
     284      <xsl:text>    </xsl:text>
     285      <xsl:if test="@readonly='yes'">
     286        <xsl:text>readonly </xsl:text>
     287      </xsl:if>
     288      <xsl:text>attribute </xsl:text>
     289      <xsl:apply-templates select="@type"/>
     290      <xsl:text> </xsl:text>
     291      <xsl:value-of select="@name"/>
     292      <xsl:text>;&#x0A;</xsl:text>
     293    </xsl:otherwise>
     294  </xsl:choose>
     295  <xsl:apply-templates select="@if" mode="end"/>
     296  <xsl:text>&#x0A;</xsl:text>
    297297</xsl:template>
    298298
     
    301301-->
    302302<xsl:template match="interface//method | collection//method">
    303     <xsl:apply-templates select="@if" mode="begin"/>
    304     <xsl:if test="param/@mod='ptr'">
    305         <!-- methods using native types must be non-scriptable -->
    306         <xsl:text>    [noscript]&#x0A;</xsl:text>
    307     </xsl:if>
    308     <xsl:text>    void </xsl:text>
    309     <xsl:value-of select="@name"/>
    310     <xsl:if test="param">
    311         <xsl:text> (&#x0A;</xsl:text>
    312         <xsl:for-each select="param [position() != last()]">
    313             <xsl:text>        </xsl:text>
    314             <xsl:apply-templates select="."/>
    315             <xsl:text>,&#x0A;</xsl:text>
    316         </xsl:for-each>
    317         <xsl:text>        </xsl:text>
    318         <xsl:apply-templates select="param [last()]"/>
    319         <xsl:text>&#x0A;    );&#x0A;</xsl:text>
    320     </xsl:if>
    321     <xsl:if test="not(param)">
    322         <xsl:text>();&#x0A;</xsl:text>
    323     </xsl:if>
    324     <xsl:apply-templates select="@if" mode="end"/>
    325     <xsl:text>&#x0A;</xsl:text>
     303  <xsl:apply-templates select="@if" mode="begin"/>
     304  <xsl:if test="param/@mod='ptr'">
     305    <!-- methods using native types must be non-scriptable -->
     306    <xsl:text>    [noscript]&#x0A;</xsl:text>
     307  </xsl:if>
     308  <xsl:text>    void </xsl:text>
     309  <xsl:value-of select="@name"/>
     310  <xsl:if test="param">
     311    <xsl:text> (&#x0A;</xsl:text>
     312    <xsl:for-each select="param [position() != last()]">
     313      <xsl:text>        </xsl:text>
     314      <xsl:apply-templates select="."/>
     315      <xsl:text>,&#x0A;</xsl:text>
     316    </xsl:for-each>
     317    <xsl:text>        </xsl:text>
     318    <xsl:apply-templates select="param [last()]"/>
     319    <xsl:text>&#x0A;    );&#x0A;</xsl:text>
     320  </xsl:if>
     321  <xsl:if test="not(param)">
     322    <xsl:text>();&#x0A;</xsl:text>
     323  </xsl:if>
     324  <xsl:apply-templates select="@if" mode="end"/>
     325  <xsl:text>&#x0A;</xsl:text>
    326326</xsl:template>
    327327
     
    331331-->
    332332<xsl:template match="module/class">
    333     <!-- class and contract id -->
    334     <xsl:text>%{C++&#x0A;</xsl:text>
    335     <xsl:text>#define NS_</xsl:text>
    336     <xsl:call-template name="uppercase">
    337         <xsl:with-param name="str" select="@name"/>
    338     </xsl:call-template>
    339     <xsl:text>_CID { \&#x0A;</xsl:text>
    340     <xsl:text>    0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
    341     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
    342     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
    343     <xsl:text>, \&#x0A;    </xsl:text>
    344     <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
    345     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
    346     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
    347     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
    348     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
    349     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
    350     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
    351     <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
    352     <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
    353     <xsl:text>#define NS_</xsl:text>
    354     <xsl:call-template name="uppercase">
    355         <xsl:with-param name="str" select="@name"/>
    356     </xsl:call-template>
    357     <!-- Contract ID -->
    358     <xsl:text>_CONTRACTID &quot;@</xsl:text>
    359     <xsl:value-of select="@namespace"/>
    360     <xsl:text>/</xsl:text>
    361     <xsl:value-of select="@name"/>
    362     <xsl:text>;1&quot;&#x0A;</xsl:text>
    363     <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
    364     <xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
    365     <xsl:text>#define CLSID_</xsl:text>
    366     <xsl:value-of select="@name"/>
    367     <xsl:text> (nsCID) NS_</xsl:text>
    368     <xsl:call-template name="uppercase">
    369         <xsl:with-param name="str" select="@name"/>
    370     </xsl:call-template>
    371     <xsl:text>_CID&#x0A;</xsl:text>
    372     <xsl:text>%}&#x0A;&#x0A;</xsl:text>
     333  <!-- class and contract id -->
     334  <xsl:text>%{C++&#x0A;</xsl:text>
     335  <xsl:text>#define NS_</xsl:text>
     336  <xsl:call-template name="uppercase">
     337    <xsl:with-param name="str" select="@name"/>
     338  </xsl:call-template>
     339  <xsl:text>_CID { \&#x0A;</xsl:text>
     340  <xsl:text>    0x</xsl:text><xsl:value-of select="substring(@uuid,1,8)"/>
     341  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,10,4)"/>
     342  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,15,4)"/>
     343  <xsl:text>, \&#x0A;    </xsl:text>
     344  <xsl:text>{ 0x</xsl:text><xsl:value-of select="substring(@uuid,20,2)"/>
     345  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,22,2)"/>
     346  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,25,2)"/>
     347  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,27,2)"/>
     348  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,29,2)"/>
     349  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,31,2)"/>
     350  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,33,2)"/>
     351  <xsl:text>, 0x</xsl:text><xsl:value-of select="substring(@uuid,35,2)"/>
     352  <xsl:text> } \&#x0A;}&#x0A;</xsl:text>
     353  <xsl:text>#define NS_</xsl:text>
     354  <xsl:call-template name="uppercase">
     355    <xsl:with-param name="str" select="@name"/>
     356  </xsl:call-template>
     357  <!-- Contract ID -->
     358  <xsl:text>_CONTRACTID &quot;@</xsl:text>
     359  <xsl:value-of select="@namespace"/>
     360  <xsl:text>/</xsl:text>
     361  <xsl:value-of select="@name"/>
     362  <xsl:text>;1&quot;&#x0A;</xsl:text>
     363  <!-- CLSID_xxx declarations for XPCOM, for compatibility with Win32 -->
     364  <xsl:text>// for compatibility with Win32&#x0A;</xsl:text>
     365  <xsl:text>#define CLSID_</xsl:text>
     366  <xsl:value-of select="@name"/>
     367  <xsl:text> (nsCID) NS_</xsl:text>
     368  <xsl:call-template name="uppercase">
     369    <xsl:with-param name="str" select="@name"/>
     370  </xsl:call-template>
     371  <xsl:text>_CID&#x0A;</xsl:text>
     372  <xsl:text>%}&#x0A;&#x0A;</xsl:text>
    373373</xsl:template>
    374374
     
    382382]
    383383<xsl:text>interface </xsl:text>
    384     <xsl:value-of select="@name"/>
    385     <xsl:text> : nsISupports&#x0A;{&#x0A;</xsl:text>
    386     <!-- HasMore -->
    387     <xsl:text>    void hasMore ([retval] out boolean more);&#x0A;&#x0A;</xsl:text>
    388     <!-- GetNext -->
    389     <xsl:text>    void getNext ([retval] out </xsl:text>
    390     <xsl:apply-templates select="@type"/>
    391     <xsl:text> next);&#x0A;&#x0A;</xsl:text>
    392     <!-- -->
    393     <xsl:text>}; /* interface </xsl:text>
    394     <xsl:value-of select="@name"/>
    395     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     384  <xsl:value-of select="@name"/>
     385  <xsl:text> : nsISupports&#x0A;{&#x0A;</xsl:text>
     386  <!-- HasMore -->
     387  <xsl:text>    void hasMore ([retval] out boolean more);&#x0A;&#x0A;</xsl:text>
     388  <!-- GetNext -->
     389  <xsl:text>    void getNext ([retval] out </xsl:text>
     390  <xsl:apply-templates select="@type"/>
     391  <xsl:text> next);&#x0A;&#x0A;</xsl:text>
     392  <!-- -->
     393  <xsl:text>}; /* interface </xsl:text>
     394  <xsl:value-of select="@name"/>
     395  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    396396</xsl:template>
    397397
     
    401401-->
    402402<xsl:template match="collection">
    403     <xsl:if test="not(@readonly='yes')">
    404         <xsl:message terminate="yes">
    405             <xsl:value-of select="concat(@name,': ')"/>
    406             <xsl:text>non-readonly collections are not currently supported</xsl:text>
    407         </xsl:message>
    408     </xsl:if>[
     403  <xsl:if test="not(@readonly='yes')">
     404    <xsl:message terminate="yes">
     405      <xsl:value-of select="concat(@name,': ')"/>
     406      <xsl:text>non-readonly collections are not currently supported</xsl:text>
     407    </xsl:message>
     408  </xsl:if>[
    409409    uuid(<xsl:value-of select="@uuid"/>),
    410410    scriptable
    411411]
    412412<xsl:text>interface </xsl:text>
    413     <xsl:value-of select="@name"/>
    414     <xsl:text> : nsISupports&#x0A;{&#x0A;</xsl:text>
    415     <!-- Count -->
    416     <xsl:text>    readonly attribute unsigned long count;&#x0A;&#x0A;</xsl:text>
    417     <!-- GetItemAt -->
    418     <xsl:text>    void getItemAt (in unsigned long index, [retval] out </xsl:text>
    419     <xsl:apply-templates select="@type"/>
    420     <xsl:text> item);&#x0A;&#x0A;</xsl:text>
    421     <!-- Enumerate -->
    422     <xsl:text>    void enumerate ([retval] out </xsl:text>
    423     <xsl:apply-templates select="@enumerator"/>
    424     <xsl:text> enumerator);&#x0A;&#x0A;</xsl:text>
    425     <!-- other extra attributes (properties) -->
    426     <xsl:apply-templates select="attribute"/>
    427     <!-- other extra methods -->
    428     <xsl:apply-templates select="method"/>
    429     <!-- 'if' enclosed elements, unsorted -->
    430     <xsl:apply-templates select="if"/>
    431     <!-- -->
    432     <xsl:text>}; /* interface </xsl:text>
    433     <xsl:value-of select="@name"/>
    434     <xsl:text> */&#x0A;&#x0A;</xsl:text>
     413  <xsl:value-of select="@name"/>
     414  <xsl:text> : nsISupports&#x0A;{&#x0A;</xsl:text>
     415  <!-- Count -->
     416  <xsl:text>    readonly attribute unsigned long count;&#x0A;&#x0A;</xsl:text>
     417  <!-- GetItemAt -->
     418  <xsl:text>    void getItemAt (in unsigned long index, [retval] out </xsl:text>
     419  <xsl:apply-templates select="@type"/>
     420  <xsl:text> item);&#x0A;&#x0A;</xsl:text>
     421  <!-- Enumerate -->
     422  <xsl:text>    void enumerate ([retval] out </xsl:text>
     423  <xsl:apply-templates select="@enumerator"/>
     424  <xsl:text> enumerator);&#x0A;&#x0A;</xsl:text>
     425  <!-- other extra attributes (properties) -->
     426  <xsl:apply-templates select="attribute"/>
     427  <!-- other extra methods -->
     428  <xsl:apply-templates select="method"/>
     429  <!-- 'if' enclosed elements, unsorted -->
     430  <xsl:apply-templates select="if"/>
     431  <!-- -->
     432  <xsl:text>}; /* interface </xsl:text>
     433  <xsl:value-of select="@name"/>
     434  <xsl:text> */&#x0A;&#x0A;</xsl:text>
    435435</xsl:template>
    436436
     
    444444]
    445445<xsl:text>interface </xsl:text>
    446     <xsl:value-of select="@name"/>
    447     <xsl:text>&#x0A;{&#x0A;</xsl:text>
    448     <xsl:for-each select="const">
     446  <xsl:value-of select="@name"/>
     447  <xsl:text>&#x0A;{&#x0A;</xsl:text>
     448  <xsl:for-each select="const">
    449449    <xsl:text>    const PRUint32 </xsl:text>
    450450    <xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>
    451451    <xsl:text>;&#x0A;</xsl:text>
    452     </xsl:for-each>
    453     <xsl:text>};&#x0A;&#x0A;</xsl:text>
    454     <!-- -->
    455     <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
    456     <xsl:text>%{C++&#x0A;</xsl:text>
    457     <xsl:value-of select="concat('#define ', @name, '_T', ' ',
    458                                  'PRUint32&#x0A;')"/>
    459     <xsl:text>%}&#x0A;&#x0A;</xsl:text>
    460     <!-- -->
    461     <xsl:value-of select="concat('/* cross-platform constants for ', @name, ' */&#x0A;')"/>
    462     <xsl:text>%{C++&#x0A;</xsl:text>
    463     <xsl:for-each select="const">
    464         <xsl:value-of select="concat('#define ', ../@name, '_', @name, ' ',
    465                                      ../@name, '::', @name, '&#x0A;')"/>
    466     </xsl:for-each>
    467     <xsl:text>%}&#x0A;&#x0A;</xsl:text>
     452  </xsl:for-each>
     453  <xsl:text>};&#x0A;&#x0A;</xsl:text>
     454  <!-- -->
     455  <xsl:value-of select="concat('/* cross-platform type name for ', @name, ' */&#x0A;')"/>
     456  <xsl:text>%{C++&#x0A;</xsl:text>
     457  <xsl:value-of select="concat('#define ', @name, '_T', ' ',
     458                               'PRUint32&#x0A;')"/>
     459  <xsl:text>%}&#x0A;&#x0A;</xsl:text>
     460  <!-- -->
     461  <xsl:value-of select="concat('/* cross-platform constants for ', @name, ' */&#x0A;')"/>
     462  <xsl:text>%{C++&#x0A;</xsl:text>
     463  <xsl:for-each select="const">
     464    <xsl:value-of select="concat('#define ', ../@name, '_', @name, ' ',
     465                                 ../@name, '::', @name, '&#x0A;')"/>
     466  </xsl:for-each>
     467  <xsl:text>%}&#x0A;&#x0A;</xsl:text>
    468468</xsl:template>
    469469
     
    473473-->
    474474<xsl:template match="method/param">
    475     <xsl:choose>
    476         <!-- safearray parameters -->
    477         <xsl:when test="@safearray='yes'">
    478             <!-- array size -->
    479             <xsl:choose>
    480                 <xsl:when test="@dir='in'">in </xsl:when>
    481                 <xsl:when test="@dir='out'">out </xsl:when>
    482                 <xsl:when test="@dir='return'">out </xsl:when>
    483                 <xsl:otherwise>in </xsl:otherwise>
    484             </xsl:choose>
    485             <xsl:text>unsigned long </xsl:text>
    486             <xsl:value-of select="@name"/>
    487             <xsl:text>Size,&#x0A;</xsl:text>
    488             <!-- array pointer -->
    489             <xsl:text>        [array, size_is(</xsl:text>
    490             <xsl:value-of select="@name"/>
    491             <xsl:text>Size)</xsl:text>
    492             <xsl:choose>
    493                 <xsl:when test="@dir='in'">] in </xsl:when>
    494                 <xsl:when test="@dir='out'">] out </xsl:when>
    495                 <xsl:when test="@dir='return'"> , retval] out </xsl:when>
    496                 <xsl:otherwise>] in </xsl:otherwise>
    497             </xsl:choose>
    498             <xsl:apply-templates select="@type"/>
    499             <xsl:text> </xsl:text>
    500             <xsl:value-of select="@name"/>
     475  <xsl:choose>
     476    <!-- safearray parameters -->
     477    <xsl:when test="@safearray='yes'">
     478      <!-- array size -->
     479      <xsl:choose>
     480        <xsl:when test="@dir='in'">in </xsl:when>
     481        <xsl:when test="@dir='out'">out </xsl:when>
     482        <xsl:when test="@dir='return'">out </xsl:when>
     483        <xsl:otherwise>in </xsl:otherwise>
     484      </xsl:choose>
     485      <xsl:text>unsigned long </xsl:text>
     486      <xsl:value-of select="@name"/>
     487      <xsl:text>Size,&#x0A;</xsl:text>
     488      <!-- array pointer -->
     489      <xsl:text>        [array, size_is(</xsl:text>
     490      <xsl:value-of select="@name"/>
     491      <xsl:text>Size)</xsl:text>
     492      <xsl:choose>
     493        <xsl:when test="@dir='in'">] in </xsl:when>
     494        <xsl:when test="@dir='out'">] out </xsl:when>
     495        <xsl:when test="@dir='return'"> , retval] out </xsl:when>
     496        <xsl:otherwise>] in </xsl:otherwise>
     497      </xsl:choose>
     498      <xsl:apply-templates select="@type"/>
     499      <xsl:text> </xsl:text>
     500      <xsl:value-of select="@name"/>
     501    </xsl:when>
     502    <!-- normal and array parameters -->
     503    <xsl:otherwise>
     504      <xsl:if test="@array">
     505        <xsl:if test="@dir='return'">
     506          <xsl:message terminate="yes">
     507            <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     508            <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
     509          </xsl:message>
     510        </xsl:if>
     511        <xsl:text>[array, </xsl:text>
     512        <xsl:choose>
     513          <xsl:when test="../param[@name=current()/@array]">
     514            <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
     515              <xsl:message terminate="yes">
     516                <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
     517                <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
     518                <xsl:text> must have the same direction</xsl:text>
     519              </xsl:message>
     520            </xsl:if>
     521            <xsl:text>size_is(</xsl:text>
     522            <xsl:value-of select="@array"/>
     523            <xsl:text>)</xsl:text>
     524          </xsl:when>
     525          <xsl:otherwise>
     526            <xsl:message terminate="yes">
     527              <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
     528              <xsl:text>array attribute refers to non-existent param: </xsl:text>
     529              <xsl:value-of select="@array"/>
     530            </xsl:message>
     531          </xsl:otherwise>
     532        </xsl:choose>
     533        <xsl:text>] </xsl:text>
     534      </xsl:if>
     535      <xsl:choose>
     536        <xsl:when test="@dir='in'">in </xsl:when>
     537        <xsl:when test="@dir='out'">out </xsl:when>
     538        <xsl:when test="@dir='return'">[retval] out </xsl:when>
     539        <xsl:otherwise>in </xsl:otherwise>
     540      </xsl:choose>
     541      <xsl:apply-templates select="@type"/>
     542      <xsl:text> </xsl:text>
     543      <xsl:value-of select="@name"/>
     544    </xsl:otherwise>
     545  </xsl:choose>
     546</xsl:template>
     547
     548
     549<!--
     550 *  attribute/parameter type conversion
     551-->
     552<xsl:template match="
     553  attribute/@type | param/@type |
     554  enumerator/@type | collection/@type | collection/@enumerator
     555">
     556  <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
     557
     558  <xsl:if test="../@array and ../@safearray='yes'">
     559    <xsl:message terminate="yes">
     560      <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     561      <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
     562    </xsl:message>
     563  </xsl:if>
     564
     565  <xsl:choose>
     566    <!-- modifiers (ignored for 'enumeration' attributes)-->
     567    <xsl:when test="name(current())='type' and ../@mod">
     568      <xsl:choose>
     569        <xsl:when test="../@mod='ptr'">
     570          <xsl:choose>
     571            <!-- standard types -->
     572            <!--xsl:when test=".='result'">??</xsl:when-->
     573            <xsl:when test=".='boolean'">booeanPtr</xsl:when>
     574            <xsl:when test=".='octet'">octetPtr</xsl:when>
     575            <xsl:when test=".='short'">shortPtr</xsl:when>
     576            <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
     577            <xsl:when test=".='long'">longPtr</xsl:when>
     578            <xsl:when test=".='long long'">llongPtr</xsl:when>
     579            <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
     580            <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
     581            <xsl:when test=".='char'">charPtr</xsl:when>
     582            <!--xsl:when test=".='string'">??</xsl:when-->
     583            <xsl:when test=".='wchar'">wcharPtr</xsl:when>
     584            <!--xsl:when test=".='wstring'">??</xsl:when-->
     585            <xsl:otherwise>
     586              <xsl:message terminate="yes">
     587                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     588                <xsl:text>attribute 'mod=</xsl:text>
     589                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     590                <xsl:text>' cannot be used with type </xsl:text>
     591                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     592              </xsl:message>
     593            </xsl:otherwise>
     594          </xsl:choose>
    501595        </xsl:when>
    502         <!-- normal and array parameters -->
    503596        <xsl:otherwise>
    504             <xsl:if test="@array">
    505                 <xsl:if test="@dir='return'">
    506                     <xsl:message terminate="yes">
    507                         <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    508                         <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text>
    509                     </xsl:message>
    510                 </xsl:if>
    511                 <xsl:text>[array, </xsl:text>
    512                 <xsl:choose>
    513                     <xsl:when test="../param[@name=current()/@array]">
    514                         <xsl:if test="../param[@name=current()/@array]/@dir != @dir">
    515                             <xsl:message terminate="yes">
    516                                 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/>
    517                                 <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/>
    518                                 <xsl:text> must have the same direction</xsl:text>
    519                             </xsl:message>
    520                         </xsl:if>
    521                         <xsl:text>size_is(</xsl:text>
    522                             <xsl:value-of select="@array"/>
    523                         <xsl:text>)</xsl:text>
    524                     </xsl:when>
    525                     <xsl:otherwise>
    526                         <xsl:message terminate="yes">
    527                             <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/>
    528                             <xsl:text>array attribute refers to non-existent param: </xsl:text>
    529                             <xsl:value-of select="@array"/>
    530                         </xsl:message>
    531                     </xsl:otherwise>
    532                 </xsl:choose>
    533                 <xsl:text>] </xsl:text>
    534             </xsl:if>
    535             <xsl:choose>
    536                 <xsl:when test="@dir='in'">in </xsl:when>
    537                 <xsl:when test="@dir='out'">out </xsl:when>
    538                 <xsl:when test="@dir='return'">[retval] out </xsl:when>
    539                 <xsl:otherwise>in </xsl:otherwise>
    540             </xsl:choose>
    541             <xsl:apply-templates select="@type"/>
    542             <xsl:text> </xsl:text>
    543             <xsl:value-of select="@name"/>
     597          <xsl:message terminate="yes">
     598            <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     599            <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     600            <xsl:text>of attribute 'mod' is invalid!</xsl:text>
     601          </xsl:message>
    544602        </xsl:otherwise>
    545     </xsl:choose>
    546 </xsl:template>
    547 
    548 
    549 <!--
    550  *  attribute/parameter type conversion
    551 -->
    552 <xsl:template match="
    553     attribute/@type | param/@type |
    554     enumerator/@type | collection/@type | collection/@enumerator
    555 ">
    556     <xsl:variable name="self_target" select="current()/ancestor::if/@target"/>
    557 
    558     <xsl:if test="../@array and ../@safearray='yes'">
    559         <xsl:message terminate="yes">
    560             <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    561             <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text>
    562         </xsl:message>
    563     </xsl:if>
    564 
    565     <xsl:choose>
    566         <!-- modifiers (ignored for 'enumeration' attributes)-->
    567         <xsl:when test="name(current())='type' and ../@mod">
    568             <xsl:choose>
    569                 <xsl:when test="../@mod='ptr'">
    570                     <xsl:choose>
    571                         <!-- standard types -->
    572                         <!--xsl:when test=".='result'">??</xsl:when-->
    573                         <xsl:when test=".='boolean'">booeanPtr</xsl:when>
    574                         <xsl:when test=".='octet'">octetPtr</xsl:when>
    575                         <xsl:when test=".='short'">shortPtr</xsl:when>
    576                         <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
    577                         <xsl:when test=".='long'">longPtr</xsl:when>
    578                         <xsl:when test=".='long long'">llongPtr</xsl:when>
    579                         <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
    580                         <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
    581                         <xsl:when test=".='char'">charPtr</xsl:when>
    582                         <!--xsl:when test=".='string'">??</xsl:when-->
    583                         <xsl:when test=".='wchar'">wcharPtr</xsl:when>
    584                         <!--xsl:when test=".='wstring'">??</xsl:when-->
    585                         <xsl:otherwise>
    586                             <xsl:message terminate="yes">
    587                                 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    588                                 <xsl:text>attribute 'mod=</xsl:text>
    589                                 <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
    590                                 <xsl:text>' cannot be used with type </xsl:text>
    591                                 <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
    592                             </xsl:message>
    593                         </xsl:otherwise>
    594                     </xsl:choose>
     603      </xsl:choose>
     604    </xsl:when>
     605    <!-- no modifiers -->
     606    <xsl:otherwise>
     607      <xsl:choose>
     608        <!-- standard types -->
     609        <xsl:when test=".='result'">nsresult</xsl:when>
     610        <xsl:when test=".='boolean'">boolean</xsl:when>
     611        <xsl:when test=".='octet'">octet</xsl:when>
     612        <xsl:when test=".='short'">short</xsl:when>
     613        <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
     614        <xsl:when test=".='long'">long</xsl:when>
     615        <xsl:when test=".='long long'">long long</xsl:when>
     616        <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
     617        <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
     618        <xsl:when test=".='char'">char</xsl:when>
     619        <xsl:when test=".='wchar'">wchar</xsl:when>
     620        <xsl:when test=".='string'">string</xsl:when>
     621        <xsl:when test=".='wstring'">wstring</xsl:when>
     622        <!-- UUID type -->
     623        <xsl:when test=".='uuid'">
     624          <xsl:choose>
     625            <xsl:when test="name(..)='attribute'">
     626              <xsl:choose>
     627                <xsl:when test="../@readonly='yes'">
     628                  <xsl:text>nsIDPtr</xsl:text>
    595629                </xsl:when>
    596630                <xsl:otherwise>
    597                     <xsl:message terminate="yes">
    598                         <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
    599                         <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
    600                         <xsl:text>of attribute 'mod' is invalid!</xsl:text>
    601                     </xsl:message>
     631                  <xsl:message terminate="yes">
     632                    <xsl:value-of select="../@name"/>
     633                    <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
     634                  </xsl:message>
    602635                </xsl:otherwise>
    603             </xsl:choose>
     636              </xsl:choose>
     637            </xsl:when>
     638            <xsl:when test="name(..)='param'">
     639              <xsl:choose>
     640                <xsl:when test="../@dir='in'">
     641                  <xsl:text>nsIDRef</xsl:text>
     642                </xsl:when>
     643                <xsl:otherwise>
     644                  <xsl:text>nsIDPtr</xsl:text>
     645                </xsl:otherwise>
     646              </xsl:choose>
     647            </xsl:when>
     648          </xsl:choose>
    604649        </xsl:when>
    605         <!-- no modifiers -->
     650        <!-- system interface types -->
     651        <xsl:when test=".='$unknown'">nsISupports</xsl:when>
    606652        <xsl:otherwise>
    607             <xsl:choose>
    608                 <!-- standard types -->
    609                 <xsl:when test=".='result'">nsresult</xsl:when>
    610                 <xsl:when test=".='boolean'">boolean</xsl:when>
    611                 <xsl:when test=".='octet'">octet</xsl:when>
    612                 <xsl:when test=".='short'">short</xsl:when>
    613                 <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
    614                 <xsl:when test=".='long'">long</xsl:when>
    615                 <xsl:when test=".='long long'">long long</xsl:when>
    616                 <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
    617                 <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
    618                 <xsl:when test=".='char'">char</xsl:when>
    619                 <xsl:when test=".='wchar'">wchar</xsl:when>
    620                 <xsl:when test=".='string'">string</xsl:when>
    621                 <xsl:when test=".='wstring'">wstring</xsl:when>
    622                 <!-- UUID type -->
    623                 <xsl:when test=".='uuid'">
    624                     <xsl:choose>
    625                         <xsl:when test="name(..)='attribute'">
    626                             <xsl:choose>
    627                                 <xsl:when test="../@readonly='yes'">
    628                                     <xsl:text>nsIDPtr</xsl:text>
    629                                 </xsl:when>
    630                                 <xsl:otherwise>
    631                                     <xsl:message terminate="yes">
    632                                         <xsl:value-of select="../@name"/>
    633                                         <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
    634                                     </xsl:message>
    635                                 </xsl:otherwise>
    636                             </xsl:choose>
    637                         </xsl:when>
    638                         <xsl:when test="name(..)='param'">
    639                             <xsl:choose>
    640                                 <xsl:when test="../@dir='in'">
    641                                     <xsl:text>nsIDRef</xsl:text>
    642                                 </xsl:when>
    643                                 <xsl:otherwise>
    644                                     <xsl:text>nsIDPtr</xsl:text>
    645                                 </xsl:otherwise>
    646                             </xsl:choose>
    647                         </xsl:when>
    648                     </xsl:choose>
    649                 </xsl:when>
    650                 <!-- system interface types -->
    651                 <xsl:when test=".='$unknown'">nsISupports</xsl:when>
    652                 <xsl:otherwise>
    653                     <xsl:choose>
    654                         <!-- enum types -->
    655                         <xsl:when test="
    656                             (ancestor::library/enum[@name=current()]) or
    657                             (ancestor::library/if[@target=$self_target]/enum[@name=current()])
    658                         ">
    659                             <xsl:text>PRUint32</xsl:text>
    660                         </xsl:when>
    661                         <!-- custom interface types -->
    662                         <xsl:when test="
    663                             (name(current())='enumerator' and
    664                              ((ancestor::library/enumerator[@name=current()]) or
    665                               (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
    666                             ) or
    667                             ((ancestor::library/interface[@name=current()]) or
    668                              (ancestor::library/if[@target=$self_target]/interface[@name=current()])
    669                             ) or
    670                             ((ancestor::library/collection[@name=current()]) or
    671                              (ancestor::library/if[@target=$self_target]/collection[@name=current()])
    672                             )
    673                         ">
    674                             <xsl:value-of select="."/>
    675                         </xsl:when>
    676                         <!-- other types -->
    677                         <xsl:otherwise>
    678                             <xsl:message terminate="yes">
    679                                 <xsl:text>Unknown parameter type: </xsl:text>
    680                                 <xsl:value-of select="."/>
    681                             </xsl:message>
    682                         </xsl:otherwise>
    683                     </xsl:choose>
    684                 </xsl:otherwise>
    685             </xsl:choose>
     653          <xsl:choose>
     654            <!-- enum types -->
     655            <xsl:when test="
     656              (ancestor::library/enum[@name=current()]) or
     657              (ancestor::library/if[@target=$self_target]/enum[@name=current()])
     658            ">
     659              <xsl:text>PRUint32</xsl:text>
     660            </xsl:when>
     661            <!-- custom interface types -->
     662            <xsl:when test="
     663              (name(current())='enumerator' and
     664               ((ancestor::library/enumerator[@name=current()]) or
     665                (ancestor::library/if[@target=$self_target]/enumerator[@name=current()]))
     666              ) or
     667              ((ancestor::library/interface[@name=current()]) or
     668               (ancestor::library/if[@target=$self_target]/interface[@name=current()])
     669              ) or
     670              ((ancestor::library/collection[@name=current()]) or
     671               (ancestor::library/if[@target=$self_target]/collection[@name=current()])
     672              )
     673            ">
     674              <xsl:value-of select="."/>
     675            </xsl:when>
     676            <!-- other types -->
     677            <xsl:otherwise>
     678              <xsl:message terminate="yes">
     679                <xsl:text>Unknown parameter type: </xsl:text>
     680                <xsl:value-of select="."/>
     681              </xsl:message>
     682            </xsl:otherwise>
     683          </xsl:choose>
    686684        </xsl:otherwise>
    687     </xsl:choose>
     685      </xsl:choose>
     686    </xsl:otherwise>
     687  </xsl:choose>
    688688</xsl:template>
    689689
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