Skip to content

Commit 802d1f8

Browse files
authored
Initial support for M1 CPU (qzind#783)
Fixes JNA crash, add experimental JavaFX support
1 parent 2aa773e commit 802d1f8

File tree

7 files changed

+73
-9
lines changed

7 files changed

+73
-9
lines changed

ant/javafx.xml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,33 @@
5454
<property file="ant/project.properties"/>
5555
<property name="javafx.version" value="11.0.2"/>
5656
<property name="javafx.mirror" value="https://gluonhq.com/download"/>
57+
<property name="javafx.arch" value="aarch64"/>
58+
<property name="javafx.separator" value="_"/>
5759
<property name="lib.dir" value="lib"/>
5860
<property name="dist.dir" value="out/dist"/>
5961
-->
6062
<!-- end required properties -->
6163

64+
<!-- ARM64 -->
65+
<condition property="javafx.version" value="${javafx.aarch64.version}">
66+
<equals arg1="aarch64" arg2="${jre.arch}"/>
67+
</condition>
68+
<condition property="javafx.mirror" value="${javafx.aarch64.mirror}">
69+
<equals arg1="aarch64" arg2="${jre.arch}"/>
70+
</condition>
71+
<condition property="javafx.arch" value="${javafx.aarch64.arch}">
72+
<equals arg1="aarch64" arg2="${jre.arch}"/>
73+
</condition>
74+
<condition property="javafx.separator" value="${javafx.aarch64.separator}">
75+
<equals arg1="aarch64" arg2="${jre.arch}"/>
76+
</condition>
77+
78+
<!-- Intel (fallback) -->
79+
<property name="javafx.version" value="${javafx.x86_64.version}" description="fallback"/>
80+
<property name="javafx.mirror" value="${javafx.x86_64.mirror}" description="fallback"/>
81+
<property name="javafx.arch" value="${javafx.x86_64.arch}" description="fallback"/>
82+
<property name="javafx.separator" value="${javafx.x86_64.separator}" description="fallback"/>
83+
6284
<loadresource property="javafx.version-url">
6385
<propertyresource name="javafx.version"/>
6486
<filterchain>
@@ -116,7 +138,7 @@
116138

117139
<!-- Downloads and extracts javafx for the specified platform -->
118140
<target name="download-javafx-platform" depends="get-javafx-version">
119-
<get src="${javafx.mirror}/openjfx-${javafx.version-url}-${javafx.platform}-x64_bin-sdk.zip" verbose="true" dest="javafx-${javafx.platform}.zip"/>
141+
<get src="${javafx.mirror}/openjfx-${javafx.version-url}${javafx.separator}${javafx.platform}-${javafx.arch}_bin-sdk.zip" verbose="true" dest="javafx-${javafx.platform}.zip"/>
120142
<unzip src="javafx-${javafx.platform}.zip" dest="lib/javafx/${javafx.platform}/javafx-${javafx.version}" overwrite="true"/>
121143
<delete file="javafx-${javafx.platform}.zip"/>
122144
</target>

ant/project.properties

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,21 @@ jar.index=true
2424
# See also qz.common.Constants.java
2525
javac.source=1.8
2626
javac.target=1.8
27-
javafx.version=15.ea+3_monocle
28-
javafx.mirror=https://download2.gluonhq.com/openjfx/15
2927
java.download=https://adoptopenjdk.net/?variant=openjdk11
3028

29+
jre.arch=${os.arch}
30+
31+
# JavaFX x86_64
32+
javafx.x86_64.version=15.ea+3_monocle
33+
javafx.x86_64.mirror=https://download2.gluonhq.com/openjfx/15
34+
javafx.x86_64.arch=x64
35+
javafx.x86_64.separator=-
36+
37+
# JavaFX ARM64
38+
javafx.aarch64.version=17-ea+6
39+
javafx.aarch64.mirror=https://download2.gluonhq.com/openjfx/17
40+
javafx.aarch64.arch=aarch64
41+
javafx.aarch64.separator=_
42+
3143
# Workaround to delay expansion of $${foo} (e.g. shell scripts)
3244
dollar=$
Binary file not shown.

src/org/dyorgio/jna/platform/mac/Foundation.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,21 @@ public interface Foundation extends Library {
5151

5252
boolean class_addMethod(NativeLong clazz, Pointer selector, Callback callback, String types);
5353

54-
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, Object... args);
54+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector);
55+
56+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, Pointer obj);
57+
58+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, NativeLong objAddress);
59+
60+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, boolean boolArg);
61+
62+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, double doubleArg);
63+
64+
// Used by NSObject.performSelectorOnMainThread
65+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, Pointer selectorDst, NativeLong objAddress, boolean wait);
66+
67+
// Used by NSString.fromJavaString
68+
NativeLong objc_msgSend(NativeLong receiver, Pointer selector, byte[] bytes, int len, long encoding);
5569

