Revision: 9526
Author: con...@google.com
Date: Wed Jan 12 11:43:57 2011
Log: Update the xpcom plugin for Gecko 2.0 (FF4). Only tested on Linux so
far.
Review at http://gwt-code-reviews.appspot.com/1269801
http://code.google.com/p/google-web-toolkit/source/detail?r=9526
Modified:
/trunk/plugins/xpcom/ExternalWrapper.cpp
/trunk/plugins/xpcom/FFSessionHandler.cpp
/trunk/plugins/xpcom/FFSessionHandler.h
/trunk/plugins/xpcom/JavaObject.cpp
/trunk/plugins/xpcom/JavaObject.h
/trunk/plugins/xpcom/Makefile
/trunk/plugins/xpcom/ModuleOOPHM.cpp
/trunk/plugins/xpcom/RootedObject.h
/trunk/plugins/xpcom/SessionData.h
/trunk/plugins/xpcom/XpcomDebug.cpp
/trunk/plugins/xpcom/install-template.rdf
/trunk/plugins/xpcom/prebuilt/extension/chrome.manifest
/trunk/plugins/xpcom/prebuilt/extension/components/stub.js
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3/libgwt_dev_ff3.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3+/libgwt_dev_ff3+.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff35/libgwt_dev_ff35.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff36/libgwt_dev_ff36.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff40/libgwt_dev_ff40.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3/libgwt_dev_ff3.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3+/libgwt_dev_ff3+.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff35/libgwt_dev_ff35.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff36/libgwt_dev_ff36.so
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff40/libgwt_dev_ff40.so
/trunk/plugins/xpcom/prebuilt/gwt-dev-plugin.xpi
=======================================
--- /trunk/plugins/xpcom/ExternalWrapper.cpp Mon Nov 30 16:12:52 2009
+++ /trunk/plugins/xpcom/ExternalWrapper.cpp Wed Jan 12 11:43:57 2011
@@ -32,16 +32,19 @@
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsPIDOMWindow.h"
-
-#ifndef NS_IMPL_ISUPPORTS2_CI
-#include "nsIClassInfoImpl.h" // 1.9 only
-#endif
-
#include "LoadModuleMessage.h"
#include "ServerMethods.h"
#include "BrowserChannel.h"
#include "AllowedConnections.h"
+#if GECKO_VERSION >= 1900
+#include "nsIClassInfoImpl.h"
+#endif //GECKO_VERSION
+
+#if GECKO_VERSION >= 2000
+NS_IMPL_CLASSINFO(ExternalWrapper, NULL, 0, OOPHM_CID)
+#endif //GECKO_VERSION
+
NS_IMPL_ISUPPORTS2_CI(ExternalWrapper, IOOPHM, nsISecurityCheckedComponent)
ExternalWrapper::ExternalWrapper() {
=======================================
--- /trunk/plugins/xpcom/FFSessionHandler.cpp Mon Nov 23 15:38:51 2009
+++ /trunk/plugins/xpcom/FFSessionHandler.cpp Wed Jan 12 11:43:57 2011
@@ -33,6 +33,13 @@
#include "nsIPrincipal.h"
#include "nsServiceManagerUtils.h"
+#if GECKO_VERSION >= 2000
+#define JS_RemoveRootRT js_RemoveRoot
+static inline bool INT_FITS_IN_JSVAL(int i) {
+ return (i >= JSVAL_INT_MIN) && (i <= JSVAL_INT_MAX);
+}
+#endif //GECKO_VERSION
+
static JSContext* getJSContext() {
// Get JSContext from stack.
nsCOMPtr<nsIJSContextStack> stack =
@@ -62,14 +69,14 @@
// TODO(jat): is there a way to avoid calling this twice, without keeping
// JSContext in an instance field?
JSContext* ctx = getJSContext();
- if (!JS_AddNamedRoot(ctx, &jsObjectsById, "jsObjectsById")) {
+ if (!JS_AddNamedObjectRoot(ctx, &jsObjectsById, "jsObjectsById")) {
Debug::log(Debug::Error) << "Error rooting jsObjectsById" <<
Debug::flush;
}
jsObjectsById = JS_NewArrayObject(ctx, 0, NULL);
if (!jsObjectsById) {
Debug::log(Debug::Error) << "Error rooting jsObjectsById" <<
Debug::flush;
}
- if (!JS_AddNamedRoot(ctx, &toStringTearOff, "toStringTearOff")) {
+ if (!JS_AddNamedValueRoot(ctx, &toStringTearOff, "toStringTearOff")) {
Debug::log(Debug::Error) << "Error rooting toStringTearOff" <<
Debug::flush;
}
getStringObjectClass(ctx);
@@ -439,10 +446,15 @@
retVal.setBoolean(JSVAL_TO_BOOLEAN(value));
} else if (JSVAL_IS_STRING(value)) {
JSString* str = JSVAL_TO_STRING(value);
+#if GECKO_VERSION < 2000
retVal.setString(utf8String(JS_GetStringChars(str),
JS_GetStringLength(str)));
+#else
+ retVal.setString(utf8String(JS_GetStringCharsZ(ctx, str),
+ JS_GetStringLength(str)));
+#endif //GECKO_VERSION
} else if (JSVAL_IS_DOUBLE(value)) {
- retVal.setDouble(*JSVAL_TO_DOUBLE(value));
+ retVal.setDouble(JSVAL_TO_DOUBLE(value));
} else if (JSVAL_IS_OBJECT(value)) {
JSObject* obj = JSVAL_TO_OBJECT(value);
if (JavaObject::isJavaObject(ctx, obj)) {
@@ -450,8 +462,13 @@
} else if (JS_GET_CLASS(ctx, obj) == stringObjectClass) {
// JS String wrapper object, treat as a string primitive
JSString* str = JS_ValueToString(ctx, value);
- retVal.setString(utf8String(JS_GetStringChars(str),
- JS_GetStringLength(str)));
+#if GECKO_VERSION < 2000
+ retVal.setString(utf8String(JS_GetStringChars(str),
+ JS_GetStringLength(str)));
+#else
+ retVal.setString(utf8String(JS_GetStringCharsZ(ctx, str),
+ JS_GetStringLength(str)));
+#endif //GECKO_VERSION
// str will be garbage-collected, does not need to be freed
} else {
// It's a plain-old JavaScript Object
=======================================
--- /trunk/plugins/xpcom/FFSessionHandler.h Mon Nov 23 13:18:40 2009
+++ /trunk/plugins/xpcom/FFSessionHandler.h Wed Jan 12 11:43:57 2011
@@ -68,13 +68,4 @@
std::map<void*, int> jsIdsByObject;
};
-inline Debug::DebugStream& operator<<(Debug::DebugStream& dbg, JSString*
str) {
- if (str == NULL) {
- dbg << "null";
- } else {
- dbg << std::string(JS_GetStringBytes(str), JS_GetStringLength(str));
- }
- return dbg;
-}
-
#endif
=======================================
--- /trunk/plugins/xpcom/JavaObject.cpp Mon Nov 30 16:12:57 2009
+++ /trunk/plugins/xpcom/JavaObject.cpp Wed Jan 12 11:43:57 2011
@@ -41,7 +41,11 @@
NULL, /* object hooks */
NULL, /* check access */
+#if GECKO_VERSION < 2000
JavaObject::call, /* call */ //TODO
+#else
+ JavaObject::call20, /* call: compatability wrapper for 2.0+ */
+#endif //GECKO_VERSION
NULL, /* construct */
NULL, /* object serialization */
NULL, /* has instance */
@@ -52,7 +56,6 @@
int JavaObject::getObjectId(JSContext* ctx, JSObject* obj) {
jsval val;
JSClass* jsClass = JS_GET_CLASS(ctx, obj);
-#if 1
if (jsClass != &JavaObjectClass) {
Debug::log(Debug::Error)
<< "JavaObject::getObjectId called on non-JavaObject: " <<
jsClass->name
@@ -66,7 +69,6 @@
<< " reserved slots, no objectId present" << Debug::flush;
return -1;
}
-#endif
if (!JS_GetReservedSlot(ctx, obj, 0, &val)) {
Debug::log(Debug::Error) << "Error getting reserved slot" <<
Debug::flush;
return -1;
@@ -104,16 +106,21 @@
return NULL;
}
// define toString (TODO: some way to avoid doing this each time)
-#if 1
+#if GECKO_VERSION < 2000
if (!JS_DefineFunction(ctx, obj, "toString", JavaObject::toString, 0,
0)) {
Debug::log(Debug::Error) << "Could not define toString method on
object"
<< Debug::flush;
}
-#endif
+#else
+ if (!JS_DefineFunction(ctx, obj, "toString", JavaObject::toString20, 0,
0)) {
+ Debug::log(Debug::Error) << "Could not define toString method on
object"
+ << Debug::flush;
+ }
+#endif //GECKO_VERSION
return obj;
}
-JSBool JavaObject::getProperty(JSContext* ctx, JSObject* obj, jsval id,
+JSBool JavaObject::getProperty(JSContext* ctx, JSObject* obj, jsid id,
jsval* rval) {
Debug::log(Debug::Spam) << "JavaObject::getProperty obj=" << obj <<
Debug::flush;
SessionData* data = JavaObject::getSessionData(ctx, obj);
@@ -123,20 +130,20 @@
return JS_TRUE;
}
int objectRef = JavaObject::getObjectId(ctx, obj);
- if (JSVAL_IS_STRING(id)) {
- JSString* str = JSVAL_TO_STRING(id);
- if ((JS_GetStringLength(str) == 8) && !strncmp("toString",
- JS_GetStringBytes(str), 8)) {
+ if (JSID_IS_STRING(id)) {
+ JSString* str = JSID_TO_STRING(id);
+ if ((JS_GetStringEncodingLength(ctx, str) == 8) && !strncmp("toString",
+ JS_EncodeString(ctx, str), 8)) {
*rval = data->getToStringTearOff();
return JS_TRUE;
}
- if ((JS_GetStringLength(str) == 2) && !strncmp("id",
- JS_GetStringBytes(str), 2)) {
+ if ((JS_GetStringEncodingLength(ctx, str) == 2) && !strncmp("id",
+ JS_EncodeString(ctx, str), 2)) {
*rval = INT_TO_JSVAL(objectRef);
return JS_TRUE;
}
- if ((JS_GetStringLength(str) == 16) && !strncmp("__noSuchMethod__",
- JS_GetStringBytes(str), 16)) {
+ if ((JS_GetStringEncodingLength(ctx, str) == 16)
&& !strncmp("__noSuchMethod__",
+ JS_EncodeString(ctx, str), 16)) {
// Avoid error spew if we are disconnected
*rval = JSVAL_VOID;
return JS_TRUE;
@@ -146,13 +153,13 @@
// TODO: throw a better exception here
return JS_FALSE;
}
- if (!JSVAL_IS_INT(id)) {
+ if (!JSID_IS_INT(id)) {
Debug::log(Debug::Error) << "Getting non-int/non-string property "
<< dumpJsVal(ctx, id) << Debug::flush;
// TODO: throw a better exception here
return JS_FALSE;
}
- int dispId = JSVAL_TO_INT(id);
+ int dispId = JSID_TO_INT(id);
HostChannel* channel = data->getHostChannel();
SessionHandler* handler = data->getSessionHandler();
@@ -162,10 +169,10 @@
return JS_TRUE;
}
-JSBool JavaObject::setProperty(JSContext* ctx, JSObject* obj, jsval id,
+JSBool JavaObject::setProperty(JSContext* ctx, JSObject* obj, jsid id,
jsval* vp) {
Debug::log(Debug::Spam) << "JavaObject::setProperty obj=" << obj <<
Debug::flush;
- if (!JSVAL_IS_INT(id)) {
+ if (!JSID_IS_INT(id)) {
Debug::log(Debug::Error) << " Error: setting string property id" <<
Debug::flush;
// TODO: throw a better exception here
return JS_FALSE;
@@ -177,7 +184,7 @@
}
int objectRef = JavaObject::getObjectId(ctx, obj);
- int dispId = JSVAL_TO_INT(id);
+ int dispId = JSID_TO_INT(id);
Value value;
data->makeValueFromJsval(value, ctx, *vp);
@@ -232,7 +239,7 @@
<< ", INIT)" << Debug::flush;
*statep = JSVAL_ZERO;
if (idp) {
- *idp = INT_TO_JSVAL(NUM_PROPERTY_NAMES);
+ *idp = INT_TO_JSID(NUM_PROPERTY_NAMES);
}
break;
case JSENUMERATE_NEXT:
@@ -243,7 +250,10 @@
*statep = INT_TO_JSVAL(idNum + 1);
if (idNum >= NUM_PROPERTY_NAMES) {
*statep = JSVAL_NULL;
+#if GECKO_VERSION < 2000
+ //TODO(jat): do we need to do this?
*idp = JSVAL_NULL;
+#endif //GECKO_VERSION
} else {
const char* propName = propertyNames[idNum];
JSString* str = JS_NewStringCopyZ(ctx, propName);
@@ -344,6 +354,31 @@
}
return invokeJava(ctx, data, javaThis, dispId, argc - 2, &argv[2], rval);
}
+
+#if GECKO_VERSION >= 2000
+/**
+ * Compatability wrapper for Gecko 2.0+
+ */
+JSBool JavaObject::toString20(JSContext* ctx, uintN argc, jsval* vp) {
+ jsval rval = JSVAL_VOID;
+ JSBool success;
+ success = toString(ctx, JS_THIS_OBJECT(ctx, vp), argc, JS_ARGV(ctx, vp),
+ &rval);
+ JS_SET_RVAL(cx, vp, rval);
+ return success;
+}
+
+/**
+ * Compatability wrapper method for Gecko 2.0+
+ */
+JSBool JavaObject::call20(JSContext* ctx, uintN argc, jsval* vp) {
+ jsval rval = JSVAL_VOID;
+ JSBool success;
+ success = call(ctx, NULL, argc, JS_ARGV(ctx, vp), &rval);
+ JS_SET_RVAL(ctx, vp, rval);
+ return success;
+}
+#endif //GECKO_VERSION
/**
* Calls a method on a Java object and returns a two-element JS array, with
=======================================
--- /trunk/plugins/xpcom/JavaObject.h Mon Aug 3 08:30:11 2009
+++ /trunk/plugins/xpcom/JavaObject.h Wed Jan 12 11:43:57 2011
@@ -22,19 +22,36 @@
class SessionData;
class Value;
+#if GECKO_VERSION < 2000
+#define jsid jsval
+#define JSID_IS_STRING JSVAL_IS_STRING
+#define JSID_TO_STRING JSVAL_TO_STRING
+#define JSID_IS_INT JSVAL_IS_INT
+#define JSID_TO_INT JSVAL_TO_INT
+#define INT_TO_JSID INT_TO_JSVAL
+#define JS_GetStringEncodingLength(ctx, str) JS_GetStringLength(str)
+#define JS_EncodeString(ctx, str) JS_GetStringBytes(str)
+#endif
+
class JavaObject {
public:
static bool isJavaObject(JSContext* ctx, JSObject* obj);
static JSObject* construct(JSContext* ctx, SessionData* data, int
objectRef);
static int getObjectId(JSContext* ctx, JSObject* obj);
- static JSBool getProperty(JSContext* ctx, JSObject* obj, jsval id,
jsval* vp);
- static JSBool setProperty(JSContext* ctx, JSObject* obj, jsval id,
jsval* vp);
+ static JSBool getProperty(JSContext* ctx, JSObject* obj, jsid id, jsval*
vp);
+ static JSBool setProperty(JSContext* ctx, JSObject* obj, jsid id, jsval*
vp);
static JSBool resolve(JSContext* ctx, JSObject* obj, jsval id);
static JSBool convert(JSContext* cx, JSObject* obj, JSType type, jsval*
vp);
static JSBool enumerate(JSContext* ctx, JSObject* obj, JSIterateOp op,
jsval* statep, jsid* idp);
static void finalize(JSContext* ctx, JSObject* obj);
static JSBool toString(JSContext* ctx, JSObject* obj, uintN argc, jsval*
argv, jsval* rval);
static JSBool call(JSContext* ctx, JSObject* obj, uintN argc, jsval*
argv, jsval* rval);
+
+#if GECKO_VERSION >= 2000
+ static JSBool toString20(JSContext* ctx, uintN argc, jsval* vp);
+ static JSBool call20(JSContext* ctx, uintN argc, jsval* vp);
+#endif //GECKO_VERSION
+
private:
static SessionData* getSessionData(JSContext* ctx, JSObject* obj);
static JSBool invokeJava(JSContext* ctx, SessionData* data,
=======================================
--- /trunk/plugins/xpcom/Makefile Fri Oct 22 04:28:03 2010
+++ /trunk/plugins/xpcom/Makefile Wed Jan 12 11:43:57 2011
@@ -49,7 +49,7 @@
export FLAG32BIT
ifeq ($(BROWSER),)
-$(warning Defaulting to FF3 build [set with BROWSER=ff2, ff3, ff3+, ff35,
or ff36])
+$(warning Defaulting to FF3 build [set with BROWSER=ff3, ff3+, ff35, ff36,
or ff40])
BROWSER=ff3
endif
@@ -67,40 +67,41 @@
CFLAGS += -DBROWSER=$(BROWSER)
GECKO_MINOR_VERSION=
-ifeq ($(BROWSER),ff2)
-GECKO_VERSION = 1.8
-else
+GECKO_DLLFLAGS = -lxpcomglue_s -lxpcom
+NSPR_DLLFLAGS = -lnspr4
+MOZJS_DLLFLAGS = -lmozjs
+MOZALLOC_DLLFLAGS =
+
ifeq ($(BROWSER),ff3)
GECKO_VERSION = 1.9.0
-CFLAGS += -DGECKO_19
+CFLAGS += -DGECKO_VERSION=1900
else
ifeq ($(BROWSER),ff3+)
GECKO_VERSION = 1.9.0
-CFLAGS += -DGECKO_19
+CFLAGS += -DGECKO_VERSION=1901
GECKO_MINOR_VERSION=.10
else
ifeq ($(BROWSER),ff35)
GECKO_VERSION = 1.9.1
-CFLAGS += -DGECKO_19
+CFLAGS += -DGECKO_VERSION=1910
else
ifeq ($(BROWSER),ff36)
GECKO_VERSION = 1.9.2
-CFLAGS += -DGECKO_19
+CFLAGS += -DGECKO_VERSION=1920
else
ifeq ($(BROWSER),ff40)
-GECKO_VERSION = 1.9.3
-CFLAGS += -DGECKO_19
-ifeq ($(OS),mac)
-DLLFLAGS += -lmozalloc
-endif
+GECKO_VERSION = 2.0.0
+CFLAGS += -DGECKO_VERSION=2000
+MOZALLOC_DLLFLAGS = -lmozalloc
+#MOZJS is statically linked in FF4
+MOZJS_DLLFLAGS =
else
-$(error Unrecognized BROWSER of $(BROWSER) - options are ff2, ff3, ff3+,
ff35, ff36, ff40)
+$(error Unrecognized BROWSER of $(BROWSER) - options are ff3, ff3+, ff35,
ff36, ff40)
endif
endif
endif
endif
endif
-endif
CFLAGS += -fshort-wchar
CXXFLAGS = $(CXXONLYFLAGS) $(CFLAGS)
@@ -131,18 +132,12 @@
XPIDL = $(GECKO_SDK)/$(GECKO_PLATFORM)/bin/xpidl
XPIDL_FLAGS = -I$(GECKO_SDK)/idl
-#DLLFLAGS += \
-# -L$(GECKO_LIBS) \
-# -L$(FIREFOX_LIBS) \
-# -Wl,$(RUN_PATH_FLAG),$(FIREFOX_LIBS) \
-# -Wl,$(RUN_PATH_FLAG),$(GECKO_LIBS) \
-# -Wl,$(RUN_PATH_FLAG),$(DEFAULT_FIREFOX_LIBS) \
-# -lxpcomglue_s -lxpcom -lnspr4 -lmozjs
DLLFLAGS += \
-L$(DEFAULT_FIREFOX_LIBS) \
-L$(GECKO_LIBS) \
-Wl,$(RUN_PATH_FLAG),$(GECKO_LIBS) \
- -lxpcomglue_s -lxpcom -lnspr4 -lmozjs
+ $(GECKO_DLLFLAGS) $(NSPR_DLLFLAGS) \
+ $(MOZALLOC_DLLFLAGS) $(MOZJS_DLLFLAGS)
INC += -I$(GECKO_PLAT_INC) -I$(GECKO_SDK)/include -I$(dir $(FF_HEADER))
@@ -239,7 +234,6 @@
-cp $(FF_DLL) $(subst
$(EXTENSION_OUTDIR),prebuilt/extension-$(BROWSER),$(subst
x86,ppc,$(FF_PLATFORM_DIR)))/components
endif
else
- @$(MAKE) $@ BROWSER=ff2
@$(MAKE) $@ BROWSER=ff3
@$(MAKE) $@ BROWSER=ff3+
@$(MAKE) $@ BROWSER=ff35
=======================================
--- /trunk/plugins/xpcom/ModuleOOPHM.cpp Thu Jun 17 11:57:35 2010
+++ /trunk/plugins/xpcom/ModuleOOPHM.cpp Wed Jan 12 11:43:57 2011
@@ -18,18 +18,24 @@
#include "ExternalWrapper.h"
#include "nsCOMPtr.h"
-#include "nsIGenericFactory.h"
-#include "nsICategoryManager.h"
#include "nsISupports.h"
#include "nsIXULAppInfo.h"
#include "nsIXULRuntime.h"
#include "nsServiceManagerUtils.h"
#include "nsXPCOMCID.h"
-#ifdef GECKO_19
-#include "nsIClassInfoImpl.h" // 1.9 only
+#if GECKO_VERSION >= 1900
+#include "nsIClassInfoImpl.h"
#endif
+#if GECKO_VERSION >= 2000
+#include "mozilla/ModuleUtils.h"
+#else
+#include "nsIGenericFactory.h"
+#include "nsICategoryManager.h"
+#endif
+
+
// Allow a macro to be treated as a C string, ie -Dfoo=bar; QUOTE(foo)
= "bar"
#define QUOTE_HELPER(x) #x
#define QUOTE(x) QUOTE_HELPER(x)
@@ -49,9 +55,95 @@
}
#endif
-NS_GENERIC_FACTORY_CONSTRUCTOR(ExternalWrapper)
-NS_DECL_CLASSINFO(ExternalWrapper)
-
+// This defines ExternalWrapperConstructor, which in turn instantiates via
+// ExternalWrapper::ExternalWrapper()
+NS_GENERIC_FACTORY_CONSTRUCTOR(ExternalWrapper);
+
+static nsresult Load() {
+ nsresult nr;
+ nsCOMPtr<nsIXULAppInfo> app_info
+ = do_GetService("@mozilla.org/xre/app-info;1", &nr);
+ if (NS_FAILED(nr) || !app_info) {
+ return NS_ERROR_FAILURE;
+ }
+ nsCString gecko_version;
+ app_info->GetPlatformVersion(gecko_version);
+ nsCString browser_version;
+ app_info->GetVersion(browser_version);
+ nsCOMPtr<nsIXULRuntime> xulRuntime
+ = do_GetService("@mozilla.org/xre/app-info;1", &nr);
+ if (NS_FAILED(nr) || !app_info) {
+ return NS_ERROR_FAILURE;
+ }
+ nsCString os;
+ xulRuntime->GetOS(os);
+ nsCString abi;
+ xulRuntime->GetXPCOMABI(abi);
+ Debug::log(Debug::Info) << "Initializing GWT Developer Plugin"
+ << Debug::flush;
+ Debug::log(Debug::Info) << " gecko=" << gecko_version.BeginReading()
+ << ", firefox=" << browser_version.BeginReading() << ", abi="
+ << os.BeginReading() << "_" << abi.BeginReading() << ", built for "
+ QUOTE(BROWSER) << Debug::flush;
+ return NS_OK;
+}
+
+static void Unload() {
+ Debug::log(Debug::Debugging) << "ModuleOOPHM Unload()"
+ << Debug::flush;
+}
+
+#if GECKO_VERSION >= 2000
+/**
+ * Gecko 2.0 has a completely different initialization mechanism
+ */
+
+// This defines kOOPHM_CID variable that refers to the OOPHM_CID
+NS_DEFINE_NAMED_CID(OOPHM_CID);
+
+// Build a table of ClassIDs (CIDs) which are implemented by this module.
CIDs
+// should be completely unique UUIDs.
+// each entry has the form { CID, service, factoryproc, constructorproc }
+// where factoryproc is usually NULL.
+static const mozilla::Module::CIDEntry kOOPHMCIDs[] = {
+ {&kOOPHM_CID, false, NULL, ExternalWrapperConstructor},
+ {NULL }
+};
+
+// Build a table which maps contract IDs to CIDs.
+// A contract is a string which identifies a particular set of
functionality. In some
+// cases an extension component may override the contract ID of a builtin
gecko component
+// to modify or extend functionality.
+static const mozilla::Module::ContractIDEntry kOOPHMContracts[] = {
+ {OOPHM_CONTRACTID, &kOOPHM_CID},
+ {NULL}
+};
+
+// Category entries are category/key/value triples which can be used
+// to register contract ID as content handlers or to observe certain
+// notifications.
+static const mozilla::Module::CategoryEntry kOOPHMCategories[] = {
+ {"JavaScript-global-property", "__gwt_HostedModePlugin",
OOPHM_CONTRACTID},
+ {NULL}
+};
+
+static const mozilla::Module kModuleOOPHM = {
+ mozilla::Module::kVersion,
+ kOOPHMCIDs,
+ kOOPHMContracts,
+ kOOPHMCategories,
+ NULL, /* Use the default factory */
+ Load,
+ Unload
+};
+
+NSMODULE_DEFN(ModuleOOPHM) = &kModuleOOPHM;
+
+#else
+/**
+ * pre-Gecko2.0 initialization
+ */
+NS_DECL_CLASSINFO(ExternalWrapper);
static NS_IMETHODIMP registerSelf(nsIComponentManager *aCompMgr, nsIFile
*aPath,
const char *aLoaderStr, const char *aType,
const nsModuleComponentInfo *aInfo) {
@@ -76,8 +168,7 @@
}
static NS_IMETHODIMP factoryDestructor(void) {
- Debug::log(Debug::Debugging) << "ModuleOOPHM factoryDestructor()"
- << Debug::flush;
+ Unload();
return NS_OK;
}
@@ -117,30 +208,7 @@
NSGETMODULE_ENTRY_POINT(ExternalWrapperModule) (nsIComponentManager
*servMgr,
nsIFile* location, nsIModule** result) {
- nsresult nr;
- nsCOMPtr<nsIXULAppInfo> app_info
- = do_GetService("@mozilla.org/xre/app-info;1", &nr);
- if (NS_FAILED(nr) || !app_info) {
- return NS_ERROR_FAILURE;
- }
- nsCString gecko_version;
- app_info->GetPlatformVersion(gecko_version);
- nsCString browser_version;
- app_info->GetVersion(browser_version);
- nsCOMPtr<nsIXULRuntime> xulRuntime
- = do_GetService("@mozilla.org/xre/app-info;1", &nr);
- if (NS_FAILED(nr) || !app_info) {
- return NS_ERROR_FAILURE;
- }
- nsCString os;
- xulRuntime->GetOS(os);
- nsCString abi;
- xulRuntime->GetXPCOMABI(abi);
- Debug::log(Debug::Info) << "Initializing GWT Developer Plugin"
- << Debug::flush;
- Debug::log(Debug::Info) << " gecko=" << gecko_version.BeginReading()
- << ", firefox=" << browser_version.BeginReading() << ", abi="
- << os.BeginReading() << "_" << abi.BeginReading() << ", built for "
- QUOTE(BROWSER) << Debug::flush;
+ Load();
return NS_NewGenericModule2(&kModuleInfo, result);
}
+#endif //GECKO_VERSION
=======================================
--- /trunk/plugins/xpcom/RootedObject.h Mon Aug 3 08:30:11 2009
+++ /trunk/plugins/xpcom/RootedObject.h Wed Jan 12 11:43:57 2011
@@ -20,10 +20,17 @@
#include "jsapi.h"
+#if GECKO_VERSION < 2000
+#define JS_AddNamedObjectRoot JS_AddNamedRoot
+#define JS_AddNamedValueRoot JS_AddNamedRoot
+#define JS_RemoveObjectRoot JS_RemoveRoot
+#define JS_RemoveValueRoot JS_RemoveRoot
+#endif
+
class RootedObject {
public:
RootedObject(JSContext* ctx, const char* name = 0) : ctx(ctx), obj(0) {
- if (!JS_AddNamedRoot(ctx, &obj, name)) {
+ if (!JS_AddNamedObjectRoot(ctx, &obj, name)) {
Debug::log(Debug::Error) << "RootedObject(" << (name ? name : "")
<< "): JS_AddNamedRoot failed" << Debug::flush;
}
@@ -31,7 +38,7 @@
~RootedObject() {
// Always returns success, so no need to check.
- JS_RemoveRoot(ctx, &obj);
+ JS_RemoveObjectRoot(ctx, &obj);
}
JSObject& operator*() const {
=======================================
--- /trunk/plugins/xpcom/SessionData.h Mon Aug 3 08:30:11 2009
+++ /trunk/plugins/xpcom/SessionData.h Wed Jan 12 11:43:57 2011
@@ -22,13 +22,17 @@
#include "jsapi.h"
+#if GECKO_VERSION >= 2000
+#include "jsobj.h"
+#endif
+
class HostChannel;
class SessionData {
public:
SessionData(HostChannel* channel, SessionHandler* sessionHandler,
JSContext* ctx) : channel(channel), sessionHandler(sessionHandler),
- global(JS_GetGlobalObject(ctx)), runtime(JS_GetRuntime(ctx)),
+ global(SessionData::getJSGlobalObject(ctx)),
runtime(JS_GetRuntime(ctx)),
toStringTearOff(JSVAL_VOID)
{
}
@@ -65,6 +69,17 @@
* Removes the JavaObject wrapper with the given id and notifies the host.
*/
virtual void freeJavaObject(int objectId)=0;
+
+private:
+ static JSObject* getJSGlobalObject(JSContext* ctx) {
+ JSObject* global = JS_GetGlobalObject(ctx);
+#if GECKO_VERSION >= 2000
+ // Innerize the global object from the WindowProxy object to its inner
+ // Window delegate since the proxy can't be used for evaluating
scripts.
+ OBJ_TO_INNER_OBJECT(ctx, global);
+#endif //GECKO_VERSION
+ return global;
+ }
protected:
/*
=======================================
--- /trunk/plugins/xpcom/XpcomDebug.cpp Wed Jan 27 07:05:14 2010
+++ /trunk/plugins/xpcom/XpcomDebug.cpp Wed Jan 12 11:43:57 2011
@@ -53,10 +53,18 @@
} else if (JSVAL_IS_INT(v)) {
snprintf(buf, sizeof(buf), "int(%d)", JSVAL_TO_INT(v));
} else if (JSVAL_IS_DOUBLE(v)) {
- snprintf(buf, sizeof(buf), "double(%lf)", *JSVAL_TO_DOUBLE(v));
+ double d;
+#if GECKO_VERSION < 2000
+ d= *JSVAL_TO_DOUBLE(v);
+#else
+ d = JSVAL_TO_DOUBLE(v);
+#endif //GECKO_VERSION
+ snprintf(buf, sizeof(buf), "double(%lf)", d);
} else if (JSVAL_IS_STRING(v)) {
JSString* str = JSVAL_TO_STRING(v);
- size_t len = JS_GetStringLength(str);
+
+ size_t len = JS_GetStringEncodingLength(ctx, str);
+
const char* continued = "";
if (len > 20) {
len = 20;
@@ -64,12 +72,12 @@
}
// TODO: trashes Unicode
snprintf(buf, sizeof(buf), "string(%.*s%s)", static_cast<int>(len),
- JS_GetStringBytes(str), continued);
+ JS_EncodeString(ctx, str), continued);
} else if (JSVAL_IS_BOOLEAN(v)) {
snprintf(buf, sizeof(buf), "bool(%s)", JSVAL_TO_BOOLEAN(v) ? "true"
: " false");
} else {
- snprintf(buf, sizeof(buf), "unknown(%08x)", v);
+ snprintf(buf, sizeof(buf), "unknown(%08x)", (unsigned) v);
}
buf[sizeof(buf) - 1] = 0;
return std::string(buf);
=======================================
--- /trunk/plugins/xpcom/install-template.rdf Thu Jun 17 11:57:35 2010
+++ /trunk/plugins/xpcom/install-template.rdf Wed Jan 12 11:43:57 2011
@@ -7,10 +7,10 @@
<em:name>Google Web Toolkit Developer Plugin for Firefox</em:name>
<em:version>GWT_DEV_PLUGIN_VERSION</em:version>
<em:type>2</em:type>
+ <em:unpack>true</em:unpack>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
- <!-- TODO: can we add 1.5-2.0 back? Do we care? -->
<em:minVersion>3.0</em:minVersion>
<em:maxVersion>4.0.*</em:maxVersion>
</Description>
=======================================
--- /trunk/plugins/xpcom/prebuilt/extension/chrome.manifest Fri Nov 6
13:34:25 2009
+++ /trunk/plugins/xpcom/prebuilt/extension/chrome.manifest Wed Jan 12
11:43:57 2011
@@ -1,2 +1,11 @@
content gwt-dev-plugin content/
skin gwt-dev-plugin classic/1.0 skin/
+
+binary-component lib/Linux_x86_64-gcc3/ff40/libgwt_dev_ff40.so
ABI=Linux_x86_64-gcc3
+binary-component lib/Linux_x86-gcc3/ff40/libgwt_dev_ff40.so
ABI=Linux_x86-gcc3
+# Windows and Mac are not yet supported
+# binary-component lib/Darwin-gcc3/ff40/libgwt_dev_ff40.dylib
ABI=Darwin_x86-gcc3
+# binary-component lib/WINNT_x86-msvc/ff40/xpGwtDevPlugin.dll
ABI=WINNT_x86-msvc
+
+interfaces components/IOOPHM.xpt
+contract @gwt.google.com/ExternalWrapper;1
{028DD88B-6D65-401D-AAFD-17E497D15D09}
=======================================
--- /trunk/plugins/xpcom/prebuilt/extension/components/stub.js Thu Jun 17
11:57:35 2010
+++ /trunk/plugins/xpcom/prebuilt/extension/components/stub.js Wed Jan 12
11:43:57 2011
@@ -33,6 +33,10 @@
// components are located, depending on what version of Firefox we detect
we are
// running in.
+// NOTE: This file is only used pre Gecko 2.0 (FF4). The registration
mechanism
+// in Gecko 2.0 allows the chrome.manifest to indicate the appropriate
binary
+// component for each ABI.
+
const Cc = Components.classes;
const Ci = Components.interfaces;
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3/libgwt_dev_ff3.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3/libgwt_dev_ff3.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3+/libgwt_dev_ff3+.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff3+/libgwt_dev_ff3+.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff35/libgwt_dev_ff35.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff35/libgwt_dev_ff35.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff36/libgwt_dev_ff36.so
Wed Jan 27 07:05:14 2010
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff36/libgwt_dev_ff36.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff40/libgwt_dev_ff40.so
Thu Jun 17 11:57:35 2010
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86-gcc3/ff40/libgwt_dev_ff40.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3/libgwt_dev_ff3.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3/libgwt_dev_ff3.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3+/libgwt_dev_ff3+.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff3+/libgwt_dev_ff3+.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff35/libgwt_dev_ff35.so
Mon Nov 30 17:41:06 2009
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff35/libgwt_dev_ff35.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff36/libgwt_dev_ff36.so
Mon Feb 1 10:54:40 2010
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff36/libgwt_dev_ff36.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
---
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff40/libgwt_dev_ff40.so
Thu Jun 17 11:57:35 2010
+++
/trunk/plugins/xpcom/prebuilt/extension/lib/Linux_x86_64-gcc3/ff40/libgwt_dev_ff40.so
Wed Jan 12 11:43:57 2011
File is too large to display a diff.
=======================================
--- /trunk/plugins/xpcom/prebuilt/gwt-dev-plugin.xpi Thu Jun 17 11:57:35
2010
+++ /trunk/plugins/xpcom/prebuilt/gwt-dev-plugin.xpi Wed Jan 12 11:43:57
2011
File is too large to display a diff.
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors