Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/mozilla/nsEmbedString.d @ 48:ddbfe84d86df
[swt lin] versioned imports
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 12:05:20 +0100 |
parents | f713da8bc051 |
children | 7a2dd761a8b2 |
comparison
equal
deleted
inserted
replaced
47:65761bc28ab2 | 48:ddbfe84d86df |
---|---|
1 module org.eclipse.swt.internal.mozilla.nsEmbedString; | 1 module org.eclipse.swt.internal.mozilla.nsEmbedString; |
2 | 2 |
3 import java.lang.all; | 3 import java.lang.all; |
4 | 4 |
5 version(Tango){ | |
5 import Utf = tango.text.convert.Utf; | 6 import Utf = tango.text.convert.Utf; |
7 } else { // Phobos | |
8 } | |
6 | 9 |
7 import org.eclipse.swt.internal.mozilla.Common; | 10 import org.eclipse.swt.internal.mozilla.Common; |
8 import org.eclipse.swt.internal.mozilla.nsStringAPI; | 11 import org.eclipse.swt.internal.mozilla.nsStringAPI; |
9 import XPCOM = org.eclipse.swt.internal.mozilla.XPCOM; | 12 import XPCOM = org.eclipse.swt.internal.mozilla.XPCOM; |
10 | 13 |
11 scope class nsEmbedString | 14 scope class nsEmbedString |
12 { | 15 { |
13 this(wchar[] s) | 16 this(wchar[] s) |
14 { | 17 { |
15 nsresult result; | 18 nsresult result; |
16 result = NS_StringContainerInit2(&str, s.ptr, s.length, 0); | 19 result = NS_StringContainerInit2(&str, s.ptr, s.length, 0); |
17 if (XPCOM.NS_FAILED(result)) | 20 if (XPCOM.NS_FAILED(result)) |
18 throw new Exception("Init string container fail"); | 21 throw new Exception("Init string container fail"); |
19 } | 22 } |
20 | 23 |
21 this() | 24 this() |
22 { | 25 { |
23 nsresult result; | 26 nsresult result; |
24 result = NS_StringContainerInit(&str); | 27 result = NS_StringContainerInit(&str); |
25 if (XPCOM.NS_FAILED(result)) | 28 if (XPCOM.NS_FAILED(result)) |
26 throw new Exception("Init string container fail"); | 29 throw new Exception("Init string container fail"); |
27 } | 30 } |
28 | 31 |
29 nsAString* opCast() | 32 nsAString* opCast() |
30 { | 33 { |
31 return cast(nsAString*)&str; | 34 return cast(nsAString*)&str; |
32 } | 35 } |
33 | 36 |
34 wchar[] toString16() | 37 wchar[] toString16() |
35 { | 38 { |
36 wchar* buffer = null; | 39 wchar* buffer = null; |
37 PRBool terminated; | 40 PRBool terminated; |
38 uint len = NS_StringGetData(cast(nsAString*)&str, &buffer, &terminated); | 41 uint len = NS_StringGetData(cast(nsAString*)&str, &buffer, &terminated); |
39 return buffer[0 .. len].dup; | 42 return buffer[0 .. len].dup; |
40 } | 43 } |
41 | 44 |
42 char[] toString() | 45 char[] toString() |
43 { | 46 { |
44 return Utf.toString(this.toString16()); | 47 return Utf.toString(this.toString16()); |
45 } | 48 } |
46 ~this() | 49 ~this() |
47 { | 50 { |
48 NS_StringContainerFinish(&str); | 51 NS_StringContainerFinish(&str); |
49 } | 52 } |
50 private: | 53 private: |
51 nsStringContainer str; | 54 nsStringContainer str; |
52 } | 55 } |
53 | 56 |
54 | 57 |
55 scope class nsEmbedCString | 58 scope class nsEmbedCString |
56 { | 59 { |
57 this(char[] s) | 60 this(char[] s) |
58 { | 61 { |
59 nsresult result; | 62 nsresult result; |
60 result = NS_CStringContainerInit2(&str, s.ptr, s.length, 0); | 63 result = NS_CStringContainerInit2(&str, s.ptr, s.length, 0); |
61 if (XPCOM.NS_FAILED(result)) | 64 if (XPCOM.NS_FAILED(result)) |
62 throw new Exception("Init string container fail"); | 65 throw new Exception("Init string container fail"); |
63 } | 66 } |
64 | 67 |
65 this() | 68 this() |
66 { | 69 { |
67 nsresult result; | 70 nsresult result; |
68 result = NS_CStringContainerInit(&str); | 71 result = NS_CStringContainerInit(&str); |
69 if (XPCOM.NS_FAILED(result)) | 72 if (XPCOM.NS_FAILED(result)) |
70 throw new Exception("Init string container fail"); | 73 throw new Exception("Init string container fail"); |
71 } | 74 } |
72 | 75 |
73 nsACString* opCast() | 76 nsACString* opCast() |
74 { | 77 { |
75 return cast(nsACString*)&str; | 78 return cast(nsACString*)&str; |
76 } | 79 } |
77 | 80 |
78 char[] toString() | 81 char[] toString() |
79 { | 82 { |
80 char* buffer = null; | 83 char* buffer = null; |
81 PRBool terminated; | 84 PRBool terminated; |
82 uint len = NS_CStringGetData(cast(nsACString*)&str, &buffer, &terminated); | 85 uint len = NS_CStringGetData(cast(nsACString*)&str, &buffer, &terminated); |
83 return buffer[0 .. len].dup; | 86 return buffer[0 .. len].dup; |
84 } | 87 } |
85 | 88 |
86 ~this() | 89 ~this() |
87 { | 90 { |
88 NS_CStringContainerFinish(&str); | 91 NS_CStringContainerFinish(&str); |
89 } | 92 } |
90 private: | 93 private: |
91 nsCStringContainer str; | 94 nsCStringContainer str; |
92 } | 95 } |
93 | 96 |