root/dwt/internal/mozilla/nsID.d

Revision 327:b0d7eb5bd76c, 2.0 kB (checked in by John Reimer <terminal.node@gmail.com>, 3 years ago)

Adding Mozilla XPCOM interfaces from dwt-linux to dwt-win

Line 
1 module dwt.internal.mozilla.nsID;
2
3 import dwt.internal.mozilla.Common;
4 import dwt.dwthelper.utils;
5
6 align(1)
7 struct nsID
8 {
9     PRUint32 m0;
10     PRUint16 m1;
11     PRUint16 m2;
12     PRUint8[8] m3;
13
14     static nsID opCall(String aIDStr)
15     {
16         nsID id;
17         if(aIDStr == null) throw new ParseException();
18         int i = 0;
19         with(id) {
20             for (; i < 8; i++) m0 = (m0 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16);
21             if (aIDStr.charAt (i) != '-') throw new ParseException ();
22             i++;
23             for (; i < 13; i++) m1 = cast(short)((m1 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
24             if (aIDStr.charAt (i) != '-') throw new ParseException ();
25             i++;
26             for (; i < 18; i++) m2 = cast(short)((m2 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
27             if (aIDStr.charAt (i) != '-') throw new ParseException ();
28             i++;
29             for (; i < 21; i++) m3[0] = cast(byte)((m3[0] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
30             for (; i < 23; i++) m3[1] = cast(byte)((m3[1] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
31             if (aIDStr.charAt (i) != '-') throw new ParseException ();
32             i++;
33             for (; i < 26; i++) m3[2] = cast(byte)((m3[2] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
34             for (; i < 28; i++) m3[3] = cast(byte)((m3[3] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
35             for (; i < 30; i++) m3[4] = cast(byte)((m3[4] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
36             for (; i < 32; i++) m3[5] = cast(byte)((m3[5] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
37             for (; i < 34; i++) m3[6] = cast(byte)((m3[6] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
38             for (; i < 36; i++) m3[7] = cast(byte)((m3[7] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
39         }
40         return id;
41     }
42
43 }
44
45 alias nsID nsCID;
46 alias nsID nsIID;
Note: See TracBrowser for help on using the browser.