1 module org.eclipse.swt.internal.mozilla.nsStringAPI; 2 3 import java.lang.all; 4 5 import org.eclipse.swt.internal.mozilla.Common; 6 7 extern (System): 8 9 /****************************************************************************** 10 11 ******************************************************************************/ 12 13 enum 14 { 15 NS_STRING_CONTAINER_INIT_DEPEND = 2, 16 NS_STRING_CONTAINER_INIT_ADOPT = 4, 17 NS_STRING_CONTAINER_INIT_SUBSTRING = 8, 18 } 19 20 nsresult NS_StringContainerInit ( nsStringContainer *aContainer ); 21 nsresult NS_StringContainerInit2( nsStringContainer *aContainer, in PRUnichar *aData, PRUint32 22 aDataLength, PRUint32 aFlags ); 23 void NS_StringContainerFinish(nsStringContainer *aContainer); 24 PRUint32 NS_StringGetData(nsAString *aStr, PRUnichar **aData, PRBool *aTerminated); 25 PRUint32 NS_StringGetMutableData(nsAString *aStr, PRUint32 aDataLength, PRUnichar **aData); 26 PRUnichar * NS_StringCloneData(nsAString *aStr); 27 nsresult NS_StringSetData(nsAString *aStr, in PRUnichar *aData, PRUint32 aDataLength); 28 nsresult NS_StringSetDataRange( nsAString *aStr, PRUint32 aCutOffset, PRUint32 aCutLength, 29 in PRUnichar *aData, PRUint32 aDataLength ); 30 nsresult NS_StringCopy(nsAString *aDestStr, nsAString *aSrcStr); 31 32 /****************************************************************************** 33 34 ******************************************************************************/ 35 36 enum 37 { 38 NS_CSTRING_CONTAINER_INIT_DEPEND = 2, 39 NS_CSTRING_CONTAINER_INIT_ADOPT = 4, 40 NS_CSTRING_CONTAINER_INIT_SUBSTRING = 8, 41 } 42 43 nsresult NS_CStringContainerInit( nsCStringContainer *aContainer ); 44 nsresult NS_CStringContainerInit2( nsCStringContainer *aContainer, in char *aData, PRUint32 aDataLength, PRUint32 aFlags ); 45 void NS_CStringContainerFinish( nsCStringContainer *aContainer ); 46 PRUint32 NS_CStringGetData( nsACString *aStr, char **aData, PRBool *aTerminated ); 47 PRUint32 NS_CStringGetMutableData( nsACString *aStr, PRUint32 aDataLength, char **aData ); 48 char * NS_CStringCloneData( nsACString *aStr); 49 nsresult NS_CStringSetData( nsACString *aStr, in char *aData, PRUint32 aDataLength ); 50 nsresult NS_CStringSetDataRange( nsACString *aStr, PRUint32 aCutOffset, 51 PRUint32 aCutLength, in char *aData, PRUint32 aDataLength ); 52 nsresult NS_CStringCopy( nsACString *aDestStr, nsACString *aSrcStr ); 53 54 /****************************************************************************** 55 56 ******************************************************************************/ 57 58 enum nsCStringEncoding 59 { 60 NS_CSTRING_ENCODING_ASCII, 61 NS_CSTRING_ENCODING_UTF8, 62 NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, 63 } 64 65 nsresult NS_CStringToUTF16( nsACString *aSource, int aSrcEncoding, nsAString *aDest ); 66 nsresult NS_UTF16ToCString( nsAString *aSource, int aDestEncoding, nsACString *aDest ); 67 68 /****************************************************************************** 69 70 ******************************************************************************/ 71 72 alias nsAString nsAString_external; 73 alias nsACString nsACString_external; 74 75 //alias nsAString nsEmbedString; 76 //alias nsACString nsEmbedCString; 77 78 struct nsAString 79 { 80 81 static nsAString opCall(String16 s) 82 { 83 nsAString result; 84 NS_StringSetData(&result, cast(PRUnichar*)s, uint.max); 85 return result; 86 } 87 88 static wchar[] toString16( nsAString* str ) 89 { 90 wchar* buffer = null; 91 PRBool terminated; 92 uint len = NS_StringGetData(str, &buffer, &terminated); 93 return buffer[0 .. len].dup; 94 } 95 96 static String toString( nsAString* str ) 97 { 98 return String_valueOf( nsAString.toString16( str ) ); 99 } 100 101 private: 102 void *v; 103 } 104 105 struct nsACString 106 { 107 /+ 108 static nsACString opCall(char[] s) 109 { 110 nsACString result; 111 NS_CStringSetData(&result, cast(char*)s, uint.max); 112 return result; 113 } 114 +/ 115 private: 116 void *v; 117 } 118 119 /****************************************************************************** 120 121 ******************************************************************************/ 122 123 struct nsStringContainer// : public nsAString 124 { 125 private: 126 void* v; 127 void* d1; 128 uint d2; 129 void* d3; 130 } 131 132 struct nsCStringContainer// : public nsACString 133 { 134 private: 135 void* v; 136 void* d1; 137 uint d2; 138 void* d3; 139 } 140 141 /****************************************************************************** 142 143 ******************************************************************************/ 144 145 // import mozilla.xpcom.nsDebug; 146 147 alias nsString_external nsString; 148 alias nsCString_external nsCString; 149 alias nsDependentString_external nsDependentString; 150 alias nsDependentCString_external nsDependentCString; 151 alias NS_ConvertASCIItoUTF16_external NS_ConvertASCIItoUTF16; 152 alias NS_ConvertUTF8toUTF16_external NS_ConvertUTF8toUTF16; 153 alias NS_ConvertUTF16toUTF8_external NS_ConvertUTF16toUTF8; 154 alias NS_LossyConvertUTF16toASCII_external NS_LossyConvertUTF16toASCII; 155 alias nsGetterCopies_external nsGetterCopies; 156 alias nsCGetterCopies_external nsCGetterCopies; 157 alias nsDependentSubstring_external nsDependentSubstring; 158 alias nsDependentCSubstring_external nsDependentCSubstring; 159 160 struct nsString_external{} 161 struct nsCString_external{} 162 struct nsDependentString_external{} 163 struct nsDependentCString_external{} 164 struct NS_ConvertASCIItoUTF16_external{} 165 struct NS_ConvertUTF8toUTF16_external{} 166 struct NS_ConvertUTF16toUTF8_external{} 167 struct NS_LossyConvertUTF16toASCII_external{} 168 169 /****************************************************************************** 170 171 ******************************************************************************/ 172 173 struct nsGetterCopies_external 174 { 175 private: 176 alias PRUnichar char_type; 177 nsString_external *mString; 178 char_type *mData; 179 } 180 181 struct nsCGetterCopies_external 182 { 183 private: 184 alias char char_type; 185 nsCString_external *mString; 186 char_type *mData; 187 } 188 189 /****************************************************************************** 190 191 ******************************************************************************/ 192 193 struct nsDependentSubstring_external{} 194 struct nsDependentCSubstring_external{}