Mercurial > projects > dwt-linux
annotate dwt/internal/mozilla/nsEmbedString.d @ 348:9a4d7706df52
Test Update to fix linux XPCOM interface issues
author | John Reimer <terminal.node@gmail.com> |
---|---|
date | Fri, 31 Oct 2008 21:46:44 -0700 |
parents | 3f4a5c7d138f |
children |
rev | line source |
---|---|
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
1 module dwt.internal.mozilla.nsEmbedString; |
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
2 |
340 | 3 import Utf = tango.text.convert.Utf; |
4 | |
5 import dwt.internal.mozilla.Common; | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
6 import dwt.internal.mozilla.nsStringAPI; |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
340
diff
changeset
|
7 import XPCOM = dwt.internal.mozilla.XPCOM; |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
8 |
340 | 9 scope class nsEmbedString |
10 { | |
11 this(wchar[] s) | |
12 { | |
13 nsresult result; | |
14 result = NS_StringContainerInit2(&str, s.ptr, s.length, 0); | |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
340
diff
changeset
|
15 if (XPCOM.NS_FAILED(result)) |
340 | 16 throw new Exception("Init string container fail"); |
17 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
18 |
340 | 19 this() |
20 { | |
21 nsresult result; | |
22 result = NS_StringContainerInit(&str); | |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
340
diff
changeset
|
23 if (XPCOM.NS_FAILED(result)) |
340 | 24 throw new Exception("Init string container fail"); |
25 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
26 |
340 | 27 nsAString* opCast() |
28 { | |
29 return cast(nsAString*)&str; | |
30 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
31 |
340 | 32 wchar[] toString16() |
33 { | |
34 wchar* buffer = null; | |
35 PRBool terminated; | |
36 uint len = NS_StringGetData(cast(nsAString*)&str, &buffer, &terminated); | |
37 return buffer[0 .. len].dup; | |
38 } | |
39 | |
40 char[] toString() | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
41 { |
340 | 42 return Utf.toString(this.toString16()); |
43 } | |
44 ~this() | |
45 { | |
46 NS_StringContainerFinish(&str); | |
47 } | |
48 private: | |
49 nsStringContainer str; | |
50 } | |
51 | |
52 | |
53 scope class nsEmbedCString | |
54 { | |
55 this(char[] s) | |
56 { | |
57 nsresult result; | |
58 result = NS_CStringContainerInit2(&str, s.ptr, s.length, 0); | |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
340
diff
changeset
|
59 if (XPCOM.NS_FAILED(result)) |
340 | 60 throw new Exception("Init string container fail"); |
61 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
62 |
340 | 63 this() |
64 { | |
65 nsresult result; | |
66 result = NS_CStringContainerInit(&str); | |
348
9a4d7706df52
Test Update to fix linux XPCOM interface issues
John Reimer <terminal.node@gmail.com>
parents:
340
diff
changeset
|
67 if (XPCOM.NS_FAILED(result)) |
340 | 68 throw new Exception("Init string container fail"); |
69 } | |
70 | |
71 nsACString* opCast() | |
72 { | |
73 return cast(nsACString*)&str; | |
74 } | |
278
93409d9838c5
Commit more browser/xpcom updates, including still uncoverted source.
John Reimer<terminal.node@gmail.com>
parents:
diff
changeset
|
75 |
340 | 76 char[] toString() |
77 { | |
78 char* buffer = null; | |
79 PRBool terminated; | |
80 uint len = NS_CStringGetData(cast(nsACString*)&str, &buffer, &terminated); | |
81 return buffer[0 .. len].dup; | |
82 } | |
83 | |
84 ~this() | |
85 { | |
86 NS_CStringContainerFinish(&str); | |
87 } | |
88 private: | |
89 nsCStringContainer str; | |
90 } | |
91 |