Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple silicon (macOS ARM64) support + install.sh script #8

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
JSyphon/native_src/JSyphon.xcodeproj/project.xcworkspace/xcuserdata
JSyphon/native_src/JSyphon.xcodeproj/xcuserdata
JSyphon/src/jsyphon/JSyphon*.class
JSyphon/native_libs/libSyphon.dylib # symlink to Syphon generated from compile.h
JSyphon/native_libs/JSyphon.so # ignore this lib?
JSyphon/native_libs/Sypho
JSyphon/native_libs/libJSyphon.jnilib # ignore this lib?
JSyphon/microsoft-jdk-*.pkg
#JSyphon/jar/jsyphon.jar # not sure if we want this?
Syphon-Framework
Syphon
jdk
.DS_Store
62 changes: 48 additions & 14 deletions JSyphon/native_src/JSyphon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
1BB1292B135611510079EA84 /* jsyphon_JSyphonServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BB1278B1355324B0079EA84 /* jsyphon_JSyphonServer.m */; };
1BB129691356115B0079EA84 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
1BB1296A1356115B0079EA84 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BB127A6135532BB0079EA84 /* OpenGL.framework */; };
1BB1296B1356115B0079EA84 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BB127AC135532FD0079EA84 /* JavaVM.framework */; };
1BB1296C1356115B0079EA84 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BB127B2135533180079EA84 /* JavaNativeFoundation.framework */; };
1BB129DC1356E7860079EA84 /* jsyphon_JSyphonClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BB129D91356E7860079EA84 /* jsyphon_JSyphonClient.h */; };
1BB129DD1356E7860079EA84 /* jsyphon_JSyphonImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1BB129DA1356E7860079EA84 /* jsyphon_JSyphonImage.h */; };
1BB12A0E135776E50079EA84 /* jsyphon_JSyphonClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BB12A0D135776E50079EA84 /* jsyphon_JSyphonClient.m */; };
2E02077A2A490BF200BDEA9B /* libjli.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2E0207792A490BF200BDEA9B /* libjli.dylib */; };
2E76E7572A491F0000C7D061 /* jsyphon_utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E76E7532A491F0000C7D061 /* jsyphon_utils.h */; };
2E76E7582A491F0000C7D061 /* jsyphon_utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E76E7552A491F0000C7D061 /* jsyphon_utils.m */; };
2E76E7592A491F0000C7D061 /* jsyphon_imports.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E76E7562A491F0000C7D061 /* jsyphon_imports.h */; };
415E166D166FC3830060AAB9 /* jsyphon_JSyphonServerList.m in Sources */ = {isa = PBXBuildFile; fileRef = 415E166C166FC3830060AAB9 /* jsyphon_JSyphonServerList.m */; };
41928310166FCDD9008F1FE8 /* jsyphon_JSyphonServerList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4192830F166FCDD9008F1FE8 /* jsyphon_JSyphonServerList.h */; };
41B03CCB13CD8D9200CE4F36 /* SyphonNameboundClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 41B03CC713CD8D9200CE4F36 /* SyphonNameboundClient.h */; };
Expand Down Expand Up @@ -46,13 +48,15 @@
1BB1278A1355324B0079EA84 /* jsyphon_JSyphonServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_JSyphonServer.h; sourceTree = "<group>"; };
1BB1278B1355324B0079EA84 /* jsyphon_JSyphonServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsyphon_JSyphonServer.m; sourceTree = "<group>"; };
1BB127A6135532BB0079EA84 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
1BB127AC135532FD0079EA84 /* JavaVM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaVM.framework; path = /System/Library/Frameworks/JavaVM.framework; sourceTree = "<absolute>"; };
1BB127B2135533180079EA84 /* JavaNativeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaNativeFoundation.framework; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework; sourceTree = "<absolute>"; };
1BB12926135611160079EA84 /* libJSyphon.jnilib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libJSyphon.jnilib; sourceTree = BUILT_PRODUCTS_DIR; };
1BB129D91356E7860079EA84 /* jsyphon_JSyphonClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_JSyphonClient.h; sourceTree = "<group>"; };
1BB129DA1356E7860079EA84 /* jsyphon_JSyphonImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_JSyphonImage.h; sourceTree = "<group>"; };
1BB12A0B13576F0C0079EA84 /* jsyphon_JSyphonImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsyphon_JSyphonImage.m; sourceTree = "<group>"; };
1BB12A0D135776E50079EA84 /* jsyphon_JSyphonClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsyphon_JSyphonClient.m; sourceTree = "<group>"; };
2E0207792A490BF200BDEA9B /* libjli.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libjli.dylib; path = "../../../../../../../../../../Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/lib/libjli.dylib"; sourceTree = "<group>"; };
2E76E7532A491F0000C7D061 /* jsyphon_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_utils.h; sourceTree = SOURCE_ROOT; };
2E76E7552A491F0000C7D061 /* jsyphon_utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsyphon_utils.m; sourceTree = SOURCE_ROOT; };
2E76E7562A491F0000C7D061 /* jsyphon_imports.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_imports.h; sourceTree = SOURCE_ROOT; };
32DBCF630370AF2F00C91783 /* JSyphon_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSyphon_Prefix.pch; sourceTree = "<group>"; };
415E166C166FC3830060AAB9 /* jsyphon_JSyphonServerList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsyphon_JSyphonServerList.m; sourceTree = "<group>"; };
4192830F166FCDD9008F1FE8 /* jsyphon_JSyphonServerList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsyphon_JSyphonServerList.h; sourceTree = "<group>"; };
Expand All @@ -70,11 +74,10 @@
buildActionMask = 2147483647;
comments = "#!/bin/bash\necho \"$BUILT_PRODUCTS_DIR/libJSyphon.dylib\"\necho \"$SOURCE_ROOT/../native_libs/libJSyphon.dylib\"\n\ncp -RfL \"$BUILT_PRODUCTS_DIR/libJSyphon.dylib\" \"$SOURCE_ROOT/../native_libs/\"";
files = (
2E02077A2A490BF200BDEA9B /* libjli.dylib in Frameworks */,
E2DDA92317D8DDD700C03F2F /* Syphon.framework in Frameworks */,
1BB129691356115B0079EA84 /* Cocoa.framework in Frameworks */,
1BB1296A1356115B0079EA84 /* OpenGL.framework in Frameworks */,
1BB1296B1356115B0079EA84 /* JavaVM.framework in Frameworks */,
1BB1296C1356115B0079EA84 /* JavaNativeFoundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -90,6 +93,7 @@
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
19C28FB8FE9D52D311CA2CBB /* Products */,
2E0207772A490BF100BDEA9B /* Frameworks */,
);
name = JSyphon;
sourceTree = "<group>";
Expand Down Expand Up @@ -128,8 +132,6 @@
children = (
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
1BB127A6135532BB0079EA84 /* OpenGL.framework */,
1BB127AC135532FD0079EA84 /* JavaVM.framework */,
1BB127B2135533180079EA84 /* JavaNativeFoundation.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
Expand Down Expand Up @@ -179,6 +181,14 @@
name = Client;
sourceTree = "<group>";
};
2E0207772A490BF100BDEA9B /* Frameworks */ = {
isa = PBXGroup;
children = (
2E0207792A490BF200BDEA9B /* libjli.dylib */,
);
name = Frameworks;
sourceTree = "<group>";
};
32C88E010371C26100C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
Expand All @@ -200,6 +210,9 @@
41B03CC413CD8D9200CE4F36 /* Shared */ = {
isa = PBXGroup;
children = (
2E76E7562A491F0000C7D061 /* jsyphon_imports.h */,
2E76E7532A491F0000C7D061 /* jsyphon_utils.h */,
2E76E7552A491F0000C7D061 /* jsyphon_utils.m */,
41B03CC713CD8D9200CE4F36 /* SyphonNameboundClient.h */,
41B03CC813CD8D9200CE4F36 /* SyphonNameboundClient.m */,
);
Expand All @@ -223,6 +236,8 @@
buildActionMask = 2147483647;
files = (
1BB129DC1356E7860079EA84 /* jsyphon_JSyphonClient.h in Headers */,
2E76E7592A491F0000C7D061 /* jsyphon_imports.h in Headers */,
2E76E7572A491F0000C7D061 /* jsyphon_utils.h in Headers */,
1BB129DD1356E7860079EA84 /* jsyphon_JSyphonImage.h in Headers */,
41B03CCB13CD8D9200CE4F36 /* SyphonNameboundClient.h in Headers */,
41928310166FCDD9008F1FE8 /* jsyphon_JSyphonServerList.h in Headers */,
Expand Down Expand Up @@ -317,6 +332,7 @@
buildActionMask = 2147483647;
files = (
1BB1292B135611510079EA84 /* jsyphon_JSyphonServer.m in Sources */,
2E76E7582A491F0000C7D061 /* jsyphon_utils.m in Sources */,
1BB12A0E135776E50079EA84 /* jsyphon_JSyphonClient.m in Sources */,
41B03CCC13CD8D9200CE4F36 /* SyphonNameboundClient.m in Sources */,
415E166D166FC3830060AAB9 /* jsyphon_JSyphonServerList.m in Sources */,
Expand Down Expand Up @@ -357,15 +373,24 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SRCROOT)/../../../Syphon-Framework/build/$(CONFIGURATION)/\"/**",
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\"",
"\"$(SRCROOT)/../../../Syphon-Framework/build/Release\"",
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
HEADER_SEARCH_PATHS = (
"/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/include/**",
"$(SRCROOT)/../jdk/src/java.desktop/macosx/native/libosxapp",
"$(SRCROOT)/../jdk/src/java.base/share/native/libjava",
"$(SRCROOT)/../jdk/src/java.base/unix/native/libjava",
);
INSTALL_PATH = "";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(LOCAL_LIBRARY_DIR)/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/lib",
);
OTHER_LDFLAGS = (
"-framework",
Foundation,
Expand All @@ -389,13 +414,22 @@
FRAMEWORK_SEARCH_PATHS = (
"\"$(SRCROOT)/../../../Syphon-Framework/build/$(CONFIGURATION)/\"/**",
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\"",
"\"$(SRCROOT)/../../../Syphon-Framework/build/Release\"",
);
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
HEADER_SEARCH_PATHS = (
"/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/include/**",
"$(SRCROOT)/../jdk/src/java.desktop/macosx/native/libosxapp",
"$(SRCROOT)/../jdk/src/java.base/share/native/libjava",
"$(SRCROOT)/../jdk/src/java.base/unix/native/libjava",
);
INSTALL_PATH = "";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(LOCAL_LIBRARY_DIR)/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/lib",
);
OTHER_LDFLAGS = (
"-framework",
Foundation,
Expand Down Expand Up @@ -438,10 +472,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 13.3;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
VALID_ARCHS = "i386 x86_64";
VALID_ARCHS = "i386 x86_64 arm64";
};
name = Debug;
};
Expand Down Expand Up @@ -475,10 +509,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 13.3;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
VALID_ARCHS = "i386 x86_64";
VALID_ARCHS = "i386 x86_64 arm64";
};
name = Release;
};
Expand Down
33 changes: 28 additions & 5 deletions JSyphon/native_src/compile.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
gcc -arch x86_64 -o ../native_libs/JSyphon.so -shared -I/System/Library/Frameworks/JavaVM.framework/Headers \
-F../native_libs/ -F/System/Library/Frameworks/JavaVM.framework/Frameworks/ \
-framework Cocoa -framework Foundation -framework OpenGL -framework JavaVM -framework Syphon -framework JavaNativeFoundation \
jsyphon_JSyphonServer.m -lc
# was x86_64 but let's use real arch to build on arm64 as well
ARCH=`uname -m`
OS=`uname -s`

