-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cy3: Changes to get pyjnius and pyobjus working with cy3.
- Loading branch information
Showing
13 changed files
with
144 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Avoid searching for the java home on Windows. | ||
Avoid searching for the JDK home on windows. | ||
|
||
From: Tom Rothamel <[email protected]> | ||
|
||
|
@@ -8,15 +8,15 @@ From: Tom Rothamel <[email protected]> | |
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/jnius/__init__.py b/jnius/__init__.py | ||
index 251beb4..376c3e7 100644 | ||
index c1300ef..855c0c8 100644 | ||
--- a/jnius/__init__.py | ||
+++ b/jnius/__init__.py | ||
@@ -13,7 +13,7 @@ from .env import get_jnius_lib_location, get_jdk_home | ||
|
||
import os | ||
import sys | ||
-if sys.platform == 'win32' and sys.version_info >= (3, 8): | ||
+if False and sys.platform == 'win32' and sys.version_info >= (3, 8): | ||
path = os.path.dirname(__file__) | ||
jdk_home = get_jdk_home(sys.platform) | ||
with os.add_dll_directory(path): | ||
@@ -13,7 +13,7 @@ from .env import get_java_setup | ||
|
||
import os | ||
import sys | ||
-if sys.platform == 'win32' and sys.version_info >= (3, 8): | ||
+if False and sys.platform == 'win32' and sys.version_info >= (3, 8): | ||
path = os.path.dirname(__file__) | ||
java = get_java_setup(sys.platform) | ||
jdk_home = java.get_javahome() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Change division to match Python 3 semantics. | ||
|
||
From: Tom Rothamel <[email protected]> | ||
|
||
|
||
--- | ||
jnius/jnius_conversion.pxi | 22 +++++++++++----------- | ||
1 file changed, 11 insertions(+), 11 deletions(-) | ||
|
||
diff --git a/jnius/jnius_conversion.pxi b/jnius/jnius_conversion.pxi | ||
index 2e0b48d..d9fb0cd 100644 | ||
--- a/jnius/jnius_conversion.pxi | ||
+++ b/jnius/jnius_conversion.pxi | ||
@@ -112,13 +112,13 @@ cdef void populate_args(JNIEnv *j_env, tuple definition_args, jvalue *j_args, ar | ||
|
||
# lambda or function | ||
elif callable(py_arg): | ||
- | ||
+ | ||
# we need to make a java object in python | ||
py_arg = convert_python_callable_to_jobject(argtype, py_arg) | ||
|
||
- # TODO: this line should not be needed to prevent py_arg from being GCd | ||
+ # TODO: this line should not be needed to prevent py_arg from being GCd | ||
activeLambdaJavaProxies.add(py_arg) | ||
- | ||
+ | ||
# next few lines is from "isinstance(py_arg, PythonJavaClass)" above | ||
# except jc is None is removed, as we know it has been called by | ||
# convert_python_callable_to_jobject() | ||
@@ -399,7 +399,7 @@ def get_param_signature(m): | ||
return rtr | ||
|
||
def convert_python_callable_to_jobject(definition, pyarg): | ||
- | ||
+ | ||
objmethods = set(["equals", "notify", "notifyAll", "toString", "wait", "getClass"]) | ||
# we assume that definition is java/util/function/Function | ||
# definition = "Ljava/util/function/Function;" | ||
@@ -411,7 +411,7 @@ def convert_python_callable_to_jobject(definition, pyarg): | ||
|
||
if not clz.isInterface(): | ||
raise JavaException('%s is not an interface that can be instantiated with a callable' % classname) | ||
- | ||
+ | ||
# A functional interface is an interface that has just one | ||
# abstract method (aside from the methods of Object) | ||
# https://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.8 | ||
@@ -427,16 +427,16 @@ def convert_python_callable_to_jobject(definition, pyarg): | ||
continue | ||
# ignore methods that are in Object | ||
if m.getName() in objmethods: | ||
- continue | ||
+ continue | ||
candidateFunctionalMethods.append(m) | ||
if len(candidateFunctionalMethods) != 1: | ||
- raise JavaException("%s is not a functional interface (%d methods) that can be instantiated with a callable: %s" | ||
+ raise JavaException("%s is not a functional interface (%d methods) that can be instantiated with a callable: %s" | ||
% (classname, len(candidateFunctionalMethods), str(list(map(lambda m : m.getName(), candidateFunctionalMethods ))))) | ||
- | ||
+ | ||
# functional method has been identified | ||
functionalMethod = candidateFunctionalMethods[0] | ||
functionalMethodName = functionalMethod.getName() | ||
- | ||
+ | ||
# we need a new Python class that will implement the correct interface | ||
class PythonLambdaArg(PythonJavaClass): | ||
__javainterfaces__ = [classname] | ||
@@ -449,7 +449,7 @@ def convert_python_callable_to_jobject(definition, pyarg): | ||
|
||
# finally add the method to the instance. we use the same name | ||
setattr(intfInstance, functionalMethodName, pyarg) | ||
- | ||
+ | ||
# we have added a method after __init__ () was called | ||
# so we need to re-run introspection | ||
intfInstance._init_j_self_ptr() | ||
@@ -606,7 +606,7 @@ cdef jstring convert_pystr_to_java(JNIEnv *j_env, unicode py_uni) except NULL: | ||
py_bytes = py_uni.encode('utf-16') | ||
# skip byte-order mark | ||
buff = (<char *>py_bytes) + sizeof(jchar) | ||
- j_strlen = int(len(py_bytes) / sizeof(jchar) - 1) | ||
+ j_strlen = int(len(py_bytes) // sizeof(jchar) - 1) | ||
j_str = j_env[0].NewString(j_env, <jchar *>buff, j_strlen) | ||
|
||
if j_str == NULL: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# This series applies on GIT commit f5653e70b1e81c8d9df76e5ffde665fbfc5d85cc | ||
no-win-jdk-home.diff | ||
py3-division.diff |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/pyobjus/_runtime.h b/pyobjus/_runtime.h | ||
index c31b7ba..00ede0e 100644 | ||
--- a/pyobjus/_runtime.h | ||
+++ b/pyobjus/_runtime.h | ||
@@ -1,6 +1,6 @@ | ||
#include <objc/runtime.h> | ||
#include <objc/message.h> | ||
-#include <ffi/ffi.h> | ||
+#include <ffi.h> | ||
#include <stdio.h> | ||
#include <dlfcn.h> | ||
#include <string.h> | ||
diff --git a/pyobjus/common.pxi b/pyobjus/common.pxi | ||
index 61a835d..5daa50b 100644 | ||
--- a/pyobjus/common.pxi | ||
+++ b/pyobjus/common.pxi | ||
@@ -110,7 +110,7 @@ cdef extern from "objc/runtime.h": | ||
objc_method_description* protocol_copyMethodDescriptionList(Protocol *p, BOOL isRequiredMethod, BOOL isInstanceMethod, unsigned int *outCount) | ||
|
||
|
||
-cdef extern from "ffi/ffi.h": | ||
+cdef extern from "ffi.h": | ||
ctypedef unsigned long ffi_arg | ||
ctypedef signed long ffi_sarg | ||
ctypedef enum: FFI_TYPE_STRUCT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This series applies on GIT commit 573bd69b857ca4a64c7154a27f0bff6850851797 | ||
ffi-h.diff |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters