VirtualBox

Changeset 469 in vbox


Ignore:
Timestamp:
Jan 31, 2007 3:57:59 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18067
Message:

Main/XIDL: Added support for the @mod attribute (with 'ptr' the only valud value for now) to declare attributes and method parameters as raw C/C++ pointers (which will make the corresponding methods non-scriptable in e.g. XPCOM but avoid 32/64 bit problems with passing pointers over COM).

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/defs.h

    r1 r469  
    8989#define IUnknown nsISupports
    9090
    91 #define LONG int32_t
    92 #define ULONG uint32_t
    93 #define LONG64 int64_t
    94 #define ULONG64 uint64_t
    95 #define USHORT uint16_t
    96 #define SHORT int16_t
    97 #define BOOL PRBool
     91#define BOOL    PRBool
     92#define BYTE    PRUint8
     93#define SHORT   PRInt16
     94#define USHORT  PRUint16
     95#define LONG    PRInt32
     96#define ULONG   PRUint32
     97#define LONG64  PRInt64
     98#define ULONG64 PRUint64
     99
     100#define BSTR    PRUnichar *
     101#define LPBSTR  BSTR *
     102#define OLECHAR wchar_t
     103
    98104#define FALSE PR_FALSE
    99105#define TRUE PR_TRUE
    100 #define BSTR PRUnichar*
    101 #define LPBSTR BSTR*
    102 #define OLECHAR wchar_t
    103106
    104107// makes the name of the getter interface function (n must be capitalized)
  • trunk/src/VBox/Frontends/VirtualBox/include/COMDefs.h

    r382 r469  
    9696    #define IUnknown    nsISupports
    9797
    98     #define LONG        int32_t
    99     #define ULONG       uint32_t
    100     #define LONG64      int64_t
    101     #define ULONG64     uint64_t
    102     #define USHORT      uint16_t
    103     #define SHORT       int16_t
    10498    #define BOOL        PRBool
     99    #define BYTE        PRUint8
     100    #define SHORT       PRInt16
     101    #define USHORT      PRUint16
     102    #define LONG        PRInt32
     103    #define ULONG       PRUint32
     104    #define LONG64      PRInt64
     105    #define ULONG64     PRUint64
     106
    105107    #define BSTR        PRUnichar*
    106108    #define LPBSTR      BSTR*
  • trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl

    r382 r469  
    10321032        </xsl:message>
    10331033    </xsl:if>
     1034
    10341035    <xsl:choose>
    1035         <!-- standard types -->
    1036         <xsl:when test=".='result'">HRESULT</xsl:when>
    1037         <xsl:when test=".='boolean'">BOOL</xsl:when>
    1038         <xsl:when test=".='octet'">BYTE</xsl:when>
    1039         <xsl:when test=".='short'">SHORT</xsl:when>
    1040         <xsl:when test=".='unsigned short'">USHORT</xsl:when>
    1041         <xsl:when test=".='long'">LONG</xsl:when>
    1042         <xsl:when test=".='long long'">LONG64</xsl:when>
    1043         <xsl:when test=".='unsigned long'">ULONG</xsl:when>
    1044         <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
    1045         <xsl:when test=".='char'">CHAR</xsl:when>
    1046         <xsl:when test=".='string'">CHAR *</xsl:when>
    1047         <xsl:when test=".='wchar'">OLECHAR</xsl:when>
    1048         <xsl:when test=".='wstring'">QString</xsl:when>
    1049         <!-- UUID type -->
    1050         <xsl:when test=".='uuid'">QUuid</xsl:when>
    1051         <!-- system interface types -->
    1052         <xsl:when test=".='$unknown'">CUnknown</xsl:when>
    1053         <xsl:otherwise>
    1054             <xsl:choose>
    1055                 <!-- enum types -->
    1056                 <xsl:when test="
    1057                     (ancestor::module/enum[@name=current()]) or
    1058                     (ancestor::module/if[@target=$self_target]/enum[@name=current()])
    1059                 ">
    1060                     <xsl:value-of select="concat('CEnums::',string(.))"/>
    1061                 </xsl:when>
    1062                 <!-- custom interface types -->
    1063                 <xsl:when test="
    1064                     (name(current())='enumerator' and
    1065                      ((ancestor::module/enumerator[@name=current()]) or
    1066                       (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
    1067                     ) or
    1068                     ((ancestor::module/interface[@name=current()]) or
    1069                      (ancestor::module/if[@target=$self_target]/interface[@name=current()])
    1070                     ) or
    1071                     ((ancestor::module/collection[@name=current()]) or
    1072                      (ancestor::module/if[@target=$self_target]/collection[@name=current()])
    1073                     )
    1074                 ">
    1075                     <xsl:value-of select="concat('C',substring(.,2))"/>
    1076                 </xsl:when>
    1077                 <!-- other types -->
     1036        <!-- modifiers (ignored for 'enumeration' attributes)-->
     1037        <xsl:when test="name(current())='type' and ../@mod">
     1038            <xsl:if test="../@array">
     1039                <xsl:message terminate="yes">
     1040                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1041                    <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
     1042                </xsl:message>
     1043            </xsl:if>
     1044            <xsl:choose>
     1045                <xsl:when test="../@mod='ptr'">
     1046                    <xsl:choose>
     1047                        <!-- standard types -->
     1048                        <!--xsl:when test=".='result'">??</xsl:when-->
     1049                        <xsl:when test=".='boolean'">BOOL *</xsl:when>
     1050                        <xsl:when test=".='octet'">BYTE *</xsl:when>
     1051                        <xsl:when test=".='short'">SHORT *</xsl:when>
     1052                        <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
     1053                        <xsl:when test=".='long'">LONG *</xsl:when>
     1054                        <xsl:when test=".='long long'">LONG64 *</xsl:when>
     1055                        <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
     1056                        <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
     1057                        <xsl:when test=".='char'">CHAR *</xsl:when>
     1058                        <!--<xsl:when test=".='string'">??</xsl:when-->
     1059                        <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
     1060                        <!--<xsl:when test=".='wstring'">??</xsl:when-->
     1061                        <xsl:otherwise>
     1062                            <xsl:message terminate="yes">
     1063                                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1064                                <xsl:text>attribute 'mod=</xsl:text>
     1065                                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     1066                                <xsl:text>' cannot be used with type </xsl:text>
     1067                                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     1068                            </xsl:message>
     1069                        </xsl:otherwise>
     1070                    </xsl:choose>
     1071                </xsl:when>
    10781072                <xsl:otherwise>
    10791073                    <xsl:message terminate="yes">
    1080                         <xsl:text>Unknown parameter type: </xsl:text>
    1081                         <xsl:value-of select="."/>
     1074                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1075                        <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     1076                        <xsl:text>of attibute 'mod' is invalid!</xsl:text>
    10821077                    </xsl:message>
    10831078                </xsl:otherwise>
    10841079            </xsl:choose>
     1080        </xsl:when>
     1081        <!-- no modifiers -->
     1082        <xsl:otherwise>
     1083            <xsl:choose>
     1084                <!-- standard types -->
     1085                <xsl:when test=".='result'">HRESULT</xsl:when>
     1086                <xsl:when test=".='boolean'">BOOL</xsl:when>
     1087                <xsl:when test=".='octet'">BYTE</xsl:when>
     1088                <xsl:when test=".='short'">SHORT</xsl:when>
     1089                <xsl:when test=".='unsigned short'">USHORT</xsl:when>
     1090                <xsl:when test=".='long'">LONG</xsl:when>
     1091                <xsl:when test=".='long long'">LONG64</xsl:when>
     1092                <xsl:when test=".='unsigned long'">ULONG</xsl:when>
     1093                <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
     1094                <xsl:when test=".='char'">CHAR</xsl:when>
     1095                <xsl:when test=".='string'">CHAR *</xsl:when>
     1096                <xsl:when test=".='wchar'">OLECHAR</xsl:when>
     1097                <xsl:when test=".='wstring'">QString</xsl:when>
     1098                <!-- UUID type -->
     1099                <xsl:when test=".='uuid'">QUuid</xsl:when>
     1100                <!-- system interface types -->
     1101                <xsl:when test=".='$unknown'">CUnknown</xsl:when>
     1102                <xsl:otherwise>
     1103                    <xsl:choose>
     1104                        <!-- enum types -->
     1105                        <xsl:when test="
     1106                            (ancestor::module/enum[@name=current()]) or
     1107                            (ancestor::module/if[@target=$self_target]/enum[@name=current()])
     1108                        ">
     1109                            <xsl:value-of select="concat('CEnums::',string(.))"/>
     1110                        </xsl:when>
     1111                        <!-- custom interface types -->
     1112                        <xsl:when test="
     1113                            (name(current())='enumerator' and
     1114                             ((ancestor::module/enumerator[@name=current()]) or
     1115                              (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
     1116                            ) or
     1117                            ((ancestor::module/interface[@name=current()]) or
     1118                             (ancestor::module/if[@target=$self_target]/interface[@name=current()])
     1119                            ) or
     1120                            ((ancestor::module/collection[@name=current()]) or
     1121                             (ancestor::module/if[@target=$self_target]/collection[@name=current()])
     1122                            )
     1123                        ">
     1124                            <xsl:value-of select="concat('C',substring(.,2))"/>
     1125                        </xsl:when>
     1126                        <!-- other types -->
     1127                        <xsl:otherwise>
     1128                            <xsl:message terminate="yes">
     1129                                <xsl:text>Unknown parameter type: </xsl:text>
     1130                                <xsl:value-of select="."/>
     1131                            </xsl:message>
     1132                        </xsl:otherwise>
     1133                    </xsl:choose>
     1134                </xsl:otherwise>
     1135            </xsl:choose>
    10851136        </xsl:otherwise>
    10861137    </xsl:choose>
     
    10891140
    10901141<!--
    1091  *  generates a null initializer for all fundamental types (such as bool or long)
     1142 *  generates a null initializer for all scalar types (such as bool or long)
    10921143 *  and enum types in the form of ' = <null_initializer>', or nothing for other
    10931144 *  types.
     
    11011152
    11021153    <xsl:choose>
    1103         <!-- standard types that need a zero initializer -->
    1104         <xsl:when test=".='result'"> = S_OK</xsl:when>
    1105         <xsl:when test=".='boolean'"> = FALSE</xsl:when>
    1106         <xsl:when test=".='octet'"> = 0</xsl:when>
    1107         <xsl:when test=".='short'"> = 0</xsl:when>
    1108         <xsl:when test=".='unsigned short'"> = 0</xsl:when>
    1109         <xsl:when test=".='long'"> = 0</xsl:when>
    1110         <xsl:when test=".='long long'"> = 0</xsl:when>
    1111         <xsl:when test=".='unsigned long'"> = 0</xsl:when>
    1112         <xsl:when test=".='unsigned long long'"> = 0</xsl:when>
    1113         <xsl:when test=".='char'"> = 0</xsl:when>
    1114         <xsl:when test=".='string'"> = NULL</xsl:when>
    1115         <xsl:when test=".='wchar'"> = 0</xsl:when>
     1154        <!-- modifiers (ignored for 'enumeration' attributes)-->
     1155        <xsl:when test="name(current())='type' and ../@mod">
     1156            <xsl:if test="../@array">
     1157                <xsl:message terminate="yes">
     1158                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1159                    <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
     1160                </xsl:message>
     1161            </xsl:if>
     1162            <xsl:choose>
     1163                <xsl:when test="../@mod='ptr'">
     1164                    <xsl:choose>
     1165                        <!-- standard types -->
     1166                        <!--xsl:when test=".='result'">??</xsl:when-->
     1167                        <xsl:when test=".='boolean'"> = NULL</xsl:when>
     1168                        <xsl:when test=".='octet'"> = NULL</xsl:when>
     1169                        <xsl:when test=".='short'"> = NULL</xsl:when>
     1170                        <xsl:when test=".='unsigned short'"> = NULL</xsl:when>
     1171                        <xsl:when test=".='long'"> = NULL</xsl:when>
     1172                        <xsl:when test=".='long long'"> = NULL</xsl:when>
     1173                        <xsl:when test=".='unsigned long'"> = NULL</xsl:when>
     1174                        <xsl:when test=".='unsigned long long'"> = NULL</xsl:when>
     1175                        <xsl:when test=".='char'"> = NULL</xsl:when>
     1176                        <!--<xsl:when test=".='string'">??</xsl:when-->
     1177                        <xsl:when test=".='wchar'"> = NULL</xsl:when>
     1178                        <!--<xsl:when test=".='wstring'">??</xsl:when-->
     1179                        <xsl:otherwise>
     1180                            <xsl:message terminate="yes">
     1181                                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1182                                <xsl:text>attribute 'mod=</xsl:text>
     1183                                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     1184                                <xsl:text>' cannot be used with type </xsl:text>
     1185                                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     1186                            </xsl:message>
     1187                        </xsl:otherwise>
     1188                    </xsl:choose>
     1189                </xsl:when>
     1190                <xsl:otherwise>
     1191                    <xsl:message terminate="yes">
     1192                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     1193                        <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     1194                        <xsl:text>of attibute 'mod' is invalid!</xsl:text>
     1195                    </xsl:message>
     1196                </xsl:otherwise>
     1197            </xsl:choose>
     1198        </xsl:when>
     1199        <!-- no modifiers -->
    11161200        <xsl:otherwise>
    11171201            <xsl:choose>
    1118                 <!-- enum types initialized with 0 -->
    1119                 <xsl:when test="
    1120                     (ancestor::module/enum[@name=current()]) or
    1121                     (ancestor::module/if[@target=$self_target]/enum[@name=current()])
    1122                 ">
    1123                     <xsl:value-of select="concat(' = (CEnums::',string(.),') 0')"/>
    1124                 </xsl:when>
     1202                <!-- standard types that need a zero initializer -->
     1203                <xsl:when test=".='result'"> = S_OK</xsl:when>
     1204                <xsl:when test=".='boolean'"> = FALSE</xsl:when>
     1205                <xsl:when test=".='octet'"> = 0</xsl:when>
     1206                <xsl:when test=".='short'"> = 0</xsl:when>
     1207                <xsl:when test=".='unsigned short'"> = 0</xsl:when>
     1208                <xsl:when test=".='long'"> = 0</xsl:when>
     1209                <xsl:when test=".='long long'"> = 0</xsl:when>
     1210                <xsl:when test=".='unsigned long'"> = 0</xsl:when>
     1211                <xsl:when test=".='unsigned long long'"> = 0</xsl:when>
     1212                <xsl:when test=".='char'"> = 0</xsl:when>
     1213                <xsl:when test=".='string'"> = NULL</xsl:when>
     1214                <xsl:when test=".='wchar'"> = 0</xsl:when>
     1215                <xsl:otherwise>
     1216                    <xsl:choose>
     1217                        <!-- enum types initialized with 0 -->
     1218                        <xsl:when test="
     1219                            (ancestor::module/enum[@name=current()]) or
     1220                            (ancestor::module/if[@target=$self_target]/enum[@name=current()])
     1221                        ">
     1222                            <xsl:value-of select="concat(' = (CEnums::',string(.),') 0')"/>
     1223                        </xsl:when>
     1224                    </xsl:choose>
     1225                </xsl:otherwise>
    11251226            </xsl:choose>
    11261227        </xsl:otherwise>
  • trunk/src/VBox/Main/idl/doxygen.xsl

    r1 r469  
    190190    <xsl:apply-templates select="text() | *[not(self::note or self::see)]"/>
    191191    <xsl:apply-templates select="note"/>
     192    <xsl:if test="../@mod='ptr'">
     193        <xsl:text>
     194
     195@warning This attribute is non-scriptable. In particluar, this also means that an
     196attempt to get or set it from a process other than the process that has created and
     197owns the object will most likely fail or crash your application.
     198</xsl:text>
     199    </xsl:if>
    192200    <xsl:apply-templates select="see"/>
    193201    <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     
    205213    <xsl:apply-templates select="note"/>
    206214    <xsl:apply-templates select="../param/desc/note"/>
     215    <xsl:if test="../param/@mod='ptr'">
     216        <xsl:text>
     217       
     218@warning This method is non-scriptable. In particluar, this also means that an
     219attempt to call it from a process other than the process that has created and
     220owns the object will most likely fail or crash your application.
     221</xsl:text>
     222    </xsl:if>
    207223    <xsl:apply-templates select="see"/>
    208224    <xsl:text>&#x0A;*/&#x0A;</xsl:text>
     
    551567
    552568    <xsl:choose>
    553         <!-- standard types -->
    554         <xsl:when test=".='result'">result</xsl:when>
    555         <xsl:when test=".='boolean'">boolean</xsl:when>
    556         <xsl:when test=".='octet'">octet</xsl:when>
    557         <xsl:when test=".='short'">short</xsl:when>
    558         <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
    559         <xsl:when test=".='long'">long</xsl:when>
    560         <xsl:when test=".='long long'">long long</xsl:when>
    561         <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
    562         <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
    563         <xsl:when test=".='char'">char</xsl:when>
    564         <xsl:when test=".='wchar'">wchar</xsl:when>
    565         <xsl:when test=".='string'">string</xsl:when>
    566         <xsl:when test=".='wstring'">wstring</xsl:when>
    567         <!-- UUID type -->
    568         <xsl:when test=".='uuid'">uuid</xsl:when>
    569         <!-- system interface types -->
    570         <xsl:when test=".='$unknown'">$unknown</xsl:when>
     569        <!-- modifiers (ignored for 'enumeration' attributes)-->
     570        <xsl:when test="name(current())='type' and ../@mod">
     571            <xsl:if test="../@array">
     572                <xsl:message terminate="yes">
     573                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     574                    <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
     575                </xsl:message>
     576            </xsl:if>
     577            <xsl:choose>
     578                <xsl:when test="../@mod='ptr'">
     579                    <xsl:choose>
     580                        <!-- standard types -->
     581                        <!--xsl:when test=".='result'">??</xsl:when-->
     582                        <xsl:when test=".='boolean'">booeanPtr</xsl:when>
     583                        <xsl:when test=".='octet'">octetPtr</xsl:when>
     584                        <xsl:when test=".='short'">shortPtr</xsl:when>
     585                        <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
     586                        <xsl:when test=".='long'">longPtr</xsl:when>
     587                        <xsl:when test=".='long long'">llongPtr</xsl:when>
     588                        <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
     589                        <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
     590                        <xsl:when test=".='char'">charPtr</xsl:when>
     591                        <!--xsl:when test=".='string'">??</xsl:when-->
     592                        <xsl:when test=".='wchar'">wcharPtr</xsl:when>
     593                        <!--xsl:when test=".='wstring'">??</xsl:when-->
     594                        <xsl:otherwise>
     595                            <xsl:message terminate="yes">
     596                                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     597                                <xsl:text>attribute 'mod=</xsl:text>
     598                                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     599                                <xsl:text>' cannot be used with type </xsl:text>
     600                                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     601                            </xsl:message>
     602                        </xsl:otherwise>
     603                    </xsl:choose>
     604                </xsl:when>
     605                <xsl:otherwise>
     606                    <xsl:message terminate="yes">
     607                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     608                        <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     609                        <xsl:text>of attibute 'mod' is invalid!</xsl:text>
     610                    </xsl:message>
     611                </xsl:otherwise>
     612            </xsl:choose>
     613        </xsl:when>
     614        <!-- no modifiers -->
    571615        <xsl:otherwise>
    572616            <xsl:choose>
    573                 <!-- enum types -->
    574                 <xsl:when test="
    575                     (ancestor::module/enum[@name=current()]) or
    576                     (ancestor::module/if[@target=$self_target]/enum[@name=current()])
    577                 ">
    578                     <xsl:value-of select="."/>
    579                 </xsl:when>
    580                 <!-- custom interface types -->
    581                 <xsl:when test="
    582                     (name(current())='enumerator' and
    583                      ((ancestor::module/enumerator[@name=current()]) or
    584                       (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
    585                     ) or
    586                     ((ancestor::module/interface[@name=current()]) or
    587                      (ancestor::module/if[@target=$self_target]/interface[@name=current()])
    588                     ) or
    589                     ((ancestor::module/collection[@name=current()]) or
    590                      (ancestor::module/if[@target=$self_target]/collection[@name=current()])
    591                     )
    592                 ">
    593                     <xsl:value-of select="."/>
    594                 </xsl:when>
    595                 <!-- other types -->
     617                <!-- standard types -->
     618                <xsl:when test=".='result'">result</xsl:when>
     619                <xsl:when test=".='boolean'">boolean</xsl:when>
     620                <xsl:when test=".='octet'">octet</xsl:when>
     621                <xsl:when test=".='short'">short</xsl:when>
     622                <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
     623                <xsl:when test=".='long'">long</xsl:when>
     624                <xsl:when test=".='long long'">long long</xsl:when>
     625                <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
     626                <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
     627                <xsl:when test=".='char'">char</xsl:when>
     628                <xsl:when test=".='wchar'">wchar</xsl:when>
     629                <xsl:when test=".='string'">string</xsl:when>
     630                <xsl:when test=".='wstring'">wstring</xsl:when>
     631                <!-- UUID type -->
     632                <xsl:when test=".='uuid'">uuid</xsl:when>
     633                <!-- system interface types -->
     634                <xsl:when test=".='$unknown'">$unknown</xsl:when>
    596635                <xsl:otherwise>
    597                     <xsl:message terminate="yes">
    598                         <xsl:text>Unknown parameter type: </xsl:text>
    599                         <xsl:value-of select="."/>
    600                     </xsl:message>
     636                    <xsl:choose>
     637                        <!-- enum types -->
     638                        <xsl:when test="
     639                            (ancestor::module/enum[@name=current()]) or
     640                            (ancestor::module/if[@target=$self_target]/enum[@name=current()])
     641                        ">
     642                            <xsl:value-of select="."/>
     643                        </xsl:when>
     644                        <!-- custom interface types -->
     645                        <xsl:when test="
     646                            (name(current())='enumerator' and
     647                             ((ancestor::module/enumerator[@name=current()]) or
     648                              (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
     649                            ) or
     650                            ((ancestor::module/interface[@name=current()]) or
     651                             (ancestor::module/if[@target=$self_target]/interface[@name=current()])
     652                            ) or
     653                            ((ancestor::module/collection[@name=current()]) or
     654                             (ancestor::module/if[@target=$self_target]/collection[@name=current()])
     655                            )
     656                        ">
     657                            <xsl:value-of select="."/>
     658                        </xsl:when>
     659                        <!-- other types -->
     660                        <xsl:otherwise>
     661                            <xsl:message terminate="yes">
     662                                <xsl:text>Unknown parameter type: </xsl:text>
     663                                <xsl:value-of select="."/>
     664                            </xsl:message>
     665                        </xsl:otherwise>
     666                    </xsl:choose>
    601667                </xsl:otherwise>
    602668            </xsl:choose>
  • trunk/src/VBox/Main/idl/midl.xsl

    r1 r469  
    459459
    460460    <xsl:choose>
    461         <!-- standard types -->
    462         <xsl:when test=".='result'">HRESULT</xsl:when>
    463         <xsl:when test=".='boolean'">BOOL</xsl:when>
    464         <xsl:when test=".='octet'">BYTE</xsl:when>
    465         <xsl:when test=".='short'">SHORT</xsl:when>
    466         <xsl:when test=".='unsigned short'">USHORT</xsl:when>
    467         <xsl:when test=".='long'">LONG</xsl:when>
    468         <xsl:when test=".='long long'">LONG64</xsl:when>
    469         <xsl:when test=".='unsigned long'">ULONG</xsl:when>
    470         <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
    471         <xsl:when test=".='char'">CHAR</xsl:when>
    472         <xsl:when test=".='string'">CHAR *</xsl:when>
    473         <xsl:when test=".='wchar'">OLECHAR</xsl:when>
    474         <xsl:when test=".='wstring'">BSTR</xsl:when>
    475         <!-- UUID type -->
    476         <xsl:when test=".='uuid'">GUID</xsl:when>
    477         <!-- system interface types -->
    478         <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
     461        <!-- modifiers (ignored for 'enumeration' attributes)-->
     462        <xsl:when test="name(current())='type' and ../@mod">
     463            <xsl:if test="../@array">
     464                <xsl:message terminate="yes">
     465                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     466                    <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
     467                </xsl:message>
     468            </xsl:if>
     469            <xsl:choose>
     470                <xsl:when test="../@mod='ptr'">
     471                    <xsl:choose>
     472                        <!-- standard types -->
     473                        <!--xsl:when test=".='result'">??</xsl:when-->
     474                        <xsl:when test=".='boolean'">BOOL *</xsl:when>
     475                        <xsl:when test=".='octet'">BYTE *</xsl:when>
     476                        <xsl:when test=".='short'">SHORT *</xsl:when>
     477                        <xsl:when test=".='unsigned short'">USHORT *</xsl:when>
     478                        <xsl:when test=".='long'">LONG *</xsl:when>
     479                        <xsl:when test=".='long long'">LONG64 *</xsl:when>
     480                        <xsl:when test=".='unsigned long'">ULONG *</xsl:when>
     481                        <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when>
     482                        <xsl:when test=".='char'">CHAR *</xsl:when>
     483                        <!--xsl:when test=".='string'">??</xsl:when-->
     484                        <xsl:when test=".='wchar'">OLECHAR *</xsl:when>
     485                        <!--xsl:when test=".='wstring'">??</xsl:when-->
     486                        <xsl:otherwise>
     487                            <xsl:message terminate="yes">
     488                                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     489                                <xsl:text>attribute 'mod=</xsl:text>
     490                                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     491                                <xsl:text>' cannot be used with type </xsl:text>
     492                                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
     493                            </xsl:message>
     494                        </xsl:otherwise>
     495                    </xsl:choose>
     496                </xsl:when>
     497                <xsl:otherwise>
     498                    <xsl:message terminate="yes">
     499                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     500                        <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     501                        <xsl:text>of attibute 'mod' is invalid!</xsl:text>
     502                    </xsl:message>
     503                </xsl:otherwise>
     504            </xsl:choose>
     505        </xsl:when>
     506        <!-- no modifiers -->
    479507        <xsl:otherwise>
    480508            <xsl:choose>
    481                 <!-- enum types -->
    482                 <xsl:when test="
    483                     (ancestor::module/enum[@name=current()]) or
    484                     (ancestor::module/if[@target=$self_target]/enum[@name=current()])
    485                 ">
    486                     <xsl:value-of select="."/>
    487                 </xsl:when>
    488                 <!-- custom interface types -->
    489                 <xsl:when test="
    490                     (name(current())='enumerator' and
    491                      ((ancestor::module/enumerator[@name=current()]) or
    492                       (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
    493                     ) or
    494                     ((ancestor::module/interface[@name=current()]) or
    495                      (ancestor::module/if[@target=$self_target]/interface[@name=current()])
    496                     ) or
    497                     ((ancestor::module/collection[@name=current()]) or
    498                      (ancestor::module/if[@target=$self_target]/collection[@name=current()])
    499                     )
    500                 ">
    501                     <xsl:value-of select="."/><xsl:text> *</xsl:text>
    502                 </xsl:when>
    503                 <!-- other types -->
     509                <!-- standard types -->
     510                <xsl:when test=".='result'">HRESULT</xsl:when>
     511                <xsl:when test=".='boolean'">BOOL</xsl:when>
     512                <xsl:when test=".='octet'">BYTE</xsl:when>
     513                <xsl:when test=".='short'">SHORT</xsl:when>
     514                <xsl:when test=".='unsigned short'">USHORT</xsl:when>
     515                <xsl:when test=".='long'">LONG</xsl:when>
     516                <xsl:when test=".='long long'">LONG64</xsl:when>
     517                <xsl:when test=".='unsigned long'">ULONG</xsl:when>
     518                <xsl:when test=".='unsigned long long'">ULONG64</xsl:when>
     519                <xsl:when test=".='char'">CHAR</xsl:when>
     520                <xsl:when test=".='string'">CHAR *</xsl:when>
     521                <xsl:when test=".='wchar'">OLECHAR</xsl:when>
     522                <xsl:when test=".='wstring'">BSTR</xsl:when>
     523                <!-- UUID type -->
     524                <xsl:when test=".='uuid'">GUID</xsl:when>
     525                <!-- system interface types -->
     526                <xsl:when test=".='$unknown'">IUnknown *</xsl:when>
    504527                <xsl:otherwise>
    505                     <xsl:message terminate="yes">
    506                         <xsl:text>Unknown parameter type: </xsl:text>
    507                         <xsl:value-of select="."/>
    508                     </xsl:message>
     528                    <xsl:choose>
     529                        <!-- enum types -->
     530                        <xsl:when test="
     531                            (ancestor::module/enum[@name=current()]) or
     532                            (ancestor::module/if[@target=$self_target]/enum[@name=current()])
     533                        ">
     534                            <xsl:value-of select="."/>
     535                        </xsl:when>
     536                        <!-- custom interface types -->
     537                        <xsl:when test="
     538                            (name(current())='enumerator' and
     539                             ((ancestor::module/enumerator[@name=current()]) or
     540                              (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
     541                            ) or
     542                            ((ancestor::module/interface[@name=current()]) or
     543                             (ancestor::module/if[@target=$self_target]/interface[@name=current()])
     544                            ) or
     545                            ((ancestor::module/collection[@name=current()]) or
     546                             (ancestor::module/if[@target=$self_target]/collection[@name=current()])
     547                            )
     548                        ">
     549                            <xsl:value-of select="."/><xsl:text> *</xsl:text>
     550                        </xsl:when>
     551                        <!-- other types -->
     552                        <xsl:otherwise>
     553                            <xsl:message terminate="yes">
     554                                <xsl:text>Unknown parameter type: </xsl:text>
     555                                <xsl:value-of select="."/>
     556                            </xsl:message>
     557                        </xsl:otherwise>
     558                    </xsl:choose>
    509559                </xsl:otherwise>
    510560            </xsl:choose>
  • trunk/src/VBox/Main/idl/xpidl.xsl

    r1 r469  
    8080 *  using XPCOM IDL (XPIDL) syntax.
    8181 */
    82     </xsl:text>
    83     <xsl:text>&#x0A;</xsl:text>
    84     <xsl:text>#include "nsISupports.idl"&#x0A;&#x0A;</xsl:text>
    85     <xsl:text>#include "nsIException.idl"&#x0A;&#x0A;</xsl:text>
     82
     83#include "nsISupports.idl"
     84#include "nsIException.idl"
     85</xsl:text>
     86    <!-- native typedefs for the 'mod="ptr"' attribute -->
     87    <xsl:text>
     88[ptr] native booeanPtr  (PRBool);
     89[ptr] native octetPtr   (PRUint8);
     90[ptr] native shortPtr   (PRInt16);
     91[ptr] native ushortPtr  (PRUint16);
     92[ptr] native longPtr    (PRInt32);
     93[ptr] native llongPtr   (PRInt64);
     94[ptr] native ulongPtr   (PRUint32);
     95[ptr] native ullongPtr  (PRUint64);
     96<!-- charPtr is already defined in nsrootidl.idl -->
     97<!-- [ptr] native charPtr    (char) -->
     98[ptr] native stringPtr  (string);
     99[ptr] native wcharPtr   (wchar);
     100[ptr] native wstringPtr (wstring);
     101
     102</xsl:text>   
    86103    <xsl:apply-templates/>
    87104</xsl:template>
     
    199216<xsl:template match="interface//attribute | collection//attribute">
    200217    <xsl:apply-templates select="@if" mode="begin"/>
     218    <xsl:if test="@mod='ptr'">
     219        <!-- attributes using native types must be non-scriptable -->
     220        <xsl:text>    [noscript]&#x0A;</xsl:text>
     221    </xsl:if>
    201222    <xsl:text>    </xsl:text>
    202223    <xsl:if test="@readonly='yes'">
     
    217238<xsl:template match="interface//method | collection//method">
    218239    <xsl:apply-templates select="@if" mode="begin"/>
     240    <xsl:if test="param/@mod='ptr'">
     241        <!-- methods using native types must be non-scriptable -->
     242        <xsl:text>    [noscript]&#x0A;</xsl:text>
     243    </xsl:if>
    219244    <xsl:text>    void </xsl:text>
    220245    <xsl:value-of select="@name"/>
     
    439464
    440465    <xsl:choose>
    441         <!-- standard types -->
    442         <xsl:when test=".='result'">nsresult</xsl:when>
    443         <xsl:when test=".='boolean'">boolean</xsl:when>
    444         <xsl:when test=".='octet'">octet</xsl:when>
    445         <xsl:when test=".='short'">short</xsl:when>
    446         <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
    447         <xsl:when test=".='long'">long</xsl:when>
    448         <xsl:when test=".='long long'">long long</xsl:when>
    449         <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
    450         <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
    451         <xsl:when test=".='char'">char</xsl:when>
    452         <xsl:when test=".='wchar'">wchar</xsl:when>
    453         <xsl:when test=".='string'">string</xsl:when>
    454         <xsl:when test=".='wstring'">wstring</xsl:when>
    455         <!-- UUID type -->
    456         <xsl:when test=".='uuid'">
     466        <!-- modifiers (ignored for 'enumeration' attributes)-->
     467        <xsl:when test="name(current())='type' and ../@mod">
     468            <xsl:if test="../@array">
     469                <xsl:message terminate="yes">
     470                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     471                    <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>
     472                </xsl:message>
     473            </xsl:if>
    457474            <xsl:choose>
    458                 <xsl:when test="name(..)='attribute'">
     475                <xsl:when test="../@mod='ptr'">
    459476                    <xsl:choose>
    460                         <xsl:when test="../@readonly='yes'">
    461                             <xsl:text>nsIDPtr</xsl:text>
    462                         </xsl:when>
     477                        <!-- standard types -->
     478                        <!--xsl:when test=".='result'">??</xsl:when-->
     479                        <xsl:when test=".='boolean'">booeanPtr</xsl:when>
     480                        <xsl:when test=".='octet'">octetPtr</xsl:when>
     481                        <xsl:when test=".='short'">shortPtr</xsl:when>
     482                        <xsl:when test=".='unsigned short'">ushortPtr</xsl:when>
     483                        <xsl:when test=".='long'">longPtr</xsl:when>
     484                        <xsl:when test=".='long long'">llongPtr</xsl:when>
     485                        <xsl:when test=".='unsigned long'">ulongPtr</xsl:when>
     486                        <xsl:when test=".='unsigned long long'">ullongPtr</xsl:when>
     487                        <xsl:when test=".='char'">charPtr</xsl:when>
     488                        <!--xsl:when test=".='string'">??</xsl:when-->
     489                        <xsl:when test=".='wchar'">wcharPtr</xsl:when>
     490                        <!--xsl:when test=".='wstring'">??</xsl:when-->
    463491                        <xsl:otherwise>
    464492                            <xsl:message terminate="yes">
    465                                 <xsl:value-of select="../@name"/>
    466                                 <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
     493                                <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     494                                <xsl:text>attribute 'mod=</xsl:text>
     495                                <xsl:value-of select="concat('&quot;',../@mod,'&quot;')"/>
     496                                <xsl:text>' cannot be used with type </xsl:text>
     497                                <xsl:value-of select="concat('&quot;',current(),'&quot;!')"/>
    467498                            </xsl:message>
    468499                        </xsl:otherwise>
    469500                    </xsl:choose>
    470501                </xsl:when>
    471                 <xsl:when test="name(..)='param'">
     502                <xsl:otherwise>
     503                    <xsl:message terminate="yes">
     504                        <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>
     505                        <xsl:value-of select="concat('value &quot;',../@mod,'&quot; ')"/>
     506                        <xsl:text>of attibute 'mod' is invalid!</xsl:text>
     507                    </xsl:message>
     508                </xsl:otherwise>
     509            </xsl:choose>
     510        </xsl:when>
     511        <!-- no modifiers -->
     512        <xsl:otherwise>
     513            <xsl:choose>
     514                <!-- standard types -->
     515                <xsl:when test=".='result'">nsresult</xsl:when>
     516                <xsl:when test=".='boolean'">boolean</xsl:when>
     517                <xsl:when test=".='octet'">octet</xsl:when>
     518                <xsl:when test=".='short'">short</xsl:when>
     519                <xsl:when test=".='unsigned short'">unsigned short</xsl:when>
     520                <xsl:when test=".='long'">long</xsl:when>
     521                <xsl:when test=".='long long'">long long</xsl:when>
     522                <xsl:when test=".='unsigned long'">unsigned long</xsl:when>
     523                <xsl:when test=".='unsigned long long'">unsigned long long</xsl:when>
     524                <xsl:when test=".='char'">char</xsl:when>
     525                <xsl:when test=".='wchar'">wchar</xsl:when>
     526                <xsl:when test=".='string'">string</xsl:when>
     527                <xsl:when test=".='wstring'">wstring</xsl:when>
     528                <!-- UUID type -->
     529                <xsl:when test=".='uuid'">
    472530                    <xsl:choose>
    473                         <xsl:when test="../@dir='in'">
    474                             <xsl:text>nsIDRef</xsl:text>
     531                        <xsl:when test="name(..)='attribute'">
     532                            <xsl:choose>
     533                                <xsl:when test="../@readonly='yes'">
     534                                    <xsl:text>nsIDPtr</xsl:text>
     535                                </xsl:when>
     536                                <xsl:otherwise>
     537                                    <xsl:message terminate="yes">
     538                                        <xsl:value-of select="../@name"/>
     539                                        <xsl:text>: Non-readonly uuid attributes are not supported!</xsl:text>
     540                                    </xsl:message>
     541                                </xsl:otherwise>
     542                            </xsl:choose>
    475543                        </xsl:when>
     544                        <xsl:when test="name(..)='param'">
     545                            <xsl:choose>
     546                                <xsl:when test="../@dir='in'">
     547                                    <xsl:text>nsIDRef</xsl:text>
     548                                </xsl:when>
     549                                <xsl:otherwise>
     550                                    <xsl:text>nsIDPtr</xsl:text>
     551                                </xsl:otherwise>
     552                            </xsl:choose>
     553                        </xsl:when>
     554                    </xsl:choose>
     555                </xsl:when>
     556                <!-- system interface types -->
     557                <xsl:when test=".='$unknown'">nsISupports</xsl:when>
     558                <xsl:otherwise>
     559                    <xsl:choose>
     560                        <!-- enum types -->
     561                        <xsl:when test="
     562                            (ancestor::module/enum[@name=current()]) or
     563                            (ancestor::module/if[@target=$self_target]/enum[@name=current()])
     564                        ">
     565                            <xsl:text>PRUint32</xsl:text>
     566                        </xsl:when>
     567                        <!-- custom interface types -->
     568                        <xsl:when test="
     569                            (name(current())='enumerator' and
     570                             ((ancestor::module/enumerator[@name=current()]) or
     571                              (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
     572                            ) or
     573                            ((ancestor::module/interface[@name=current()]) or
     574                             (ancestor::module/if[@target=$self_target]/interface[@name=current()])
     575                            ) or
     576                            ((ancestor::module/collection[@name=current()]) or
     577                             (ancestor::module/if[@target=$self_target]/collection[@name=current()])
     578                            )
     579                        ">
     580                            <xsl:value-of select="."/>
     581                        </xsl:when>
     582                        <!-- other types -->
    476583                        <xsl:otherwise>
    477                             <xsl:text>nsIDPtr</xsl:text>
     584                            <xsl:message terminate="yes">
     585                                <xsl:text>Unknown parameter type: </xsl:text>
     586                                <xsl:value-of select="."/>
     587                            </xsl:message>
    478588                        </xsl:otherwise>
    479589                    </xsl:choose>
    480                 </xsl:when>
    481             </xsl:choose>
    482         </xsl:when>
    483         <!-- system interface types -->
    484         <xsl:when test=".='$unknown'">nsISupports</xsl:when>
    485         <xsl:otherwise>
    486             <xsl:choose>
    487                 <!-- enum types -->
    488                 <xsl:when test="
    489                     (ancestor::module/enum[@name=current()]) or
    490                     (ancestor::module/if[@target=$self_target]/enum[@name=current()])
    491                 ">
    492                     <xsl:text>PRUint32</xsl:text>
    493                 </xsl:when>
    494                 <!-- custom interface types -->
    495                 <xsl:when test="
    496                     (name(current())='enumerator' and
    497                      ((ancestor::module/enumerator[@name=current()]) or
    498                       (ancestor::module/if[@target=$self_target]/enumerator[@name=current()]))
    499                     ) or
    500                     ((ancestor::module/interface[@name=current()]) or
    501                      (ancestor::module/if[@target=$self_target]/interface[@name=current()])
    502                     ) or
    503                     ((ancestor::module/collection[@name=current()]) or
    504                      (ancestor::module/if[@target=$self_target]/collection[@name=current()])
    505                     )
    506                 ">
    507                     <xsl:value-of select="."/>
    508                 </xsl:when>
    509                 <!-- other types -->
    510                 <xsl:otherwise>
    511                     <xsl:message terminate="yes">
    512                         <xsl:text>Unknown parameter type: </xsl:text>
    513                         <xsl:value-of select="."/>
    514                     </xsl:message>
    515590                </xsl:otherwise>
    516591            </xsl:choose>
Note: See TracChangeset for help on using the changeset viewer.

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