ln -s Syphon-Framework ../../Syphon
ln -s Syphon ../native_libs/libSyphon.dylib
# macOS ARM: if OS is Darwin and arch is ARM, use `javac -h` on the .java files directly
if [ "$OS" = "Darwin" ] && ([ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]); then
echo "macOS ARM64 detected"

# we may need to link to libjli.dylib, eg /Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/MacOS/libjli.dylib
gcc -arch $ARCH -o ../native_libs/JSyphon.so -shared \
-L../native_libs/ \
-L/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/MacOS \
-I../../ \
-I/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/include/darwin \
-I../jdk/src/java.desktop/macosx/native/libosxapp -I../jdk/src/java.base/share/native/libjava -I../jdk/src/java.base/unix/native/libjava \
-framework Cocoa -framework Foundation -framework OpenGL \
jsyphon_utils.m jsyphon_JSyphonServer.m -lc -ljli -lSyphon

install_name_tool -change @loader_path/../Frameworks/Syphon.framework/Versions/A/Syphon "`pwd`/../native_libs/Syphon.framework/Versions/A/Syphon" ../native_libs/libJSyphon.jnilib
else
gcc -arch $ARCH -o ../native_libs/JSyphon.so -shared -I/System/Library/Frameworks/JavaVM.framework/Headers \
-F../native_libs/ -F/System/Library/Frameworks/JavaVM.framework/Frameworks/ \
-framework Cocoa -framework Foundation -framework OpenGL -framework JavaVM -framework Syphon -framework JavaNativeFoundation \
jsyphon_JSyphonServer.m -lc
install_name_tool -change @loader_path/../Frameworks/Syphon.framework/Versions/A/Syphon "`pwd`/../native_libs/Syphon.framework/Versions/A/Syphon" ../native_libs/JSyphon.so
fi

