2005/9/14, Michael Koch <[EMAIL PROTECTED]>: > UURGH, NO. This will break SWT on 32 bit archs - if it works on 64 bit archs > at all. > > You cannont compare normal C code with JNI C code. JNI C code has much higher > restrictions.
There's that cry of outrage! Hehe. Are there any 32-bit architectures where int is not synonymous with long? The patch I plan on applying follows. Incidentally, this worked just fine on i386, tested with swingwtdemo as a native gcj application, and with Azureus using the Sun JVM. Cheers, Shaun --- swt-gtk-3.1.orig/xpcom.cpp +++ swt-gtk-3.1/xpcom.cpp @@ -32,6 +32,8 @@ extern "C" { +typedef long jintptr_t; // For 64 bit architectures. + #define XPCOM_NATIVE(func) Java_org_eclipse_swt_internal_mozilla_XPCOM_##func #ifndef NO_Call @@ -141,7 +143,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, PR_1Malloc_FUNC); - rc = (jint)PR_Malloc(arg0); + rc = (jintptr_t)PR_Malloc(arg0); XPCOM_NATIVE_EXIT(env, that, PR_1Malloc_FUNC); return rc; } @@ -1868,7 +1870,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1get_FUNC); - rc = (jint)((nsEmbedCString *)arg0)->get(); + rc = (jintptr_t)((nsEmbedCString *)arg0)->get(); XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1get_FUNC); return rc; } @@ -1880,7 +1882,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1new___FUNC); - rc = (jint)new nsEmbedCString(); + rc = (jintptr_t)new nsEmbedCString(); XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1new___FUNC); return rc; } @@ -1894,7 +1896,7 @@ jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1new___3BI_FUNC); if (arg0) if ((lparg0 = env->GetByteArrayElements(arg0, NULL)) == NULL) goto fail; - rc = (jint)new nsEmbedCString((const char *)lparg0, arg1); + rc = (jintptr_t)new nsEmbedCString((const char *)lparg0, arg1); fail: if (arg0 && lparg0) env->ReleaseByteArrayElements(arg0, lparg0, 0); XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1new___3BI_FUNC); @@ -1930,7 +1932,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1get_FUNC); - rc = (jint)((nsEmbedString *)arg0)->get(); + rc = (jintptr_t)((nsEmbedString *)arg0)->get(); XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1get_FUNC); return rc; } @@ -1942,7 +1944,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1new___FUNC); - rc = (jint)new nsEmbedString(); + rc = (jintptr_t)new nsEmbedString(); XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1new___FUNC); return rc; } @@ -1956,7 +1958,7 @@ jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1new___3C_FUNC); if (arg0) if ((lparg0 = env->GetCharArrayElements(arg0, NULL)) == NULL) goto fail; - rc = (jint)new nsEmbedString(lparg0); + rc = (jintptr_t)new nsEmbedString(lparg0); fail: if (arg0 && lparg0) env->ReleaseCharArrayElements(arg0, lparg0, 0); XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1new___3C_FUNC); @@ -2008,7 +2010,7 @@ { jint rc = 0; XPCOM_NATIVE_ENTER(env, that, nsID_1new_FUNC); - rc = (jint)new nsID(); + rc = (jintptr_t)new nsID(); XPCOM_NATIVE_EXIT(env, that, nsID_1new_FUNC); return rc; }