Improve comments in JsValueIE6 (reverting the change of factoring out the check for wrapper objects), adding a VT_WEIRD_IE7_BSTR type for the type 130 variant returned by IE7 for the name of an exception object, and added code to treat it identically to VT_BSTR since it appears to function identically, although with a string constant for the value.
Review by: scottb
knorton (final desk review of changes discussed with scottb)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@685 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
index 4474176..404fb2a 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/JsValueIE6.java
@@ -260,20 +260,24 @@
if (variant.getType() == COM.VT_BSTR) {
return true;
}
+ // see if the variant is a wrapper object
if (variant.getType() != COM.VT_DISPATCH) {
return false;
}
-
- // see if it's a String wrapper object
OleAutomation auto = null;
Variant result = null;
try {
auto = new OleAutomation(variant.getDispatch());
+ // see if it has a valueOf method
int[] ids = auto.getIDsOfNames(new String[] {"valueOf"});
if (ids == null) {
return false;
}
result = auto.invoke(ids[0]);
+ /*
+ * If the return type of the valueOf method is string, we assume it is a
+ * String wrapper object.
+ */
return result.getType() == COM.VT_BSTR;
} finally {
if (auto != null) {
diff --git a/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java b/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java
index fc852cf..a1df554 100644
--- a/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java
+++ b/dev/windows/src/org/eclipse/swt/internal/ole/win32/COM.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
+// Modified by Google
package org.eclipse.swt.internal.ole.win32;
import org.eclipse.swt.internal.win32.*;
@@ -379,6 +380,15 @@
public static final short VT_UI4 = 19;
public static final short VT_UNKNOWN = 13;
public static final short VT_VARIANT = 12;
+ /*
+ * GOOGLE: IE7 returns a variant of type 130 from the name field
+ * of a JavaScript exception, and we can't find documentation of it
+ * anywhere. It appears to contain a pointer to a string constant
+ * that behaves like a VT_BSTR, so we are treating it the same way.
+ * Note that this is a gross hack using a totally undocumented
+ * feature, and Microsoft may break these assumptions at any time.
+ */
+ public static final short VT_WEIRD_IE7_BSTR = 130;
public static final short VARIANT_TRUE = -1;
public static final short VARIANT_FALSE = 0;
diff --git a/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java b/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java
index 2b74f51..3ddd0bf 100644
--- a/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java
+++ b/dev/windows/src/org/eclipse/swt/ole/win32/Variant.java
@@ -992,6 +992,11 @@
unknownData.AddRef();
break;
}
+
+ // GOOGLE: map exception name in IE7 to BSTR
+ case COM.VT_WEIRD_IE7_BSTR :
+ type = COM.VT_BSTR;
+ // intentional fall-through to VT_BSTR case
case COM.VT_BSTR :
// get the address of the memory in which the string resides
int[] hMem = new int[1];