install_name_tool -change @loader_path/../Frameworks/Syphon.framework/Versions/A/Syphon "`pwd`/../native_libs/Syphon.framework/Versions/A/Syphon" ../native_libs/JSyphon.so
26 changes: 22 additions & 4 deletions JSyphon/native_src/gen_headers.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
cd ../bin

javah jsyphon.JSyphonClient
javah jsyphon.JSyphonImage
javah jsyphon.JSyphonServer
javah jsyphon.JSyphonServerList
files=(JSyphonClient JSyphonImage JSyphonServer JSyphonServerList)

ARCH=`uname -m`
OS=`uname -s`

# macOS ARM: if OS is Darwin and arch is ARM, use `javac -h` on the .java files directly
if [ "$OS" = "Darwin" ] && ([ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]); then
echo "macOS ARM64 detected"
JAVAH="javac -h ."
PRE="../src/jsyphon/"
END=".java"
else
JAVAH="javah"
END=""
PRE="jsyphon."
fi

for i in "${files[@]}"
do
echo $JAVAH $PRE$i$END
$JAVAH $PRE$i$END
done
mv jsyphon_*.h ../native_src/

cd ../native_src
81 changes: 51 additions & 30 deletions JSyphon/native_src/jsyphon_JSyphonClient.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
#import <JavaVM/JavaVM.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h> // JNI Cocoa helper
#import <JavaVM/jni.h>

