diff dwt/internal/mozilla/nsID.d @ 340:3f4a5c7d138f

Fixes
author John Reimer <terminal.node@gmail.com>
date Sun, 26 Oct 2008 08:09:00 -0700
parents 8235a17d9255
children
line wrap: on
line diff
--- a/dwt/internal/mozilla/nsID.d	Sat Oct 25 21:01:54 2008 -0700
+++ b/dwt/internal/mozilla/nsID.d	Sun Oct 26 08:09:00 2008 -0700
@@ -1,6 +1,7 @@
 module dwt.internal.mozilla.nsID;
 
 import dwt.internal.mozilla.Common;
+import dwt.dwthelper.utils;
 
 align(1)
 struct nsID
@@ -9,18 +10,36 @@
     PRUint16 m1;
     PRUint16 m2;
     PRUint8[8] m3;
-/+
-	static nsID opCall(PRUint32 v0, PRUint16 v1, PRUint16 v2, PRUint8[8] v3)
+
+	static nsID opCall(String aIDStr)
 	{
-		nsID result;
-		result.m0 = v0;
-		result.m1 = v1;
-		result.m2 = v2;
-		for(int i=0; i<8; ++i)
-			result.m3[i] = v3[i];
-		return result;
+        nsID id;
+        if(aIDStr == null) throw new ParseException();
+        int i = 0;
+        with(id) {
+            for (; i < 8; i++) m0 = (m0 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16);
+            if (aIDStr.charAt (i) != '-') throw new ParseException ();
+            i++;
+            for (; i < 13; i++) m1 = cast(short)((m1 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            if (aIDStr.charAt (i) != '-') throw new ParseException ();
+            i++;
+            for (; i < 18; i++) m2 = cast(short)((m2 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            if (aIDStr.charAt (i) != '-') throw new ParseException ();
+            i++;
+            for (; i < 21; i++) m3[0] = cast(byte)((m3[0] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 23; i++) m3[1] = cast(byte)((m3[1] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            if (aIDStr.charAt (i) != '-') throw new ParseException ();
+            i++;
+            for (; i < 26; i++) m3[2] = cast(byte)((m3[2] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 28; i++) m3[3] = cast(byte)((m3[3] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 30; i++) m3[4] = cast(byte)((m3[4] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 32; i++) m3[5] = cast(byte)((m3[5] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 34; i++) m3[6] = cast(byte)((m3[6] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+            for (; i < 36; i++) m3[7] = cast(byte)((m3[7] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+        }
+        return id;
 	}
-+/
+
 }
 
 alias nsID nsCID;