5670
Pointer sel_registerName(String selectorName);
5771
}

src/org/dyorgio/jna/platform/mac/FoundationUtil.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,28 @@ public static boolean isTrue(NativeLong id) {
5858
return !NULL.equals(id);
5959
}
6060

61-
public static NativeLong invoke(NativeLong id, String selector, Object... args) {
62-
return FOUNDATION.objc_msgSend(id, Foundation.INSTANCE.sel_registerName(selector), args);
61+
public static NativeLong invoke(NativeLong id, String selector) {
62+
return FOUNDATION.objc_msgSend(id, Foundation.INSTANCE.sel_registerName(selector));
6363
}
6464

65-
public static NativeLong invoke(NativeLong id, Pointer selectorPointer, Object... args) {
66-
return FOUNDATION.objc_msgSend(id, selectorPointer, args);
65+
public static NativeLong invoke(NativeLong id, String selector, boolean boolArg) {
66+
return FOUNDATION.objc_msgSend(id, Foundation.INSTANCE.sel_registerName(selector), boolArg);
67+
}
68+
69+
public static NativeLong invoke(NativeLong id, String selector, double doubleArg) {
70+
return FOUNDATION.objc_msgSend(id, Foundation.INSTANCE.sel_registerName(selector), doubleArg);
71+
}
72+
73+
public static NativeLong invoke(NativeLong id, String selector, NativeLong objAddress) {
74+
return FOUNDATION.objc_msgSend(id, Foundation.INSTANCE.sel_registerName(selector), objAddress);
75+
}
76+
77+
public static NativeLong invoke(NativeLong id, Pointer selectorPointer) {
78+
return FOUNDATION.objc_msgSend(id, selectorPointer);
79+
}
80+
81+
public static NativeLong invoke(NativeLong id, Pointer selectorPointer, NativeLong objAddress) {
82+
return FOUNDATION.objc_msgSend(id, selectorPointer, objAddress);
6783
}
6884

6985
public static void runOnMainThreadAndWait(Runnable runnable) throws InterruptedException, ExecutionException {

src/qz/utils/MacUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public static void toggleTemplateIcon(TrayIcon icon) {
224224
final NativeLong image = Foundation.INSTANCE.object_getIvar(awtView, Foundation.INSTANCE.class_getInstanceVariable(FoundationUtil.invoke(awtView, "class"), "image"));
225225
FoundationUtil.invoke(image, "setTemplate:", true);
226226
FoundationUtil.runOnMainThreadAndWait(() -> {
227-
FoundationUtil.invoke(statusItem, "setView:", (Object) null);
227+
FoundationUtil.invoke(statusItem, "setView:", FoundationUtil.NULL);
228228
NativeLong target;
229229
if (SystemUtilities.getOSVersion().greaterThanOrEqualTo(Version.forIntegers(10, 10))) {
230230
target = FoundationUtil.invoke(statusItem, "button");

0 commit comments

Comments
 (0)