Bug 512001: [Webkit2] Move evaluate() logic to java  (32 bit fix)

- 32bit fix for proper build on 32bit machines. 
- Fixed cast for GError

Change-Id: Ibbb37e7a1276b43358c0cc25ec5ce62a4edae3b0
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
index 16c839d..9da1995 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk.c
@@ -2947,12 +2947,12 @@
 	WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1view_1run_1javascript_1finish_FUNC);
 	if (arg2) if ((lparg2 = (*env)->GetIntLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
 /*
-	rc = (jintLong)webkit_web_view_run_javascript_finish(arg0, arg1, lparg2);
+	rc = (jintLong)webkit_web_view_run_javascript_finish(arg0, arg1, (GError **)lparg2);
 */
 	{
 		WebKitGTK_LOAD_FUNCTION(fp, webkit_web_view_run_javascript_finish)
 		if (fp) {
-			rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong, jintLong *))fp)(arg0, arg1, lparg2);
+			rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong, jintLong, GError **))fp)(arg0, arg1, (GError **)lparg2);
 		}
 	}
 fail:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index 4897bb4..7ead7fe 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -1173,31 +1173,31 @@
 	 * org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser.test_execute_and_closeListener()
 	 */
 	private static class CallBackMap {
-		private static HashMap<Long, Webkit2EvalReturnObj> callbackMap = new HashMap<>();
+		private static HashMap<Integer, Webkit2EvalReturnObj> callbackMap = new HashMap<>();
 
-		static long putObject(Webkit2EvalReturnObj obj) {
-			long id = getNextId();
+		static int putObject(Webkit2EvalReturnObj obj) {
+			int id = getNextId();
 			callbackMap.put(id, obj);
 			return id;
 		}
-		static Webkit2EvalReturnObj getObj(long id) {
+		static Webkit2EvalReturnObj getObj(int id) {
 			return callbackMap.get(id);
 		}
-		static void removeObject(long id) {
+		static void removeObject(int id) {
 			callbackMap.remove(id);
 			removeId(id);
 		}
 
 		// Mechanism to generate unique ID's
-		private static long nextCallbackId = 1;
-		private static HashSet<Long> usedCallbackIds = new HashSet<>();
-		private static long getNextId() {
-			long value = 0;
+		private static int nextCallbackId = 1;
+		private static HashSet<Integer> usedCallbackIds = new HashSet<>();
+		private static int getNextId() {
+			int value = 0;
 			boolean unique = false;
 			while (unique == false) {
 				value = nextCallbackId;
 				unique = !usedCallbackIds.contains(value);
-				if (nextCallbackId != Long.MAX_VALUE)
+				if (nextCallbackId != Integer.MAX_VALUE)
 					nextCallbackId++;
 				else
 					nextCallbackId = 1;
@@ -1231,7 +1231,7 @@
 			// Callback logic: Initiate an async callback and wait for it to finish.
 			// The callback comes back in javascriptExecutionFinishedProc(..) below.
 			Webkit2EvalReturnObj retObj = new Webkit2EvalReturnObj();
-			long callbackId = CallBackMap.putObject(retObj);
+			int callbackId = CallBackMap.putObject(retObj);
 			WebKitGTK.webkit_web_view_run_javascript(webView, Converter.wcsToMbcs(fixedScript, true), 0, callback.getAddress(), callbackId);
 			Shell shell = browser.getShell();
 			Display display = browser.getDisplay();
@@ -1255,7 +1255,7 @@
 	/** Callback that is called directly from Javascirpt. **/
 	@SuppressWarnings("unused")
 	private static void javascriptExecutionFinishedProc (long /*int*/ GObject_source, long /*int*/ GAsyncResult, long /*int*/ user_data) {
-		Long callbackId = user_data;
+		int callbackId = (int) user_data;
 		Webkit2EvalReturnObj retObj = CallBackMap.getObj(callbackId);
 
 		long /*int*/[] gerror = new long /*int*/ [1]; // GError **
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
index 026bf3c..73bb773 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
@@ -1622,7 +1622,7 @@
 
 /**
  * @method flags=dynamic
- * @param gerror cast(GError **)
+ * @param gerror cast=(GError **)
  */
 public static final native long /*int*/ _webkit_web_view_run_javascript_finish(long /*int*/ web_view, long /*int*/ GAsyncResult, long /*int*/[] gerror);
 /**WebKitJavascriptResult * webkit_web_view_run_javascript_finish (WebKitWebView *web_view, GAsyncResult *result, GError **error);*/