diff options
15 files changed, 527 insertions, 1263 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java index 9803ed701c..d3ac919656 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java @@ -347,8 +347,7 @@ public void createFunction (BrowserFunction function) { functionBuffer.append (")); throw error;} return result;};"); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer ("if (!window.callJava) {window.callJava = function callJava(index, token, args) {"); //$NON-NLS-1$ -// buffer.append ("return external.callJava(index,token,args);}};"); //$NON-NLS-1$ - buffer.append ("return external.callJava(1, 2, 3);}};"); //$NON-NLS-1$ + buffer.append ("return external.callJava(index,token,args);}};"); //$NON-NLS-1$ if (function.top) { buffer.append (functionBuffer.toString ()); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp index 77e5d454b1..ffef909520 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom.cpp @@ -3231,6 +3231,31 @@ fail: } #endif +#if (!defined(NO__1VtblCall__IIJJJJ) && !defined(JNI64)) || (!defined(NO__1VtblCall__IJJJJJ) && defined(JNI64)) +#ifndef JNI64 +extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIJJJJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5); +JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIJJJJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5) +#else +extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IJJJJJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5); +JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IJJJJJ)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5) +#endif +{ + jint rc = 0; +#ifndef JNI64 + XPCOM_NATIVE_ENTER(env, that, _1VtblCall__IIJJJJ_FUNC); +#else + XPCOM_NATIVE_ENTER(env, that, _1VtblCall__IJJJJJ_FUNC); +#endif + rc = (jint)((jint (STDMETHODCALLTYPE *)(jintLong, jlong, jlong, jlong, jlong))(*(jintLong **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5); +#ifndef JNI64 + XPCOM_NATIVE_EXIT(env, that, _1VtblCall__IIJJJJ_FUNC); +#else + XPCOM_NATIVE_EXIT(env, that, _1VtblCall__IJJJJJ_FUNC); +#endif + return rc; +} +#endif + #if (!defined(NO__1VtblCall__IIJJJJIJ_3C_3I_3J) && !defined(JNI64)) || (!defined(NO__1VtblCall__IJJJJJIJ_3C_3I_3J) && defined(JNI64)) #ifndef JNI64 extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(_1VtblCall__IIJJJJIJ_3C_3I_3J)(JNIEnv *env, jclass that, jint arg0, jintLong arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jint arg6, jlong arg7, jcharArray arg8, jintArray arg9, jlongArray arg10); @@ -7026,19 +7051,6 @@ JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1nsIMemory_1Realloc) } #endif -#ifndef NO__1nsIScriptContext_1GetGlobalObject -extern "C" JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1nsIScriptContext_1GetGlobalObject)(JNIEnv *env, jclass that, jintLong arg0); -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1nsIScriptContext_1GetGlobalObject) - (JNIEnv *env, jclass that, jintLong arg0) -{ - jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1nsIScriptContext_1GetGlobalObject_FUNC); - rc = (jintLong)((nsIScriptContext *)arg0)->GetGlobalObject(); - XPCOM_NATIVE_EXIT(env, that, _1nsIScriptContext_1GetGlobalObject_FUNC); - return rc; -} -#endif - #ifndef NO__1nsIScriptContext_1GetNativeContext extern "C" JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1nsIScriptContext_1GetNativeContext)(JNIEnv *env, jclass that, jintLong arg0); JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1nsIScriptContext_1GetNativeContext) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.cpp index 0c81ec87d6..bbea17dca6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.cpp @@ -194,55 +194,6 @@ fail: } #endif -#ifndef NO__1JS_1GetGlobalObject -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1GetGlobalForScopeChain) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0) -{ - jbyte *lpmozillaPath=NULL; - jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1JS_1GetGlobalForScopeChain_FUNC); - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JS_GetGlobalForScopeChain(arg0); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JS_GetGlobalForScopeChain"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong))fp)(arg0); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JS_GetGlobalForScopeChain"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - XPCOM_NATIVE_EXIT(env, that, _1JS_1GetGlobalForScopeChain_FUNC); - return rc; -} -#endif - #ifndef NO__1JS_1NewObject JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1NewObject) (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0, jintLong arg1, jintLong arg2, jintLong arg3) @@ -252,7 +203,7 @@ JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1NewObject) XPCOM_NATIVE_ENTER(env, that, _1JS_1NewObject_FUNC); if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; /* - rc = (jint)JS_GetGlobalObject(arg0, arg1, arg2, arg3); + rc = (jint)JS_NewObject(arg0, arg1, arg2, arg3); */ { @@ -292,253 +243,27 @@ fail: } #endif -#ifndef NO__1JS_1ValueToString -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1ValueToString) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0, jintLong arg1) -{ - jbyte *lpmozillaPath=NULL; - jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1JS_1ValueToString_FUNC); - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JS_ValueToString(arg0, arg1, arg2, arg3); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JS_ValueToString"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong, jintLong))fp)(arg0, arg1); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JS_ValueToString"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - XPCOM_NATIVE_EXIT(env, that, _1JS_1ValueToString_FUNC); - return rc; -} -#endif - - - -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JSVAL_1TO_1IMPL2) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0) -{ - jbyte *lpmozillaPath=NULL; - jintLong rc = 0; - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JSVAL_TO_IMPL2(arg0); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JSVAL_TO_IMPL2"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong))fp)(arg0); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JSVAL_TO_IMPL2"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - return rc; -} - -#ifndef NO__1JS_1GetStringCharsZ -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1GetStringCharsZ) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0, jintLong arg1) -{ - jbyte *lpmozillaPath=NULL; - jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1JS_1GetStringCharsZ_FUNC); - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JS_GetStringCharsZ(arg0, arg1, arg2, arg3); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JS_GetStringCharsZ"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong, jintLong))fp)(arg0, arg1); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JS_GetStringCharsZ"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - XPCOM_NATIVE_EXIT(env, that, _1JS_1GetStringCharsZ_FUNC); - return rc; +#ifndef NO_CALLBACK_1JSNative +extern "C" JNIEXPORT jintLong JNICALL XPCOM_NATIVE(CALLBACK_1JSNative)(JNIEnv *env, jclass that, jintLong arg0); +static jintLong CALLBACK_1JSNative; +static jint proc_CALLBACK_1JSNative(jintLong arg0, jint arg1, jintLong arg2) { + return ((jintLong (CALLING_CONVENTION*)(jintLong, jintLong, jintLong))CALLBACK_1JSNative)(arg0, arg1, arg2); } -#endif - -#ifndef NO__1JS_1TypeOfValue -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1TypeOfValue) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0, jintLong arg1) -{ - jbyte *lpmozillaPath=NULL; - jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1JS_1TypeOfValue_FUNC); - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JS_TypeOfValue(arg0, arg1); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JS_TypeOfValue"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong, jintLong))fp)(arg0, arg1); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JS_TypeOfValue"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong, jintLong))fp)(arg0, arg1); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - XPCOM_NATIVE_EXIT(env, that, _1JS_1TypeOfValue_FUNC); - return rc; +static jintLong CALLBACK_JSNative(jintLong func) { + CALLBACK_1JSNative = func; + return (jintLong)proc_CALLBACK_1JSNative; } -#endif - -#ifndef NO__1JS_1GetStringLength -JNIEXPORT jintLong JNICALL XPCOM_NATIVE(_1JS_1GetStringLength) - (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0) +JNIEXPORT jintLong JNICALL XPCOM_NATIVE(CALLBACK_1JSNative) + (JNIEnv *env, jclass that, jintLong arg0) { - jbyte *lpmozillaPath=NULL; jintLong rc = 0; - XPCOM_NATIVE_ENTER(env, that, _1JS_1GetStringLength_FUNC); - if (mozillaPath) if ((lpmozillaPath = env->GetByteArrayElements(mozillaPath, NULL)) == NULL) goto fail; -/* - rc = (jint)JS_GetStringLength(arg0); -*/ - { - -#ifdef _WIN32 - static int initialized = 0; - static FARPROC fp = NULL; - if (!initialized) { - HMODULE hm = LoadLibrary((const char *)lpmozillaPath); - if (hm) { - fp = GetProcAddress(hm, "JS_GetStringLength"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (*)(jintLong))fp)(arg0); - } -#else -#define CALLING_CONVENTION - static int initialized = 0; - static void *fp = NULL; - if (!initialized) { - void* handle = dlopen((const char *)lpmozillaPath, RTLD_LAZY); - if (handle) { - fp = dlsym(handle, "JS_GetStringLength"); - } - initialized = 1; - } - if (fp) { - rc = (jintLong)((jint (CALLING_CONVENTION*)(jintLong))fp)(arg0); - } -#endif /* _WIN32 */ - } -fail: - if (mozillaPath && lpmozillaPath) env->ReleaseByteArrayElements(mozillaPath, lpmozillaPath, 0); - XPCOM_NATIVE_EXIT(env, that, _1JS_1GetStringLength_FUNC); + XPCOM_NATIVE_ENTER(env, that, CALLBACK_1JSNative_FUNC); + rc = (jintLong)CALLBACK_JSNative(arg0); + XPCOM_NATIVE_EXIT(env, that, CALLBACK_1JSNative_FUNC); return rc; } #endif - - - - #ifndef NO__1NS_1Free JNIEXPORT jint JNICALL XPCOM_NATIVE(_1NS_1Free) (JNIEnv *env, jclass that, jbyteArray mozillaPath, jintLong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.h b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.h index 10cff82b0d..fe1578e76c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.h +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_custom.h @@ -16,4 +16,3 @@ #else #include <dlfcn.h> #endif - diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp index b71434ed85..d0977c1c4e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.cpp @@ -14,9 +14,10 @@ #ifdef NATIVE_STATS -int XPCOM_nativeFunctionCount = 256; -int XPCOM_nativeFunctionCallCount[256]; +int XPCOM_nativeFunctionCount = 251; +int XPCOM_nativeFunctionCallCount[251]; char * XPCOM_nativeFunctionNames[] = { + "CALLBACK_1JSNative", #ifndef JNI64 "_1Call__I", #else @@ -37,16 +38,10 @@ char * XPCOM_nativeFunctionNames[] = { #else "_1Call__JJJ_3BII_3I", #endif - "_1JSVAL_1TO_1IMPL2", "_1JS_1DefineFunction", "_1JS_1EvaluateUCScriptForPrincipals", - "_1JS_1GetGlobalForScopeChain", "_1JS_1GetGlobalObject", - "_1JS_1GetStringCharsZ", - "_1JS_1GetStringLength", "_1JS_1NewObject", - "_1JS_1TypeOfValue", - "_1JS_1ValueToString", "_1NS_1Free", "_1NS_1GetComponentManager", "_1NS_1GetServiceManager", @@ -558,6 +553,11 @@ char * XPCOM_nativeFunctionNames[] = { "_1VtblCall__IJJJJI_3C_3BJJIJI_3J_3J", #endif #ifndef JNI64 + "_1VtblCall__IIJJJJ", +#else + "_1VtblCall__IJJJJJ", +#endif +#ifndef JNI64 "_1VtblCall__IIJJJJIJ_3C_3I_3J", #else "_1VtblCall__IJJJJJIJ_3C_3I_3J", @@ -1120,7 +1120,6 @@ char * XPCOM_nativeFunctionNames[] = { "_1nsID_1new", "_1nsIMemory_1Alloc", "_1nsIMemory_1Realloc", - "_1nsIScriptContext_1GetGlobalObject", "_1nsIScriptContext_1GetNativeContext", "_1nsIScriptGlobalObject_1EnsureScriptEnvironment", "_1nsIScriptGlobalObject_1GetScriptContext", diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h index 954b801cb6..b47b3aecc0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/library/xpcom_stats.h @@ -25,6 +25,7 @@ extern char* XPCOM_nativeFunctionNames[]; #endif typedef enum { + CALLBACK_1JSNative_FUNC, #ifndef JNI64 _1Call__I_FUNC, #else @@ -45,16 +46,10 @@ typedef enum { #else _1Call__JJJ_3BII_3I_FUNC, #endif - _1JSVAL_1TO_1IMPL2_FUNC, _1JS_1DefineFunction_FUNC, _1JS_1EvaluateUCScriptForPrincipals_FUNC, - _1JS_1GetGlobalForScopeChain_FUNC, _1JS_1GetGlobalObject_FUNC, - _1JS_1GetStringCharsZ_FUNC, - _1JS_1GetStringLength_FUNC, _1JS_1NewObject_FUNC, - _1JS_1TypeOfValue_FUNC, - _1JS_1ValueToString_FUNC, _1NS_1Free_FUNC, _1NS_1GetComponentManager_FUNC, _1NS_1GetServiceManager_FUNC, @@ -566,6 +561,11 @@ typedef enum { _1VtblCall__IJJJJI_3C_3BJJIJI_3J_3J_FUNC, #endif #ifndef JNI64 + _1VtblCall__IIJJJJ_FUNC, +#else + _1VtblCall__IJJJJJ_FUNC, +#endif +#ifndef JNI64 _1VtblCall__IIJJJJIJ_3C_3I_3J_FUNC, #else _1VtblCall__IJJJJJIJ_3C_3I_3J_FUNC, @@ -1128,7 +1128,6 @@ typedef enum { _1nsID_1new_FUNC, _1nsIMemory_1Alloc_FUNC, _1nsIMemory_1Realloc_FUNC, - _1nsIScriptContext_1GetGlobalObject_FUNC, _1nsIScriptContext_1GetNativeContext_FUNC, _1nsIScriptGlobalObject_1EnsureScriptEnvironment_FUNC, _1nsIScriptGlobalObject_1GetScriptContext_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/External.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/External.java index 1a85443bc0..54e3385f50 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/External.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/External.java @@ -11,8 +11,6 @@ package org.eclipse.swt.browser; -import java.io.UnsupportedEncodingException; - import org.eclipse.swt.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.mozilla.*; @@ -29,13 +27,11 @@ class External { XPCOMObject classInfo; XPCOMObject securityCheckedComponent; XPCOMObject scriptObjectOwner; - XPCOMObject xpcScriptable; int refCount = 0; static Callback CallJavaProc; - static { - CallJavaProc = new Callback (External.class, "CallJava", 3); //$NON-NLS-1$ + CallJavaProc = new Callback (External.class, "callJava", 3); //$NON-NLS-1$ if (CallJavaProc.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); } @@ -43,12 +39,18 @@ External () { createCOMInterfaces (); } -int AddRef () { - refCount++; - return refCount; -} +/* external */ + +/* + * This is the BrowserFunction entry point for XULRunner releases >= 4 because + * QueryInterface answers an nsIScriptObjectOwner implementation (which points + * at this function) iff the detected XULRunner version is >= 4. + */ +static int /*long*/ callJava (int /*long*/ cx, int /*long*/ argc, int /*long*/ vp) { + int jsval_sizeof = 8; + int /*long*/ argsPtr = vp + 2 * jsval_sizeof; + nsIVariant resultVariant = null; -static int /*long*/ CallJava (int /*long*/ cx, int /*long*/ argc, int /*long*/ vp) { int /*long*/[] result = new int /*long*/[1]; int rc = XPCOM.NS_GetServiceManager (result); if (rc != XPCOM.NS_OK) Mozilla.error (rc); @@ -56,100 +58,374 @@ static int /*long*/ CallJava (int /*long*/ cx, int /*long*/ argc, int /*long*/ v nsIServiceManager serviceManager = new nsIServiceManager (result[0]); result[0] = 0; - //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, "@mozilla.org/js/xpc/XPConnect;1", true); - nsID NS_IXPCONNECT_CID = new nsID ("CB6593E0-F9B2-11d2-BDD6-000064657374"); - nsID NS_IXPCONNECT_IID = new nsID ("a995b541-d514-43f1-ac0e-f49746c0b063"); - rc = serviceManager.GetService(NS_IXPCONNECT_CID, NS_IXPCONNECT_IID, result); - nsIXPConnect connect = new nsIXPConnect(result[0]); - result[0] = 0; - - - //int /*long*/[] result = new int /*long*/[1]; - XPCOM.memmove(result, vp + 2 * C.PTR_SIZEOF, C.PTR_SIZEOF); - int /*long*/ arrayPtr = result[0]; + rc = serviceManager.GetService (XPCOM.NS_IXPCONNECT_CID, nsIXPConnect.NS_IXPCONNECT_IID, result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + + nsIXPConnect connect = new nsIXPConnect (result[0]); result[0] = 0; - - XPCOM.memmove(result, arrayPtr, C.PTR_SIZEOF); - int /*long*/ args = result[0]; + + /* extract the first argument value (the function id) */ + rc = connect.JSValToVariant (cx, argsPtr, result); + if (rc == XPCOM.NS_OK && result[0] != 0) { + nsIVariant idVariant = new nsIVariant (result[0]); + result[0] = 0; + short[] dataType = new short[1]; + rc = idVariant.GetDataType (dataType); + if (rc == XPCOM.NS_OK && dataType[0] == nsIDataType.VTYPE_INT32) { + int[] intResult = new int[1]; + rc = idVariant.GetAsInt32 (intResult); /* PRInt32 */ + if (rc == XPCOM.NS_OK) { + int functionId = (int)intResult[0]; + + /* get the second argument variant (the token string) */ + argsPtr += jsval_sizeof; + rc = connect.JSValToVariant (cx, argsPtr, result); + if (rc == XPCOM.NS_OK && result[0] != 0) { + int /*long*/ tokenVariant = result[0]; + result[0] = 0; + + /* get the third argument variant (the invocation args) */ + argsPtr += jsval_sizeof; + rc = connect.JSValToVariant (cx, argsPtr, result); + if (rc == XPCOM.NS_OK && result[0] != 0) { + int /*long*/ argsVariant = result[0]; + result[0] = 0; + + /* invoke the BrowserFunction */ + resultVariant = new nsIVariant (invokeFunction (functionId, tokenVariant, argsVariant)); + new nsISupports (argsVariant).Release (); + } + new nsISupports (tokenVariant).Release (); + } + } + } + idVariant.Release (); + } result[0] = 0; - int /*long*/ asdf4 = XPCOM.JSVAL_TO_IMPL2(Mozilla.jsLibPathBytes, arrayPtr); - System.out.println(asdf4); - asdf4 = XPCOM.JSVAL_TO_IMPL2(Mozilla.jsLibPathBytes, args); - System.out.println(asdf4); + /* if the BrowserFunction could not be invoked for some reason then return null to JS */ + if (resultVariant == null) { + rc = XPCOM.NS_GetComponentManager (result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + nsIComponentManager componentManager = new nsIComponentManager (result[0]); + result[0] = 0; + resultVariant = convertToJS (null, componentManager); + componentManager.Release (); + } - int /*long*/ type2 = XPCOM.JS_TypeOfValue(Mozilla.jsLibPathBytes, cx, args); - System.out.println(type2); - int /*long*/ stringPtr = XPCOM.JS_ValueToString(Mozilla.jsLibPathBytes, cx, args); - int length = (int)XPCOM.JS_GetStringLength(Mozilla.jsLibPathBytes, stringPtr); - int /*long*/ nativePtr = XPCOM.JS_GetStringCharsZ(Mozilla.jsLibPathBytes, cx, stringPtr); - char[] dest = new char[length]; - XPCOM.memmove (dest, nativePtr, length * 2); - System.out.println(new String (dest)); - - - args += C.PTR_SIZEOF; - type2 = XPCOM.JS_TypeOfValue(Mozilla.jsLibPathBytes, cx, args); - System.out.println(type2); - stringPtr = XPCOM.JS_ValueToString(Mozilla.jsLibPathBytes, cx, args); - length = (int)XPCOM.JS_GetStringLength(Mozilla.jsLibPathBytes, stringPtr); - nativePtr = XPCOM.JS_GetStringCharsZ(Mozilla.jsLibPathBytes, cx, stringPtr); - dest = new char[length]; - XPCOM.memmove (dest, nativePtr, length * 2); - System.out.println(new String (dest)); - - args += C.PTR_SIZEOF; - type2 = XPCOM.JS_TypeOfValue(Mozilla.jsLibPathBytes, cx, args); - System.out.println(type2); - stringPtr = XPCOM.JS_ValueToString(Mozilla.jsLibPathBytes, cx, args); - length = (int)XPCOM.JS_GetStringLength(Mozilla.jsLibPathBytes, stringPtr); - nativePtr = XPCOM.JS_GetStringCharsZ(Mozilla.jsLibPathBytes, cx, stringPtr); - dest = new char[length]; - XPCOM.memmove (dest, nativePtr, length * 2); - System.out.println(new String (dest)); - - rc = connect.JSValToVariant(cx, args, result); - nsIVariant variant = new nsIVariant(result[0]); - short[] type = new short[1]; - rc = variant.GetDataType(type); - Object asdf = convertToJava(variant, type[0]); - System.out.println(asdf); - - Object functionId = convertToJava(args); - args += C.PTR_SIZEOF; - Object token = convertToJava(args); - - for (int i = 0; i < argc; i++) { - + /* convert the resulting variant to a jsval */ + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release(); + + nsIMemory memory = new nsIMemory (result[0]); + result[0] = 0; + int /*long*/ jsVal = memory.Alloc (jsval_sizeof); + C.memset (jsVal, 0, jsval_sizeof); + int /*long*/ globalObject = XPCOM.JS_GetGlobalObject (Mozilla.getJSLibPathBytes (), cx); + rc = connect.VariantToJS (cx, globalObject, resultVariant.getAddress (), jsVal); + resultVariant.Release (); + connect.Release (); + + int /*long*/ returnValue = XPCOM.JS_FALSE; + if (rc == XPCOM.NS_OK) { + /* write the jsval to the return value slot */ + C.memmove (vp, jsVal, jsval_sizeof); + returnValue = XPCOM.JS_TRUE; } + memory.Free (jsVal); + memory.Release (); + return returnValue; +} - return 0; +/* this is the BrowserFunction entry point when the detected XULRunner version is < 4 */ +static int callJava (int functionId, int /*long*/ tokenVariant, int /*long*/ argsVariant, int /*long*/ returnPtr) { + int /*long*/ resultVariant = invokeFunction (functionId, tokenVariant, argsVariant); + C.memmove (returnPtr, new int /*long*/[] {resultVariant}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +static Object convertToJava (nsIVariant variant, short type) { + switch (type) { + case nsIDataType.VTYPE_EMPTY: + case nsIDataType.VTYPE_VOID: + return null; + case nsIDataType.VTYPE_EMPTY_ARRAY: + return new Object[0]; + case nsIDataType.VTYPE_BOOL: + int[] boolResult = new int[1]; /*PRInt32*/ + int rc = variant.GetAsBool (boolResult); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return new Boolean (boolResult[0] != 0); + case nsIDataType.VTYPE_INT32: + int[] intResult = new int[1]; /*PRInt32*/ + rc = variant.GetAsInt32 (intResult); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return new Double (intResult[0]); + case nsIDataType.VTYPE_DOUBLE: + int /*long*/ doubleReturn = C.malloc (8); + rc = variant.GetAsDouble (doubleReturn); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + double[] doubleResult = new double[1]; + C.memmove (doubleResult, doubleReturn, 8); + C.free (doubleReturn); + return new Double (doubleResult[0]); + case nsIDataType.VTYPE_WSTRING_SIZE_IS: + int[] size = new int[1]; /* PRInt32 */ + int /*long*/[] wString = new int /*long*/[1]; + rc = variant.GetAsWStringWithSize (size, wString); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + char[] chars = new char[size[0]]; + C.memmove (chars, wString[0], size[0] * 2); + return new String (chars); + case nsIDataType.VTYPE_ARRAY: + Object[] arrayReturn = new Object[0]; + int /*long*/ iid = C.malloc (nsID.sizeof); + C.memset (iid, 0, nsID.sizeof); + int[] count = new int[1]; /* PRUint32 */ + short[] currentType = new short[1]; + int /*long*/[] ptr = new int /*long*/[1]; + rc = variant.GetAsArray (currentType, iid, count, ptr); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (ptr[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); + nsID id = new nsID (); + XPCOM.memmove (id, iid, nsID.sizeof); + C.free (iid); + + int /*long*/[] result = new int /*long*/[1]; + rc = XPCOM.NS_GetServiceManager (result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + + nsIServiceManager serviceManager = new nsIServiceManager (result[0]); + result[0] = 0; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); + rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + serviceManager.Release (); + + nsIMemory memory = new nsIMemory (result[0]); + result[0] = 0; + + if (id.Equals (nsIVariant.NS_IVARIANT_IID) || id.Equals (nsIVariant.NS_IVARIANT_10_IID)) { + arrayReturn = new Object[count[0]]; + for (int i = 0; i < count[0]; i++) { + int /*long*/[] arrayPtr = new int /*long*/[1]; + C.memmove (arrayPtr, ptr[0] + i * C.PTR_SIZEOF, C.PTR_SIZEOF); + nsISupports supports = new nsISupports (arrayPtr[0]); + rc = supports.QueryInterface (id, result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + + nsIVariant currentVariant = new nsIVariant (result[0]); + result[0] = 0; + currentType[0] = 0; + rc = currentVariant.GetDataType (currentType); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + try { + arrayReturn[i] = convertToJava (currentVariant, currentType[0]); + currentVariant.Release (); + } catch (IllegalArgumentException e) { + /* invalid argument value type */ + currentVariant.Release (); + memory.Free (ptr[0]); + memory.Release (); + throw e; + } + } + } else { + switch (currentType[0]) { + case nsIDataType.VTYPE_DOUBLE: + arrayReturn = new Object[count[0]]; + for (int i = 0; i < count[0]; i++) { + double[] doubleValue = new double[1]; + C.memmove (doubleValue, ptr[0] + i * 8, 8); + arrayReturn[i] = new Double (doubleValue[0]); + } + break; + case nsIDataType.VTYPE_BOOL: + arrayReturn = new Object[count[0]]; + for (int i = 0; i < count[0]; i++) { + int[] boolValue = new int[1]; /* PRUInt32 */ + C.memmove (boolValue, ptr[0] + i * 4, 4); + arrayReturn[i] = new Boolean (boolValue[0] != 0); + } + break; + case nsIDataType.VTYPE_INT32: + arrayReturn = new Object[count[0]]; + for (int i = 0; i < count[0]; i++) { + int[] intValue = new int[1]; /* PRInt32 */ + C.memmove (intValue, ptr[0] + i * 4, 4); + arrayReturn[i] = new Double (intValue[0]); + } + break; + case nsIDataType.VTYPE_WCHAR_STR: + arrayReturn = new Object[count[0]]; + for (int i = 0; i < count[0]; i++) { + int /*long*/ currentPtr = ptr[0] + i * C.PTR_SIZEOF; + int /*long*/[] stringPtr = new int /*long*/[1]; + C.memmove (stringPtr, currentPtr, C.PTR_SIZEOF); + int length = XPCOM.strlen_PRUnichar (stringPtr[0]); + char[] dest = new char[length]; + XPCOM.memmove (dest, stringPtr[0], length * 2); + arrayReturn[i] = new String (dest); + } + break; + default: + memory.Free (ptr[0]); + memory.Release (); + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + } + memory.Free (ptr[0]); + memory.Release (); + return arrayReturn; + } + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + return null; } -static Object convertToJava(int /*long*/ jsVal) { - /* -typedef uint8 JSValueType; -#define JSVAL_TYPE_DOUBLE ((uint8)0x00) -#define JSVAL_TYPE_INT32 ((uint8)0x01) -#define JSVAL_TYPE_UNDEFINED ((uint8)0x02) -#define JSVAL_TYPE_BOOLEAN ((uint8)0x03) -#define JSVAL_TYPE_MAGIC ((uint8)0x04) -#define JSVAL_TYPE_STRING ((uint8)0x05) -#define JSVAL_TYPE_NULL ((uint8)0x06) -#define JSVAL_TYPE_OBJECT ((uint8)0x07) -#define JSVAL_TYPE_UNKNOWN ((uint8)0x20) -#define JSVAL_TYPE_NONFUNOBJ ((uint8)0x57) -#define JSVAL_TYPE_FUNOBJ ((uint8)0x67) -#define JSVAL_TYPE_STRORNULL ((uint8)0x77) -#define JSVAL_TYPE_OBJORNULL ((uint8)0x78) -#define JSVAL_TYPE_BOXED ((uint8)0x79) -#define JSVAL_TYPE_UNINITIALIZED ((uint8)0x7d) - -jsval_layout PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) - - */ +static nsIVariant convertToJS (Object value, nsIComponentManager componentManager) { + int /*long*/[] result = new int /*long*/[1]; + byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_VARIANT_CONTRACTID, true); + int rc = componentManager.CreateInstanceByContractID (aContractID, 0, nsIWritableVariant.NS_IWRITABLEVARIANT_IID, result); + nsIWritableVariant variant = new nsIWritableVariant (result[0]); + result[0] = 0; + + if (value == null) { + rc = variant.SetAsEmpty (); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return variant; + } + if (value instanceof String) { + String stringValue = (String)value; + int length = stringValue.length (); + char[] chars = new char[length]; + stringValue.getChars (0, length, chars, 0); + rc = variant.SetAsWStringWithSize (length, chars); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return variant; + } + if (value instanceof Boolean) { + Boolean booleanValue = (Boolean)value; + rc = variant.SetAsBool (booleanValue.booleanValue () ? 1 : 0); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return variant; + } + if (value instanceof Number) { + Number numberValue = (Number)value; + rc = variant.SetAsDouble (numberValue.doubleValue ()); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + return variant; + } + if (value instanceof Object[]) { + Object[] arrayValue = (Object[])value; + int length = arrayValue.length; + if (length == 0) { + rc = variant.SetAsEmptyArray (); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + } else { + int /*long*/ arrayPtr = C.malloc (C.PTR_SIZEOF * length); + for (int i = 0; i < length; i++) { + Object currentObject = arrayValue[i]; + try { + nsIVariant currentVariant = convertToJS (currentObject, componentManager); + C.memmove (arrayPtr + C.PTR_SIZEOF * i, new int /*long*/[] {currentVariant.getAddress ()}, C.PTR_SIZEOF); + } catch (SWTException e) { + /* invalid return value type */ + C.free (arrayPtr); + variant.Release (); + /* release the variants that had previously been added to the array */ + for (int j = 0; j < i; j++) { + int /*long*/[] ptr = new int /*long*/[1]; + C.memmove (ptr, arrayPtr + C.PTR_SIZEOF * j, C.PTR_SIZEOF); + new nsISupports (ptr[0]).Release (); + } + throw e; + } + } + int /*long*/ idPtr = C.malloc (nsID.sizeof); + XPCOM.memmove (idPtr, Mozilla.IsPre_4 ? nsIVariant.NS_IVARIANT_IID : nsIVariant.NS_IVARIANT_10_IID, nsID.sizeof); + rc = variant.SetAsArray (nsIDataType.VTYPE_INTERFACE_IS, idPtr, length, arrayPtr); + C.free (idPtr); + C.free (arrayPtr); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + } + return variant; + } + + variant.Release (); + SWT.error (SWT.ERROR_INVALID_RETURN_VALUE); return null; - +} + +static int /*long*/ invokeFunction (int functionId, int /*long*/ tokenVariant, int /*long*/ args) { + Object key = new Integer (functionId); + BrowserFunction function = (BrowserFunction)Mozilla.AllFunctions.get (key); + Object returnValue = null; + + if (function != null) { + try { + short[] type = new short[1]; /* PRUint16 */ + nsIVariant variant = new nsIVariant (tokenVariant); + int rc = variant.GetDataType (type); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + Object temp = convertToJava (variant, type[0]); + type[0] = 0; + if (temp instanceof String) { + String token = (String)temp; + if (token.equals (function.token)) { + variant = new nsIVariant (args); + rc = variant.GetDataType (type); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + temp = convertToJava (variant, type[0]); + if (temp instanceof Object[]) { + Object[] arguments = (Object[])temp; + try { + returnValue = function.function (arguments); + } catch (Exception e) { + /* exception during function invocation */ + returnValue = WebBrowser.CreateErrorString (e.getLocalizedMessage ()); + } + } + } + } + } catch (IllegalArgumentException e) { + /* invalid argument value type */ + if (function.isEvaluate) { + /* notify the evaluate function so that a java exception can be thrown */ + function.function (new String[] {WebBrowser.CreateErrorString (new SWTException (SWT.ERROR_INVALID_RETURN_VALUE).getLocalizedMessage ())}); + } + returnValue = WebBrowser.CreateErrorString (e.getLocalizedMessage ()); + } + } + + int /*long*/[] result = new int /*long*/[1]; + int rc = XPCOM.NS_GetComponentManager (result); + if (rc != XPCOM.NS_OK) Mozilla.error (rc); + if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); + nsIComponentManager componentManager = new nsIComponentManager (result[0]); + result[0] = 0; + nsIVariant variant; + try { + variant = convertToJS (returnValue, componentManager); + } catch (SWTException e) { + /* invalid return value type */ + variant = convertToJS (WebBrowser.CreateErrorString (e.getLocalizedMessage ()), componentManager); + } + componentManager.Release (); + + return variant.getAddress (); +} + +int AddRef () { + refCount++; + return refCount; } void createCOMInterfaces () { @@ -195,170 +471,9 @@ void createCOMInterfaces () { public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) { - // int /*long*/ globalObject = XPCOM.nsIScriptContext_GetGlobalObject(args[0]); - int /*long*/ nativeContext = XPCOM.nsIScriptContext_GetNativeContext (args[0]); - if (Mozilla.jsLibPathBytes == null) { - String mozillaPath = Mozilla.getMozillaPath () + MozillaDelegate.getJSLibraryName() + '\0'; - try { - Mozilla.jsLibPathBytes = mozillaPath.getBytes ("UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - Mozilla.jsLibPathBytes = mozillaPath.getBytes (); - } - } - int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (Mozilla.jsLibPathBytes, nativeContext); - int /*long*/ globalJSObject1 = XPCOM.JS_GetGlobalObject (Mozilla.jsLibPathBytes, args[0]); - int /*long*/ globalJSObject2 = XPCOM.JS_GetGlobalForScopeChain (Mozilla.jsLibPathBytes, nativeContext); -// int /*long*/ globalJSObject3 = XPCOM.JS_GetGlobalForScopeChain (Mozilla.jsLibPathBytes, args[0]); - int /*long*/ newObject = XPCOM.JS_NewObject(Mozilla.jsLibPathBytes, nativeContext, 0, 0, globalJSObject); - - byte[] functionName = MozillaDelegate.wcsToMbcs(null, "callJava", true); - int /*long*/ newFunction = XPCOM.JS_DefineFunction(Mozilla.jsLibPathBytes, nativeContext, newObject, functionName, CallJavaProc.getAddress(), 3, /*JSPROP_ENUMERATE*/ 0x1 | /*JSPROP_READONLY*/ 0x2 | /*JSPROP_PERMANENT*/ 0x4); - System.out.println(newFunction); - - XPCOM.memmove(args[1], new int /*long*/[] {newObject}, C.PTR_SIZEOF); - return XPCOM.NS_OK; - } - public int /*long*/ method4 (int /*long*/[] args) { - return XPCOM.NS_OK; - // return SetScriptObject (args[0]);} - } - }; - - xpcScriptable = new XPCOMObject (new int[] {2, 0, 0, 1, 1, 4, 3, 3, 6, 6, 6, 6, 4, 7, 7, 6, 3, 7, 7, 7, 6, 3, 5, 4, 2}) { - public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);} - public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();} - public int /*long*/ method2 (int /*long*/[] args) {return Release ();} - public int /*long*/ method3 (int /*long*/[] args) { - int /*long*/[] result = new int /*long*/[1]; - int rc = XPCOM.NS_GetServiceManager (result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - - nsIServiceManager serviceManager = new nsIServiceManager (result[0]); - result[0] = 0; - byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); - rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - serviceManager.Release (); - - nsIMemory memory = new nsIMemory (result[0]); - result[0] = 0; - byte[] bytes = MozillaDelegate.wcsToMbcs (null, "External", true); //$NON-NLS-1$ - int /*long*/ ptr = memory.Alloc (bytes.length); - C.memmove (ptr, bytes, bytes.length); - C.memmove(args[0], new int /*long*/[] {ptr}, C.PTR_SIZEOF); - return XPCOM.NS_OK;} - public int /*long*/ method4 (int /*long*/[] args) { - System.out.println("Get scriptable flags"); - XPCOM.memmove(args[0], new int[] {/*WANT_NEWRESOLVE 512 |*/ /* WANT_GETPROPERTY */ 32 | /* WANT_CALL */ 8192}, 4); - // XPCOM.memmove(args[0], new int[] {0xFFFF}, 4); - return XPCOM.NS_OK;} - public int /*long*/ method5 (int /*long*/[] args) { - System.out.println("pre-create"); - return XPCOM.NS_OK;} - public int /*long*/ method6 (int /*long*/[] args) { - System.out.println("create"); - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method7 (int /*long*/[] args) { - System.out.println("post-create"); - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method8 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method9 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method10 (int /*long*/[] args) { - System.out.println("Get property"); -// int /*long*/ nativeContext = XPCOM.nsIScriptContext_GetNativeContext (args[0]); - if (Mozilla.jsLibPathBytes == null) { - String mozillaPath = Mozilla.getMozillaPath () + MozillaDelegate.getJSLibraryName() + '\0'; - try { - Mozilla.jsLibPathBytes = mozillaPath.getBytes ("UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - Mozilla.jsLibPathBytes = mozillaPath.getBytes (); - } - } -// int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (Mozilla.jsLibPathBytes, nativeContext); -// int /*long*/ newObject = XPCOM.JS_NewObject(Mozilla.jsLibPathBytes, nativeContext, 0, 0, globalJSObject); - - int /*long*/ stringPtr = XPCOM.JS_ValueToString(Mozilla.jsLibPathBytes, args[1], args[3]); - int /*long*/ stringLength = XPCOM.JS_GetStringLength(Mozilla.jsLibPathBytes, stringPtr); - int /*long*/ nativePtr = XPCOM.JS_GetStringCharsZ(Mozilla.jsLibPathBytes, args[1], stringPtr); - - int length = XPCOM.strlen_PRUnichar (nativePtr); - char[] dest = new char[length]; - XPCOM.memmove (dest, nativePtr, length * 2); - System.out.println(new String (dest)); - - - - byte[] functionName = MozillaDelegate.wcsToMbcs(null, "callJava", true); - int /*long*/ newFunction = XPCOM.JS_DefineFunction(Mozilla.jsLibPathBytes, /*nativeContext*/args[1], /*newObject*/args[2], functionName, CallJavaProc.getAddress(), 3, /*JSPROP_ENUMERATE*/ 0x1 | /*JSPROP_READONLY*/ 0x2 | /*JSPROP_PERMANENT*/ 0x4); - System.out.println(newFunction); - - return /* PR_TRUE */ 1;} - - public int /*long*/ method11 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method12 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method13 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method14 (int /*long*/[] args) { - System.out.println("New Resolve"); - - int /*long*/ nativeContext = XPCOM.nsIScriptContext_GetNativeContext (args[0]); - if (Mozilla.jsLibPathBytes == null) { - String mozillaPath = Mozilla.getMozillaPath () + MozillaDelegate.getJSLibraryName() + '\0'; - try { - Mozilla.jsLibPathBytes = mozillaPath.getBytes ("UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - Mozilla.jsLibPathBytes = mozillaPath.getBytes (); - } - } - - int /*long*/ stringPtr = XPCOM.JS_ValueToString(Mozilla.jsLibPathBytes, /*args[1]*/nativeContext, args[3]); - int /*long*/ stringLength = XPCOM.JS_GetStringLength(Mozilla.jsLibPathBytes, stringPtr); - int /*long*/ nativePtr = XPCOM.JS_GetStringCharsZ(Mozilla.jsLibPathBytes, /*args[1]*/nativeContext, stringPtr); - - int length = XPCOM.strlen_PRUnichar (nativePtr); - char[] dest = new char[length]; - XPCOM.memmove (dest, nativePtr, length /** 2*/); - System.out.println(new String (dest)); - -// int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (Mozilla.jsLibPathBytes, nativeContext); -// int /*long*/ newObject = XPCOM.JS_NewObject(Mozilla.jsLibPathBytes, nativeContext, 0, 0, globalJSObject); - - byte[] functionName = MozillaDelegate.wcsToMbcs(null, "callJava", true); - int /*long*/ newFunction = XPCOM.JS_DefineFunction(Mozilla.jsLibPathBytes, /*nativeContext*/args[1], /*newObject*/args[2], functionName, CallJavaProc.getAddress(), 3, /*JSPROP_ENUMERATE*/ 0x1 | /*JSPROP_READONLY*/ 0x2 | /*JSPROP_PERMANENT*/ 0x4); - System.out.println(newFunction); - - XPCOM.memmove(args[5], new int /*long*/[] {args[2]}, C.PTR_SIZEOF); - return /* PR_TRUE */ 1;} - public int /*long*/ method15 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method16 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method17 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method18 (int /*long*/[] args) { - System.out.println("Call"); - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method19 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method20 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method21 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method22 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method23 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} - public int /*long*/ method24 (int /*long*/[] args) { - return XPCOM.NS_ERROR_NOT_IMPLEMENTED;} + public int /*long*/ method3 (int /*long*/[] args) {return getScriptObject (args[0], args[1]);} + public int /*long*/ method4 (int /*long*/[] args) {return setScriptObject (args[0]);} }; - } void disposeCOMInterfaces () { @@ -382,59 +497,34 @@ int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) { XPCOM.memmove (guid, riid, nsID.sizeof); if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) { - System.out.println("QI'd for nsISupports"); XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF); AddRef(); return XPCOM.NS_OK; } if (guid.Equals (nsIClassInfo.NS_ICLASSINFO_IID)) { - System.out.println("QI'd for nsIClassInfo"); XPCOM.memmove (ppvObject, new int /*long*/[] {classInfo.getAddress ()}, C.PTR_SIZEOF); AddRef(); return XPCOM.NS_OK; } - if (guid.Equals (nsISecurityCheckedComponent.NS_ISECURITYCHECKEDCOMPONENT_IID)) { - System.out.println("QI'd for nsISecurityCheckedComponent"); + if (guid.Equals (XPCOM.NS_ISECURITYCHECKEDCOMPONENT_IID)) { XPCOM.memmove (ppvObject, new int /*long*/[] {securityCheckedComponent.getAddress ()}, C.PTR_SIZEOF); AddRef(); return XPCOM.NS_OK; } if (guid.Equals (EXTERNAL_IID)) { - System.out.println("QI'd for EXTERNAL_IID"); XPCOM.memmove (ppvObject, new int /*long*/[] {external.getAddress ()}, C.PTR_SIZEOF); AddRef(); return XPCOM.NS_OK; } if (!Mozilla.IsPre_4) { - nsID NS_ISCRIPT_OBJECT_OWNER_IID = new nsID("8f6bca7e-ce42-11d1-b724-00600891d8c9"); - if (guid.Equals(NS_ISCRIPT_OBJECT_OWNER_IID)) { - System.out.println("QI'd for NS_ISCRIPT_OBJECT_OWNER"); + if (guid.Equals(XPCOM.NS_ISCRIPTOBJECTOWNER_IID)) { XPCOM.memmove (ppvObject, new int /*long*/[] {scriptObjectOwner.getAddress ()}, C.PTR_SIZEOF); AddRef(); return XPCOM.NS_OK; } } - -// nsID NS_ASDF_IID = new nsID("3eedba38-8d22-41e1-817a-0e43e165b664"); -// if (guid.Equals (NS_ASDF_IID)) { -// System.out.println("QI'd for nsIScriptObjectPrincipal"); -// XPCOM.memmove (ppvObject, new int /*long*/[] {external.getAddress ()}, C.PTR_SIZEOF); -// AddRef(); -// return XPCOM.NS_OK; -// } - -// if (!Mozilla.IsPre_4) { -// nsID nsIXPCScriptable_IID = new nsID("a40ce52e-2d8c-400f-9af2-f8784a656070"); -// if (guid.Equals (nsIXPCScriptable_IID)) { -// System.out.println("QI'd for nsIXPCScriptable_IID"); -// XPCOM.memmove (ppvObject, new int /*long*/[] {xpcScriptable.getAddress ()}, C.PTR_SIZEOF); -// AddRef(); -// return XPCOM.NS_OK; -// } -// } - - System.out.println("no answer for: " + guid.toString()); + XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF); return XPCOM.NS_ERROR_NO_INTERFACE; } @@ -485,7 +575,7 @@ int getContractID (int /*long*/ _retValue) { } int getFlags (int /*long*/ flags) { - C.memmove (flags, new int[] {nsIClassInfo.THREADSAFE/*MAIN_THREAD_ONLY*/}, 4); /* PRUint32 */ + C.memmove (flags, new int[] {nsIClassInfo.MAIN_THREAD_ONLY}, 4); /* PRUint32 */ return XPCOM.NS_OK; } @@ -495,14 +585,11 @@ int getHelperForLanguage (int language, int /*long*/ _retValue) { } int getImplementationLanguage (int /*long*/ _retValue) { - C.memmove (_retValue, new int[] {5}, 4); /* nsIProgrammingLanguage.JAVA */ /* PRUint */ // nsIProgrammingLanguage::CPLUSPLUS + C.memmove (_retValue, new int[] {5}, 4); /* nsIProgrammingLanguage.JAVA */ /* PRUint */ return XPCOM.NS_OK; } - int getInterfaces (int /*long*/ count, int /*long*/ array) { - //C.memset(6, 6, 6); - System.out.println("---------------------------"); int /*long*/[] result = new int /*long*/[1]; int rc = XPCOM.NS_GetServiceManager (result); if (rc != XPCOM.NS_OK) Mozilla.error (rc); @@ -519,7 +606,7 @@ int getInterfaces (int /*long*/ count, int /*long*/ array) { nsIMemory memory = new nsIMemory (result[0]); result[0] = 0; int /*long*/ securityCheckedComponentIID = memory.Alloc (nsID.sizeof); - XPCOM.memmove (securityCheckedComponentIID, nsISecurityCheckedComponent.NS_ISECURITYCHECKEDCOMPONENT_IID, nsID.sizeof); + XPCOM.memmove (securityCheckedComponentIID, XPCOM.NS_ISECURITYCHECKEDCOMPONENT_IID, nsID.sizeof); int /*long*/ externalIID = memory.Alloc (nsID.sizeof); XPCOM.memmove (externalIID, EXTERNAL_IID, nsID.sizeof); int /*long*/ ptrArray = memory.Alloc (3 * C.PTR_SIZEOF); @@ -530,8 +617,7 @@ int getInterfaces (int /*long*/ count, int /*long*/ array) { int /*long*/ asdfIID = memory.Alloc (nsID.sizeof); XPCOM.memmove (asdfIID, NS_ASDF_IID, nsID.sizeof); C.memmove (ptrArray + 2 * C.PTR_SIZEOF, new int /*long*/[] {asdfIID}, C.PTR_SIZEOF); - - + C.memmove (array, new int /*long*/[] {ptrArray}, C.PTR_SIZEOF); memory.Release (); @@ -539,6 +625,25 @@ int getInterfaces (int /*long*/ count, int /*long*/ array) { return XPCOM.NS_OK; } +/* nsIScriptObjectOwner */ + +int getScriptObject (int /*long*/ aContext, int /*long*/ aScriptObject) { + byte[] jsLibPath = Mozilla.getJSLibPathBytes (); + int /*long*/ nativeContext = XPCOM.nsIScriptContext_GetNativeContext (aContext); + int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (jsLibPath, nativeContext); + int /*long*/ newObject = XPCOM.JS_NewObject (jsLibPath, nativeContext, 0, 0, globalJSObject); + + byte[] functionName = MozillaDelegate.wcsToMbcs (null, "callJava", true); //$NON-NLS-1$ + int flags = XPCOM.JSPROP_ENUMERATE | XPCOM.JSPROP_READONLY | XPCOM.JSPROP_PERMANENT; + XPCOM.JS_DefineFunction (jsLibPath, nativeContext, newObject, functionName, XPCOM.CALLBACK_JSNative (CallJavaProc.getAddress ()), 3, flags); + XPCOM.memmove (aScriptObject, new int /*long*/[] {newObject}, C.PTR_SIZEOF); + return XPCOM.NS_OK; +} + +int setScriptObject (int /*long*/ aScriptObject) { + return XPCOM.NS_COMFALSE; +} + /* nsISecurityCheckedComponent */ int canCreateWrapper (int /*long*/ iid, int /*long*/ _retVal) { @@ -650,280 +755,4 @@ int canSetProperty (int /*long*/ iid, int /*long*/ propertyName, int /*long*/ _r return XPCOM.NS_OK; } -/* external */ - -static Object convertToJava (nsIVariant variant, short type) { - switch (type) { - case nsIDataType.VTYPE_EMPTY: - case nsIDataType.VTYPE_VOID: - return null; - case nsIDataType.VTYPE_EMPTY_ARRAY: - return new Object[0]; - case nsIDataType.VTYPE_BOOL: - int[] boolResult = new int[1]; /*PRInt32*/ - int rc = variant.GetAsBool (boolResult); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return new Boolean (boolResult[0] != 0); - case nsIDataType.VTYPE_INT32: - int[] intResult = new int[1]; /*PRInt32*/ - rc = variant.GetAsInt32 (intResult); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return new Double (intResult[0]); - case nsIDataType.VTYPE_DOUBLE: - int /*long*/ doubleReturn = C.malloc (8); - rc = variant.GetAsDouble (doubleReturn); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - double[] doubleResult = new double[1]; - C.memmove (doubleResult, doubleReturn, 8); - C.free (doubleReturn); - return new Double (doubleResult[0]); - case nsIDataType.VTYPE_WSTRING_SIZE_IS: - int[] size = new int[1]; /* PRInt32 */ - int /*long*/[] wString = new int /*long*/[1]; - rc = variant.GetAsWStringWithSize (size, wString); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - char[] chars = new char[size[0]]; - C.memmove (chars, wString[0], size[0] * 2); - return new String (chars); - case nsIDataType.VTYPE_ARRAY: - Object[] arrayReturn = new Object[0]; - int /*long*/ iid = C.malloc (nsID.sizeof); - C.memset (iid, 0, nsID.sizeof); - int[] count = new int[1]; /* PRUint32 */ - short[] currentType = new short[1]; - int /*long*/[] ptr = new int /*long*/[1]; - rc = variant.GetAsArray (currentType, iid, count, ptr); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (ptr[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); - nsID id = new nsID (); - XPCOM.memmove (id, iid, nsID.sizeof); - C.free (iid); - - int /*long*/[] result = new int /*long*/[1]; - rc = XPCOM.NS_GetServiceManager (result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - - nsIServiceManager serviceManager = new nsIServiceManager (result[0]); - result[0] = 0; - byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true); - rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - serviceManager.Release (); - - nsIMemory memory = new nsIMemory (result[0]); - result[0] = 0; - - if (id.Equals (nsIVariant.NS_IVARIANT_IID)) { - arrayReturn = new Object[count[0]]; - for (int i = 0; i < count[0]; i++) { - int /*long*/[] arrayPtr = new int /*long*/[1]; - C.memmove (arrayPtr, ptr[0] + i * C.PTR_SIZEOF, C.PTR_SIZEOF); - nsISupports supports = new nsISupports (arrayPtr[0]); - rc = supports.QueryInterface (nsIVariant.NS_IVARIANT_IID, result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - - nsIVariant currentVariant = new nsIVariant (result[0]); - result[0] = 0; - currentType[0] = 0; - rc = currentVariant.GetDataType (currentType); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - try { - arrayReturn[i] = convertToJava (currentVariant, currentType[0]); - currentVariant.Release (); - } catch (IllegalArgumentException e) { - /* invalid argument value type */ - currentVariant.Release (); - memory.Free (ptr[0]); - memory.Release (); - throw e; - } - } - } else { - switch (currentType[0]) { - case nsIDataType.VTYPE_DOUBLE: - arrayReturn = new Object[count[0]]; - for (int i = 0; i < count[0]; i++) { - double[] doubleValue = new double[1]; - C.memmove (doubleValue, ptr[0] + i * 8, 8); - arrayReturn[i] = new Double (doubleValue[0]); - } - break; - case nsIDataType.VTYPE_BOOL: - arrayReturn = new Object[count[0]]; - for (int i = 0; i < count[0]; i++) { - int[] boolValue = new int[1]; /* PRUInt32 */ - C.memmove (boolValue, ptr[0] + i * 4, 4); - arrayReturn[i] = new Boolean (boolValue[0] != 0); - } - break; - case nsIDataType.VTYPE_INT32: - arrayReturn = new Object[count[0]]; - for (int i = 0; i < count[0]; i++) { - int[] intValue = new int[1]; /* PRInt32 */ - C.memmove (intValue, ptr[0] + i * 4, 4); - arrayReturn[i] = new Double (intValue[0]); - } - break; - case nsIDataType.VTYPE_WCHAR_STR: - arrayReturn = new Object[count[0]]; - for (int i = 0; i < count[0]; i++) { - int /*long*/ currentPtr = ptr[0] + i * C.PTR_SIZEOF; - int /*long*/[] stringPtr = new int /*long*/[1]; - C.memmove (stringPtr, currentPtr, C.PTR_SIZEOF); - int length = XPCOM.strlen_PRUnichar (stringPtr[0]); - char[] dest = new char[length]; - XPCOM.memmove (dest, stringPtr[0], length * 2); - arrayReturn[i] = new String (dest); - } - break; - default: - memory.Free (ptr[0]); - memory.Release (); - SWT.error (SWT.ERROR_INVALID_ARGUMENT); - } - } - memory.Free (ptr[0]); - memory.Release (); - return arrayReturn; - } - SWT.error (SWT.ERROR_INVALID_ARGUMENT); - return null; -} - -nsIVariant convertToJS (Object value, nsIComponentManager componentManager) { - int /*long*/[] result = new int /*long*/[1]; - byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_VARIANT_CONTRACTID, true); - int rc = componentManager.CreateInstanceByContractID (aContractID, 0, nsIWritableVariant.NS_IWRITABLEVARIANT_IID, result); - nsIWritableVariant variant = new nsIWritableVariant (result[0]); - result[0] = 0; - - if (value == null) { - rc = variant.SetAsEmpty (); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return variant; - } - if (value instanceof String) { - String stringValue = (String)value; - int length = stringValue.length (); - char[] chars = new char[length]; - stringValue.getChars (0, length, chars, 0); - rc = variant.SetAsWStringWithSize (length, chars); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return variant; - } - if (value instanceof Boolean) { - Boolean booleanValue = (Boolean)value; - rc = variant.SetAsBool (booleanValue.booleanValue () ? 1 : 0); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return variant; - } - if (value instanceof Number) { - Number numberValue = (Number)value; - rc = variant.SetAsDouble (numberValue.doubleValue ()); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - return variant; - } - if (value instanceof Object[]) { - Object[] arrayValue = (Object[])value; - int length = arrayValue.length; - if (length == 0) { - rc = variant.SetAsEmptyArray (); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - } else { - int /*long*/ arrayPtr = C.malloc (C.PTR_SIZEOF * length); - for (int i = 0; i < length; i++) { - Object currentObject = arrayValue[i]; - try { - nsIVariant currentVariant = convertToJS (currentObject, componentManager); - C.memmove (arrayPtr + C.PTR_SIZEOF * i, new int /*long*/[] {currentVariant.getAddress ()}, C.PTR_SIZEOF); - } catch (SWTException e) { - /* invalid return value type */ - C.free (arrayPtr); - variant.Release (); - /* release the variants that had previously been added to the array */ - for (int j = 0; j < i; j++) { - int /*long*/[] ptr = new int /*long*/[1]; - C.memmove (ptr, arrayPtr + C.PTR_SIZEOF * j, C.PTR_SIZEOF); - new nsISupports (ptr[0]).Release (); - } - throw e; - } - } - int /*long*/ idPtr = C.malloc (nsID.sizeof); - XPCOM.memmove (idPtr, nsIVariant.NS_IVARIANT_IID, nsID.sizeof); - rc = variant.SetAsArray (nsIDataType.VTYPE_INTERFACE_IS, idPtr, length, arrayPtr); - C.free (idPtr); - C.free (arrayPtr); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - } - return variant; - } - - variant.Release (); - SWT.error (SWT.ERROR_INVALID_RETURN_VALUE); - return null; -} - -int callJava (int functionId, int /*long*/ tokenVariant, int /*long*/ args, int /*long*/ returnPtr) { - Object key = new Integer (functionId); - BrowserFunction function = (BrowserFunction)Mozilla.AllFunctions.get (key); - Object returnValue = null; - - if (function != null) { - try { - short[] type = new short[1]; /* PRUint16 */ - nsIVariant variant = new nsIVariant (tokenVariant); - int rc = variant.GetDataType (type); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - Object temp = convertToJava (variant, type[0]); - type[0] = 0; - if (temp instanceof String) { - String token = (String)temp; - if (token.equals (function.token)) { - variant = new nsIVariant (args); - rc = variant.GetDataType (type); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - temp = convertToJava (variant, type[0]); - if (temp instanceof Object[]) { - Object[] arguments = (Object[])temp; - try { - returnValue = function.function (arguments); - } catch (Exception e) { - /* exception during function invocation */ - returnValue = WebBrowser.CreateErrorString (e.getLocalizedMessage ()); - } - } - } - } - } catch (IllegalArgumentException e) { - /* invalid argument value type */ - if (function.isEvaluate) { - /* notify the evaluate function so that a java exception can be thrown */ - function.function (new String[] {WebBrowser.CreateErrorString (new SWTException (SWT.ERROR_INVALID_RETURN_VALUE).getLocalizedMessage ())}); - } - returnValue = WebBrowser.CreateErrorString (e.getLocalizedMessage ()); - } - } - - int /*long*/[] result = new int /*long*/[1]; - int rc = XPCOM.NS_GetComponentManager (result); - if (rc != XPCOM.NS_OK) Mozilla.error (rc); - if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE); - nsIComponentManager componentManager = new nsIComponentManager (result[0]); - result[0] = 0; - nsIVariant variant; - try { - variant = convertToJS (returnValue, componentManager); - } catch (SWTException e) { - /* invalid return value type */ - variant = convertToJS (WebBrowser.CreateErrorString (e.getLocalizedMessage ()), componentManager); - } - componentManager.Release (); - C.memmove (returnPtr, new int /*long*/[] {variant.getAddress ()}, C.PTR_SIZEOF); - - return XPCOM.NS_OK; -} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java index 51917394a7..74c33cbe47 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java @@ -694,9 +694,6 @@ public void create (Composite parent, int style) { LocationProvider = new AppFileLocProvider (MozillaPath, profilePath, cacheParentPath, IsXULRunner); LocationProvider.AddRef (); - /* write external.xpt to the file system if needed */ - initExternal (profilePath); - /* invoke appropriate Init function (based on mozilla version) */ initXPCOM (MozillaPath, IsXULRunner); } @@ -896,6 +893,9 @@ public void create (Composite parent, int style) { interfaceRequestor.Release (); componentRegistrar.Release (); + /* write external.xpt to the file system if needed */ + initExternal (LocationProvider.profilePath); + if (!factoriesRegistered) { HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); dialogFactory.AddRef (); @@ -1359,17 +1359,9 @@ public boolean execute (String script) { if (rc == XPCOM.NS_OK && result[0] != 0) { int /*long*/ principals = result[0]; result[0] = 0; - String jsLibraryName = IsPre_4 ? MozillaDelegate.getJSLibraryName_Pre4() : MozillaDelegate.getJSLibraryName(); - if (jsLibPathBytes == null) { - String mozillaPath = getMozillaPath () + jsLibraryName + '\0'; - try { - jsLibPathBytes = mozillaPath.getBytes ("UTF-8"); //$NON-NLS-1$ - } catch (UnsupportedEncodingException e) { - jsLibPathBytes = mozillaPath.getBytes (); - } - } - int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (jsLibPathBytes, nativeContext); + byte[] jsLibPath = getJSLibPathBytes (); + int /*long*/ globalJSObject = XPCOM.JS_GetGlobalObject (jsLibPath, nativeContext); if (globalJSObject != 0) { aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CONTEXTSTACK_CONTRACTID, true); rc = serviceManager.GetServiceByContractID (aContractID, nsIJSContextStack.NS_IJSCONTEXTSTACK_IID, result); @@ -1380,7 +1372,7 @@ public boolean execute (String script) { if (rc != XPCOM.NS_OK) { stack.Release (); } else { - boolean success = XPCOM.JS_EvaluateUCScriptForPrincipals (jsLibPathBytes, nativeContext, globalJSObject, principals, scriptChars, length, urlbytes, 0, result) != 0; + boolean success = XPCOM.JS_EvaluateUCScriptForPrincipals (jsLibPath, nativeContext, globalJSObject, principals, scriptChars, length, urlbytes, 0, result) != 0; result[0] = 0; rc = stack.Pop (result); stack.Release (); @@ -1488,6 +1480,19 @@ public String getBrowserType () { return "mozilla"; //$NON-NLS-1$ } +static byte[] getJSLibPathBytes () { + if (jsLibPathBytes == null) { + String jsLibraryName = IsPre_4 ? MozillaDelegate.getJSLibraryName_Pre4 () : MozillaDelegate.getJSLibraryName (); + String mozillaPath = getMozillaPath () + jsLibraryName + '\0'; + try { + jsLibPathBytes = mozillaPath.getBytes ("UTF-8"); //$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + jsLibPathBytes = mozillaPath.getBytes (); + } + } + return jsLibPathBytes; +} + static String getMozillaPath () { if (LocationProvider != null) return LocationProvider.mozillaPath; if (!Initialized) return ""; @@ -1738,6 +1743,13 @@ static String InitDiscoverXULRunner () { } void initExternal (String profilePath) { + /* + * external.xpt does not need to be written to the file system if the + * XULRunner version is >= 4 since External.java handles this case + * differently than for earlier XULRunner releases. + */ + if (!IsPre_4) return; + File componentsDir = new File (profilePath, AppFileLocProvider.COMPONENTS_DIR); java.io.InputStream is = Library.class.getResourceAsStream ("/external.xpt"); //$NON-NLS-1$ if (is != null) { @@ -1825,12 +1837,12 @@ void initFactories (nsIServiceManager serviceManager, nsIComponentManager compon /* register for mozilla versions <= 3.6.x */ byte[] category = MozillaDelegate.wcsToMbcs (null, "JavaScript global property", true); //$NON-NLS-1$ - rc = categoryManager.AddCategoryEntry(category, entry, aContractID, 0, 1, result); + rc = categoryManager.AddCategoryEntry (category, entry, aContractID, 0, 1, result); result[0] = 0; /* register for mozilla versions >= 3.6.x */ category = MozillaDelegate.wcsToMbcs (null, "JavaScript-global-property", true); //$NON-NLS-1$ - rc = categoryManager.AddCategoryEntry(category, entry, aContractID, 0, 1, result); + rc = categoryManager.AddCategoryEntry (category, entry, aContractID, 0, 1, result); result[0] = 0; categoryManager.Release (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java index 8423c7a547..fd0259f7ec 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/XPCOM.java @@ -47,7 +47,7 @@ public class XPCOM extends C { public static final String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$ public static final String DOMEVENT_KEYPRESS = "keypress"; //$NON-NLS-1$ public static final String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$ - + /* CID constants */ public static final nsID EXTERNAL_CID = new nsID ("f2c59ad0-bd76-11dd-ad8b-0800200c9a66"); //$NON-NLS-1$ public static final nsID NS_APPSHELL_CID = new nsID("2d96b3df-c051-11d1-a827-0040959a28c9"); //$NON-NLS-1$ @@ -62,6 +62,10 @@ public class XPCOM extends C { public static final nsID NS_PROMPTER_CID = new nsID("f2112d6a-0e28-421f-b46a-25c0b308cbd0"); //$NON-NLS-1$ public static final nsID NS_PROMPTSERVICE_CID = new nsID("a2112d6a-0e28-421f-b46a-25c0b308cbd0"); //$NON-NLS-1$ public static final nsID NS_IWEBBROWSER_CID = new nsID ("F1EAC761-87E9-11d3-AF80-00A024FFC08C"); //$NON-NLS-1$ + public static final nsID NS_IXPCONNECT_CID = new nsID ("CB6593E0-F9B2-11d2-BDD6-000064657374"); //$NON-NLS-1$ + + public static final nsID NS_ISCRIPTOBJECTOWNER_IID = new nsID ("8f6bca7e-ce42-11d1-b724-00600891d8c9"); //$NON-NLS-1$ + public static final nsID NS_ISECURITYCHECKEDCOMPONENT_IID = new nsID ("0dad9e8c-a12d-4dcb-9a6f-7d09839356e1"); //$NON-NLS-1$ public static final String EXTERNAL_CONTRACTID = "@eclipse.org/external;1"; //$NON-NLS-1$ public static final String NS_AUTHPROMPTER_CONTRACTID = "@mozilla.org/passwordmanager/authpromptfactory;1"; //$NON-NLS-1$ @@ -147,6 +151,13 @@ public class XPCOM extends C { public static final int SEC_ERROR_UNTRUSTED_ISSUER = 0x805A1FEC; public static final int SSL_ERROR_BAD_CERT_DOMAIN = 0x805A2FF4; + /* JSAPI constants */ + public static final int JSPROP_ENUMERATE = 0x1; + public static final int JSPROP_PERMANENT = 0x4; + public static final int JSPROP_READONLY = 0x2; + public static final int JS_FALSE = 0x0; + public static final int JS_TRUE = 0x1; + public static final native int nsDynamicFunctionLoad_sizeof (); public static void memmove(int /*long*/ dest, boolean[] src) { @@ -191,6 +202,9 @@ public static final native void memmove(int /*long*/ dest, nsID src, int nbytes) public static final native int strlen_PRUnichar(int /*long*/ s); /** @method flags=no_gen */ +public static final native int /*long*/ CALLBACK_JSNative(int /*long*/ func); + +/** @method flags=no_gen */ public static final native int /*long*/ _JS_DefineFunction(byte[] mozillaPath, int /*long*/ cx, int /*long*/ obj, byte[] name, int /*long*/ call, int nargs, int flags); public static final int /*long*/ JS_DefineFunction(byte[] mozillaPath, int /*long*/ cx, int /*long*/ obj, byte[] name, int /*long*/ call, int nargs, int flags) { lock.lock(); @@ -221,26 +235,6 @@ public static final int /*long*/ JS_GetGlobalObject(byte[] mozillaPath, int /*lo } } /** @method flags=no_gen */ -public static final native int /*long*/ _JS_GetGlobalForScopeChain(byte[] mozillaPath, int /*long*/ cx); -public static final int /*long*/ JS_GetGlobalForScopeChain(byte[] mozillaPath, int /*long*/ cx) { - lock.lock(); - try { - return _JS_GetGlobalForScopeChain(mozillaPath, cx); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ -public static final native int /*long*/ _JSVAL_TO_IMPL2(byte[] mozillaPath, int /*long*/ cx); -public static final int /*long*/ JSVAL_TO_IMPL2(byte[] mozillaPath, int /*long*/ cx) { - lock.lock(); - try { - return _JSVAL_TO_IMPL2(mozillaPath, cx); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ public static final native int /*long*/ _JS_NewObject(byte[] mozillaPath, int /*long*/ cx, int /*long*/ clasp, int /*long*/ proto, int /*long*/ parent); public static final int /*long*/ JS_NewObject(byte[] mozillaPath, int /*long*/ cx, int /*long*/ clasp, int /*long*/ proto, int /*long*/ parent) { lock.lock(); @@ -251,46 +245,6 @@ public static final int /*long*/ JS_NewObject(byte[] mozillaPath, int /*long*/ c } } /** @method flags=no_gen */ -public static final native int /*long*/ _JS_ValueToString(byte[] mozillaPath, int /*long*/ cx, int /*long*/ string); -public static final int /*long*/ JS_ValueToString(byte[] mozillaPath, int /*long*/ cx, int /*long*/ string) { - lock.lock(); - try { - return _JS_ValueToString(mozillaPath, cx, string); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ -public static final native int /*long*/ _JS_TypeOfValue(byte[] mozillaPath, int /*long*/ cx, int /*long*/ value); -public static final int /*long*/ JS_TypeOfValue(byte[] mozillaPath, int /*long*/ cx, int /*long*/ value) { - lock.lock(); - try { - return _JS_TypeOfValue(mozillaPath, cx, value); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ -public static final native int /*long*/ _JS_GetStringCharsZ(byte[] mozillaPath, int /*long*/ cx, int /*long*/ string); -public static final int /*long*/ JS_GetStringCharsZ(byte[] mozillaPath, int /*long*/ cx, int /*long*/ string) { - lock.lock(); - try { - return _JS_GetStringCharsZ(mozillaPath, cx, string); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ -public static final native int /*long*/ _JS_GetStringLength(byte[] mozillaPath, int /*long*/ string); -public static final int /*long*/ JS_GetStringLength(byte[] mozillaPath, int /*long*/ string) { - lock.lock(); - try { - return _JS_GetStringLength(mozillaPath, string); - } finally { - lock.unlock(); - } -} -/** @method flags=no_gen */ public static final native boolean _NS_Free(byte[] mozillaPath, int /*long*/ aPtr); public static final boolean NS_Free(byte[] mozillaPath, int /*long*/ aPtr) { lock.lock(); @@ -439,19 +393,6 @@ public static final int /*long*/ nsIScriptGlobalObject_GetScriptContext(int /*lo * @method flags=cpp * @param ptr cast=(nsIScriptContext *) */ -public static final native int /*long*/ _nsIScriptContext_GetGlobalObject(int /*long*/ ptr); -public static final int /*long*/ nsIScriptContext_GetGlobalObject(int /*long*/ ptr) { - lock.lock(); - try { - return _nsIScriptContext_GetGlobalObject(ptr); - } finally { - lock.unlock(); - } -} -/** - * @method flags=cpp - * @param ptr cast=(nsIScriptContext *) - */ public static final native int /*long*/ _nsIScriptContext_GetNativeContext(int /*long*/ ptr); public static final int /*long*/ nsIScriptContext_GetNativeContext(int /*long*/ ptr) { lock.lock(); @@ -461,7 +402,6 @@ public static final int /*long*/ nsIScriptContext_GetNativeContext(int /*long*/ lock.unlock(); } } - /** * @method flags=cpp * @param ptr cast=(nsEmbedCString *) @@ -1707,6 +1647,15 @@ static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg lock.unlock(); } } +static final native int _VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3); +static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3) { + lock.lock(); + try { + return _VtblCall(fnNumber, ppVtbl, arg0, arg1, arg2, arg3); + } finally { + lock.unlock(); + } +} static final native int _VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long[] arg3); static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long[] arg3) { lock.lock(); @@ -2591,12 +2540,4 @@ static final int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1 } } - -// added by nsIXPConnect -//static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, !ERROR UNKNOWN C TYPE <PRInt16 >! arg0); -//static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int /*long*/[] arg0); -//static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, !ERROR UNKNOWN C TYPE <bool >! arg0, !ERROR UNKNOWN C TYPE <bool >! arg1); -//static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, int /*long*/[] arg1); -//static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int /*long*/ arg0, int /*long*/ arg1, short arg2, int /*long*/ arg3, int /*long*/[] arg4, int /*long*/[] arg5); - } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISecurityCheckedComponent.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISecurityCheckedComponent.java deleted file mode 100644 index 017ed674bb..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsISecurityCheckedComponent.java +++ /dev/null @@ -1,59 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by Netscape are Copyright (C) 1998-1999 - * Netscape Communications Corporation. All Rights Reserved. - * - * Contributor(s): - * - * IBM - * - Binding to permit interfacing between Mozilla and SWT - * - Copyright (C) 2003, 2009 IBM Corp. All Rights Reserved. - * - * ***** END LICENSE BLOCK ***** */ -package org.eclipse.swt.internal.mozilla; - -public class nsISecurityCheckedComponent extends nsISupports { - - static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4; - - public static final String NS_ISECURITYCHECKEDCOMPONENT_IID_STR = - "0dad9e8c-a12d-4dcb-9a6f-7d09839356e1"; - - public static final nsID NS_ISECURITYCHECKEDCOMPONENT_IID = - new nsID(NS_ISECURITYCHECKEDCOMPONENT_IID_STR); - - public nsISecurityCheckedComponent(int /*long*/ address) { - super(address); - } - - public int CanCreateWrapper(int /*long*/ iid, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), iid, _retval); - } - - public int CanCallMethod(int /*long*/ iid, char[] methodName, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), iid, methodName, _retval); - } - - public int CanGetProperty(int /*long*/ iid, char[] propertyName, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), iid, propertyName, _retval); - } - - public int CanSetProperty(int /*long*/ iid, char[] propertyName, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), iid, propertyName, _retval); - } -} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIVariant.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIVariant.java index 2de3baf3fc..1d8df8effd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIVariant.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIVariant.java @@ -29,14 +29,20 @@ package org.eclipse.swt.internal.mozilla; public class nsIVariant extends nsISupports { - static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 26; + static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + (IsXULRunner10 ? 27 : 26); public static final String NS_IVARIANT_IID_STR = "6c9eb060-8c6a-11d5-90f3-0010a4e73d9a"; + public static final String NS_IVARIANT_10_IID_STR = + "81e4c2de-acac-4ad6-901a-b5fb1b851a0d"; + public static final nsID NS_IVARIANT_IID = new nsID(NS_IVARIANT_IID_STR); + public static final nsID NS_IVARIANT_10_IID = + new nsID(NS_IVARIANT_10_IID_STR); + public nsIVariant(int /*long*/ address) { super(address); } @@ -129,19 +135,24 @@ public class nsIVariant extends nsISupports { return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), _retval); } + public int GetAsJSVal(int /*long*/[] _retval) { + if (!IsXULRunner10) return XPCOM.NS_COMFALSE; + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), _retval); + } + public int GetAsInterface(int /*long*/[] iid, int /*long*/[] iface) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), iid, iface); + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + (IsXULRunner10 ? 24 : 23), getAddress(), iid, iface); } public int GetAsArray(short[] type, int /*long*/ iid, int[] count, int /*long*/[] ptr) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), type, iid, count, ptr); + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + (IsXULRunner10 ? 25 : 24), getAddress(), type, iid, count, ptr); } public int GetAsStringWithSize(int[] size, int /*long*/[] str) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), size, str); + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + (IsXULRunner10 ? 26 : 25), getAddress(), size, str); } public int GetAsWStringWithSize(int[] size, int /*long*/[] str) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), size, str); + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + (IsXULRunner10 ? 27 : 26), getAddress(), size, str); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPCScriptable.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPCScriptable.java deleted file mode 100644 index 9429de65d6..0000000000 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPCScriptable.java +++ /dev/null @@ -1,195 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code, released March 31, 1998.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by Netscape are Copyright (C) 1998-1999
- * Netscape Communications Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *
- * IBM
- * - Binding to permit interfacing between Mozilla and SWT
- * - Copyright (C) 2003, 2009 IBM Corp. All Rights Reserved.
- *
- * ***** END LICENSE BLOCK ***** */
-package org.eclipse.swt.internal.mozilla;
-
-public class nsIXPCScriptable extends nsISupports {
-
- static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 22;
-
- public static final String NS_IXPCSCRIPTABLE_IID_STR =
- "a40ce52e-2d8c-400f-9af2-f8784a656070";
-
- public static final nsID NS_IXPCSCRIPTABLE_IID =
- new nsID(NS_IXPCSCRIPTABLE_IID_STR);
-
- public nsIXPCScriptable(int /*long*/ address) {
- super(address);
- }
-
- public static final int WANT_PRECREATE = 1;
-
- public static final int WANT_CREATE = 2;
-
- public static final int WANT_POSTCREATE = 4;
-
- public static final int WANT_ADDPROPERTY = 8;
-
- public static final int WANT_DELPROPERTY = 16;
-
- public static final int WANT_GETPROPERTY = 32;
-
- public static final int WANT_SETPROPERTY = 64;
-
- public static final int WANT_ENUMERATE = 128;
-
- public static final int WANT_NEWENUMERATE = 256;
-
- public static final int WANT_NEWRESOLVE = 512;
-
- public static final int WANT_CONVERT = 1024;
-
- public static final int WANT_FINALIZE = 2048;
-
- public static final int WANT_CHECKACCESS = 4096;
-
- public static final int WANT_CALL = 8192;
-
- public static final int WANT_CONSTRUCT = 16384;
-
- public static final int WANT_HASINSTANCE = 32768;
-
- public static final int WANT_TRACE = 65536;
-
- public static final int USE_JSSTUB_FOR_ADDPROPERTY = 131072;
-
- public static final int USE_JSSTUB_FOR_DELPROPERTY = 262144;
-
- public static final int USE_JSSTUB_FOR_SETPROPERTY = 524288;
-
- public static final int DONT_ENUM_STATIC_PROPS = 1048576;
-
- public static final int DONT_ENUM_QUERY_INTERFACE = 2097152;
-
- public static final int DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 4194304;
-
- public static final int CLASSINFO_INTERFACES_ONLY = 8388608;
-
- public static final int ALLOW_PROP_MODS_DURING_RESOLVE = 16777216;
-
- public static final int ALLOW_PROP_MODS_TO_PROTOTYPE = 33554432;
-
- public static final int DONT_SHARE_PROTOTYPE = 67108864;
-
- public static final int DONT_REFLECT_INTERFACE_NAMES = 134217728;
-
- public static final int WANT_EQUALITY = 268435456;
-
- public static final int WANT_OUTER_OBJECT = 536870912;
-
- public static final int USE_STUB_EQUALITY_HOOK = 1073741824;
-
- public static final int RESERVED = 2147483648;
-
- public int GetClassName(int /*long*/[] aClassName) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aClassName);
- }
-
- public int GetScriptableFlags(int[] aScriptableFlags) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aScriptableFlags);
- }
-
- public int PreCreate(int /*long*/ nativeObj, int /*long*/ cx, int /*long*/ globalObj, int /*long*/[] parentObj) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), nativeObj, cx, globalObj, parentObj);
- }
-
- public int Create(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), wrapper, cx, obj);
- }
-
- public int PostCreate(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), wrapper, cx, obj);
- }
-
- public int AddProperty(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), wrapper, cx, obj, id, vp, _retval);
- }
-
- public int DelProperty(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), wrapper, cx, obj, id, vp, _retval);
- }
-
- public int GetProperty(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), wrapper, cx, obj, id, vp, _retval);
- }
-
- public int SetProperty(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), wrapper, cx, obj, id, vp, _retval);
- }
-
- public int Enumerate(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), wrapper, cx, obj, _retval);
- }
-
- public int NewEnumerate(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int enum_op, int /*long*/ statep, int /*long*/ idp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), wrapper, cx, obj, enum_op, statep, idp, _retval);
- }
-
- public int NewResolve(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int flags, int /*long*/[] objp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), wrapper, cx, obj, id, flags, objp, _retval);
- }
-
- public int Convert(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int type, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), wrapper, cx, obj, type, vp, _retval);
- }
-
- public int Finalize(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), wrapper, cx, obj);
- }
-
- public int CheckAccess(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, !ERROR UNKNOWN C TYPE <jsid >! id, int mode, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), wrapper, cx, obj, id, mode, vp, _retval);
- }
-
- public int Call(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int argc, int /*long*/ argv, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), wrapper, cx, obj, argc, argv, vp, _retval);
- }
-
- public int Construct(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int argc, int /*long*/ argv, int /*long*/ vp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), wrapper, cx, obj, argc, argv, vp, _retval);
- }
-
- public int HasInstance(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int /*long*/ val, int /*long*/ bp, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), wrapper, cx, obj, val, bp, _retval);
- }
-
- public int Trace(int /*long*/ wrapper, int /*long*/ trc, int /*long*/ obj) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), wrapper, trc, obj);
- }
-
- public int Equality(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int /*long*/ val, int /*long*/ _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), wrapper, cx, obj, val, _retval);
- }
-
- public int OuterObject(int /*long*/ wrapper, int /*long*/ cx, int /*long*/ obj, int /*long*/[] _retval) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), wrapper, cx, obj, _retval);
- }
-
- public int PostCreatePrototype(int /*long*/ cx, int /*long*/ proto) {
- return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), cx, proto);
- }
-}
\ No newline at end of file diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPConnect.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPConnect.java index 9ab32d7381..dc49321651 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPConnect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/internal/mozilla/nsIXPConnect.java @@ -22,7 +22,7 @@ * * IBM * - Binding to permit interfacing between Mozilla and SWT - * - Copyright (C) 2003, 2009 IBM Corp. All Rights Reserved. + * - Copyright (C) 2012 IBM Corp. All Rights Reserved. * * ***** END LICENSE BLOCK ***** */ package org.eclipse.swt.internal.mozilla; @@ -41,11 +41,11 @@ public class nsIXPConnect extends nsISupports { super(address); } - public int Equals(int /*long*/ other, int[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 27, getAddress(), other, _retval); - } - public int JSValToVariant(int /*long*/ cx, int /*long*/ aJSVal, int /*long*/[] _retval) { - return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), cx, aJSVal, _retval); + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), cx, aJSVal, _retval); + } + + public int VariantToJS(int /*long*/ ctx, int /*long*/ scope, int /*long*/ value, int /*long*/ _retval) { + return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 33, getAddress(), ctx, scope, value, _retval); } } diff --git a/bundles/org.eclipse.swt/buildSWT.xml b/bundles/org.eclipse.swt/buildSWT.xml index fcc3709307..74379ba1a3 100644 --- a/bundles/org.eclipse.swt/buildSWT.xml +++ b/bundles/org.eclipse.swt/buildSWT.xml @@ -975,14 +975,12 @@ <condition property="build_file" value="build-ce.bat" else="build.bat"> <equals arg1="${swt.os}" arg2="wce_ppc"/> </condition> -<!-- <exec dir="${build_dir}" executable="${build_dir}/${build_file}" failonerror="true"> <env key="JAVA_HOME" value=""/> <env key="OUTPUT_DIR" value="${win_output_dir}"/> <arg line="${targets}"/> <arg line="${clean}"/> </exec> ---> <condition property="should_build_xulrunner" value="true"> <and> <equals arg1="${swt.ws}" arg2="win32"/> diff --git a/bundles/org.eclipse.swt/components/chrome.manifest b/bundles/org.eclipse.swt/components/chrome.manifest deleted file mode 100644 index 0116640ee8..0000000000 --- a/bundles/org.eclipse.swt/components/chrome.manifest +++ /dev/null @@ -1,6 +0,0 @@ -interfaces external.xpt
-contract @eclipse.org/external;1 {f2c59ad0-bd76-11dd-ad8b-0800200c9a66}
-
-# component {f2c59ad0-bd76-11dd-ad8b-0800200c9a66}
-# public static final nsID EXTERNAL_CID = new nsID ("f2c59ad0-bd76-11dd-ad8b-0800200c9a66"); //$NON-NLS-1$
-# public static final String EXTERNAL_CONTRACTID = "@eclipse.org/external;1"; //$NON-NLS-1$
|