Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita Nemkin2019-04-13 08:57:22 +0000
committerLakshmi Shanmugam2019-04-19 08:29:24 +0000
commitd1a3c4b93f95ccf82a45f84acedb4b4d753bb4bd (patch)
treec3625741eafb4209dbf5204d33020678f3880a86
parent3a79c606be16a734b4961da9683e4cc22bf2ac8c (diff)
downloadeclipse.platform.swt-d1a3c4b93f95ccf82a45f84acedb4b4d753bb4bd.tar.gz
eclipse.platform.swt-d1a3c4b93f95ccf82a45f84acedb4b4d753bb4bd.tar.xz
eclipse.platform.swt-d1a3c4b93f95ccf82a45f84acedb4b4d753bb4bd.zip
Bug 546585 - [Cocoa] Don't use objc_msgSend to call variadic functions
JNIGen generates wrong C code for calling variadic ObjC methods, remove all such methods from SWT codebase. Change-Id: Icee75b71c4035a331a4b52ddcaf65e0d59c8793c Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras24
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAssertionHandler.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableString.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java10
7 files changed, 7 insertions, 93 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index 627e0b12fc..3a0d229a6b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -74,26 +74,6 @@
<retval swt_gen="true"></retval>
</method>
</class>
- <class name="NSAssertionHandler" swt_gen="true">
- <method class_method="true" selector="currentHandler" swt_gen="true">
- <retval swt_gen="true"></retval>
- </method>
- <method selector="handleFailureInFunction:file:lineNumber:description:" swt_gen="true">
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true" swt_param_name="format"></arg>
- <retval swt_gen="true"></retval>
- </method>
- <method selector="handleFailureInMethod:object:file:lineNumber:description:" swt_gen="true">
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true"></arg>
- <arg swt_gen="true" swt_param_name="format"></arg>
- <retval swt_gen="true"></retval>
- </method>
- </class>
<class name="NSAttributedString" swt_gen="mixed">
<method selector="attribute:atIndex:effectiveRange:" swt_gen="true">
<arg swt_gen="true"></arg>
@@ -980,10 +960,6 @@
<arg swt_gen="true"></arg>
<retval swt_alloc="true" swt_gen="true" swt_java_type="NSString"></retval>
</method>
- <method class_method="true" selector="stringWithFormat:" swt_gen="true">
- <arg swt_gen="true"></arg>
- <retval swt_gen="true" swt_java_type="NSString"></retval>
- </method>
<method class_method="true" selector="stringWithUTF8String:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true" swt_java_type="NSString"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAssertionHandler.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAssertionHandler.java
deleted file mode 100644
index 789cd76bfe..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAssertionHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.swt.internal.cocoa;
-
-public class NSAssertionHandler extends NSObject {
-
-public NSAssertionHandler() {
- super();
-}
-
-public NSAssertionHandler(long /*int*/ id) {
- super(id);
-}
-
-public NSAssertionHandler(id id) {
- super(id);
-}
-
-public static NSAssertionHandler currentHandler() {
- long /*int*/ result = OS.objc_msgSend(OS.class_NSAssertionHandler, OS.sel_currentHandler);
- return result != 0 ? new NSAssertionHandler(result) : null;
-}
-
-public void handleFailureInFunction(NSString functionName, NSString fileName, long /*int*/ line, NSString format) {
- OS.objc_msgSend(this.id, OS.sel_handleFailureInFunction_file_lineNumber_description_, functionName != null ? functionName.id : 0, fileName != null ? fileName.id : 0, line, format != null ? format.id : 0);
-}
-
-public void handleFailureInMethod(long /*int*/ selector, id object, NSString fileName, long /*int*/ line, NSString format) {
- OS.objc_msgSend(this.id, OS.sel_handleFailureInMethod_object_file_lineNumber_description_, selector, object != null ? object.id : 0, fileName != null ? fileName.id : 0, line, format != null ? format.id : 0);
-}
-
-}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableString.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableString.java
index 971c12677a..87ec1c3228 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableString.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSMutableString.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -49,11 +49,6 @@ public static NSString stringWithCharacters(char[] characters, long /*int*/ leng
return result != 0 ? new NSMutableString(result) : null;
}
-public static NSString stringWithFormat(NSString format) {
- long /*int*/ result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithFormat_, format != null ? format.id : 0);
- return result != 0 ? new NSString(result) : null;
-}
-
public static NSString stringWithUTF8String(long /*int*/ nullTerminatedCString) {
long /*int*/ result = OS.objc_msgSend(OS.class_NSMutableString, OS.sel_stringWithUTF8String_, nullTerminatedCString);
return result != 0 ? new NSString(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java
index e069c3e92b..3c43d86c29 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -147,11 +147,6 @@ public static NSString stringWithCharacters(char[] characters, long /*int*/ leng
return result != 0 ? new NSString(result) : null;
}
-public static NSString stringWithFormat(NSString format) {
- long /*int*/ result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithFormat_, format != null ? format.id : 0);
- return result != 0 ? new NSString(result) : null;
-}
-
public static NSString stringWithUTF8String(long /*int*/ nullTerminatedCString) {
long /*int*/ result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithUTF8String_, nullTerminatedCString);
return result != 0 ? new NSString(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index d2cc4720df..64865bd6b9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -788,7 +788,6 @@ public static final long /*int*/ class_NSAppearance = objc_getClass("NSAppearanc
public static final long /*int*/ class_NSAppleEventDescriptor = objc_getClass("NSAppleEventDescriptor");
public static final long /*int*/ class_NSApplication = objc_getClass("NSApplication");
public static final long /*int*/ class_NSArray = objc_getClass("NSArray");
-public static final long /*int*/ class_NSAssertionHandler = objc_getClass("NSAssertionHandler");
public static final long /*int*/ class_NSAttributedString = objc_getClass("NSAttributedString");
public static final long /*int*/ class_NSAutoreleasePool = objc_getClass("NSAutoreleasePool");
public static final long /*int*/ class_NSBezierPath = objc_getClass("NSBezierPath");
@@ -1248,7 +1247,6 @@ public static final long /*int*/ sel_currentContext = Selector.sel_currentContex
public static final long /*int*/ sel_currentCursor = Selector.sel_currentCursor.value;
public static final long /*int*/ sel_currentEditor = Selector.sel_currentEditor.value;
public static final long /*int*/ sel_currentEvent = Selector.sel_currentEvent.value;
-public static final long /*int*/ sel_currentHandler = Selector.sel_currentHandler.value;
public static final long /*int*/ sel_currentInputManager = Selector.sel_currentInputManager.value;
public static final long /*int*/ sel_currentPoint = Selector.sel_currentPoint.value;
public static final long /*int*/ sel_currentRunLoop = Selector.sel_currentRunLoop.value;
@@ -1426,8 +1424,6 @@ public static final long /*int*/ sel_graphicsContextWithWindow_ = Selector.sel_g
public static final long /*int*/ sel_graphicsPort = Selector.sel_graphicsPort.value;
public static final long /*int*/ sel_greenComponent = Selector.sel_greenComponent.value;
public static final long /*int*/ sel_handleEvent_ = Selector.sel_handleEvent_.value;
-public static final long /*int*/ sel_handleFailureInFunction_file_lineNumber_description_ = Selector.sel_handleFailureInFunction_file_lineNumber_description_.value;
-public static final long /*int*/ sel_handleFailureInMethod_object_file_lineNumber_description_ = Selector.sel_handleFailureInMethod_object_file_lineNumber_description_.value;
public static final long /*int*/ sel_handleMouseEvent_ = Selector.sel_handleMouseEvent_.value;
public static final long /*int*/ sel_hasAlpha = Selector.sel_hasAlpha.value;
public static final long /*int*/ sel_hasMarkedText = Selector.sel_hasMarkedText.value;
@@ -2205,7 +2201,6 @@ public static final long /*int*/ sel_stringForObjectValue_ = Selector.sel_string
public static final long /*int*/ sel_stringForType_ = Selector.sel_stringForType_.value;
public static final long /*int*/ sel_stringValue = Selector.sel_stringValue.value;
public static final long /*int*/ sel_stringWithCharacters_length_ = Selector.sel_stringWithCharacters_length_.value;
-public static final long /*int*/ sel_stringWithFormat_ = Selector.sel_stringWithFormat_.value;
public static final long /*int*/ sel_stringWithUTF8String_ = Selector.sel_stringWithUTF8String_.value;
public static final long /*int*/ sel_stroke = Selector.sel_stroke.value;
public static final long /*int*/ sel_strokeRect_ = Selector.sel_strokeRect_.value;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index 619d19f2b4..ccd2053469 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -359,7 +359,6 @@ public enum Selector {
, sel_currentCursor("currentCursor")
, sel_currentEditor("currentEditor")
, sel_currentEvent("currentEvent")
- , sel_currentHandler("currentHandler")
, sel_currentInputManager("currentInputManager")
, sel_currentPoint("currentPoint")
, sel_currentRunLoop("currentRunLoop")
@@ -537,8 +536,6 @@ public enum Selector {
, sel_graphicsPort("graphicsPort")
, sel_greenComponent("greenComponent")
, sel_handleEvent_("handleEvent:")
- , sel_handleFailureInFunction_file_lineNumber_description_("handleFailureInFunction:file:lineNumber:description:")
- , sel_handleFailureInMethod_object_file_lineNumber_description_("handleFailureInMethod:object:file:lineNumber:description:")
, sel_handleMouseEvent_("handleMouseEvent:")
, sel_hasAlpha("hasAlpha")
, sel_hasMarkedText("hasMarkedText")
@@ -1316,7 +1313,6 @@ public enum Selector {
, sel_stringForType_("stringForType:")
, sel_stringValue("stringValue")
, sel_stringWithCharacters_length_("stringWithCharacters:length:")
- , sel_stringWithFormat_("stringWithFormat:")
, sel_stringWithUTF8String_("stringWithUTF8String:")
, sel_stroke("stroke")
, sel_strokeRect_("strokeRect:")
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
index c4338b13ca..84c4a40b40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java
@@ -964,7 +964,7 @@ void createDisplay (DeviceData data) {
}
void createMainMenu () {
- NSString appName = getApplicationName();
+ String appName = getApplicationName().getString();
NSString emptyStr = NSString.string();
NSMenu mainMenu = (NSMenu)new NSMenu().alloc();
mainMenu.initWithTitle(emptyStr);
@@ -972,14 +972,14 @@ void createMainMenu () {
NSMenuItem menuItem;
NSMenu appleMenu;
- NSString format = NSString.stringWith("%@ %@"), title;
+ NSString title;
NSMenuItem appItem = menuItem = mainMenu.addItemWithTitle(emptyStr, 0, emptyStr);
appleMenu = (NSMenu)new NSMenu().alloc();
appleMenu.initWithTitle(emptyStr);
OS.objc_msgSend(application.id, OS.sel_registerName("setAppleMenu:"), appleMenu.id);
- title = new NSString(OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithFormat_, format.id, NSString.stringWith(SWT.getMessage("About")).id, appName.id));
+ title = NSString.stringWith(SWT.getMessage("About") + " " + appName);
menuItem = appleMenu.addItemWithTitle(title, OS.sel_orderFrontStandardAboutPanel_, emptyStr);
menuItem.setTarget(applicationDelegate);
@@ -1006,7 +1006,7 @@ void createMainMenu () {
appleMenu.addItem(NSMenuItem.separatorItem());
- title = new NSString(OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithFormat_, format.id, NSString.stringWith(SWT.getMessage("Hide")).id, appName.id));
+ title = NSString.stringWith(SWT.getMessage("Hide") + " " + appName);
menuItem = appleMenu.addItemWithTitle(title, OS.sel_hide_, NSString.stringWith("h"));
menuItem.setTarget(applicationDelegate);
@@ -1021,7 +1021,7 @@ void createMainMenu () {
appleMenu.addItem(NSMenuItem.separatorItem());
- title = new NSString(OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithFormat_, format.id, NSString.stringWith(SWT.getMessage("Quit")).id, appName.id));
+ title = NSString.stringWith(SWT.getMessage("Quit") + " " + appName);
menuItem = appleMenu.addItemWithTitle(title, OS.sel_applicationShouldTerminate_, NSString.stringWith("q"));
menuItem.setTarget(applicationDelegate);

Back to the top