#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <Syphon/Syphon.h>

#import "jsyphon_imports.h"
#import <SyphonNameboundClient.h>

#import <OpenGL/CGLMacro.h>

// pass options in case they are needed in the future...
JNIEXPORT jlong JNICALL Java_jsyphon_JSyphonClient_init(JNIEnv * env, jobject jobj, jobject options)
{
Expand Down Expand Up @@ -81,7 +72,26 @@ JNIEXPORT jboolean JNICALL Java_jsyphon_JSyphonClient_isValid(JNIEnv * env, jobj
JNIEXPORT jobject JNICALL Java_jsyphon_JSyphonClient_serverDescription(JNIEnv * env, jobject jobj, jlong ptr)
{
jobject serverdesc = nil;

// This methods returns a ArrayList<String>:
// (realm kdc* null) null (mapping-domain mapping-realm)*
jclass jc_arrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
CHECK_NULL_RETURN(jc_arrayListClass, NULL);
jmethodID jm_arrayListCons = (*env)->GetMethodID(env, jc_arrayListClass, "<init>", "()V");
CHECK_NULL_RETURN(jm_arrayListCons, NULL);
jmethodID jm_listAdd = (*env)->GetMethodID(env, jc_arrayListClass, "add", "(Ljava/lang/Object;)Z");
CHECK_NULL_RETURN(jm_listAdd, NULL);
serverdesc = (*env)->NewObject(env, jc_arrayListClass, jm_arrayListCons);
CHECK_NULL_RETURN(serverdesc, NULL);

SyphonNameboundClient* boundClient = jlong_to_ptr(ptr);
[boundClient lockClient];
SyphonClient *client = [(SyphonNameboundClient*)boundClient client];
ADD(serverdesc, client);
ADDNULL(serverdesc);
[boundClient unlockClient];
return serverdesc;

/*
JNF_COCOA_ENTER(env);

SyphonNameboundClient* boundClient = jlong_to_ptr(ptr);
Expand All @@ -100,6 +110,7 @@ JNIEXPORT jobject JNICALL Java_jsyphon_JSyphonClient_serverDescription(JNIEnv *
JNF_COCOA_EXIT(env);

return serverdesc;
*/
}


Expand Down Expand Up @@ -127,37 +138,47 @@ JNIEXPORT jobject JNICALL Java_jsyphon_JSyphonClient_newFrameDataForContext(JNIE
{
jobject imgdata = nil;

JNF_COCOA_ENTER(env);
//JNF_COCOA_ENTER(env);

SyphonNameboundClient* boundClient = jlong_to_ptr(ptr);
SyphonNameboundClient* boundClient = jlong_to_ptr(ptr);
[boundClient lockClient];
SyphonClient *client = [(SyphonNameboundClient*)boundClient client];

SyphonImage* img = [client newFrameImage];
SyphonImage* img = [client newFrameImage];

NSSize texSize = [img textureSize];

NSNumber *name = [NSNumber numberWithInt:[img textureName]];
NSNumber *width = [NSNumber numberWithFloat:texSize.width];
NSNumber *height = [NSNumber numberWithFloat:texSize.height];

NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:
name, @"name",
width, @"width",
height, @"height",
nil];


JNFTypeCoercer* coecer = [JNFDefaultCoercions defaultCoercer];
[JNFDefaultCoercions addMapCoercionTo:coecer];

imgdata = [coecer coerceNSObject:dic withEnv:env];
NSNumber *name = [NSNumber numberWithInt:[img textureName]];
NSNumber *width = [NSNumber numberWithFloat:texSize.width];
NSNumber *height = [NSNumber numberWithFloat:texSize.height];

NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:
name, @"name",
width, @"width",
height, @"height",
nil];

jclass jc_arrayListClass = (*env)->FindClass(env, "java/util/ArrayList");
CHECK_NULL_RETURN(jc_arrayListClass, NULL);
jmethodID jm_arrayListCons = (*env)->GetMethodID(env, jc_arrayListClass, "<init>", "()V");
CHECK_NULL_RETURN(jm_arrayListCons, NULL);
jmethodID jm_listAdd = (*env)->GetMethodID(env, jc_arrayListClass, "add", "(Ljava/lang/Object;)Z");
CHECK_NULL_RETURN(jm_listAdd, NULL);
imgdata = (*env)->NewObject(env, jc_arrayListClass, jm_arrayListCons);
CHECK_NULL_RETURN(imgdata, NULL);

//JNFTypeCoercer* coecer = [JNFDefaultCoercions defaultCoercer];
//[JNFDefaultCoercions addMapCoercionTo:coecer];

ADD(imgdata, dic);
ADDNULL(imgdata);
//imgdata = [coecer coerceNSObject:dic withEnv:env];

[img release];

[boundClient unlockClient];

JNF_COCOA_EXIT(env);
//JNF_COCOA_EXIT(env);

return imgdata;
}
Expand Down
10 changes: 1 addition & 9 deletions JSyphon/native_src/jsyphon_JSyphonImage.m
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#import <JavaVM/JavaVM.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h> // JNI Cocoa helper
#import <JavaVM/jni.h>

#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <Syphon/Syphon.h>

#import <OpenGL/CGLMacro.h>
#import "jsyphon_imports.h"


JNIEXPORT jint JNICALL Java_jsyphon_JSyphonImage_textureName(JNIEnv * env, jobject jobj)
Expand Down
Loading