-
Notifications
You must be signed in to change notification settings - Fork 6
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
make Int64 aka JavaLong conform to JavaParameterConvertible #11
Conversation
// Int64 aka JavaFloat | ||
|
||
extension Int64: JavaParameterConvertible, JavaInitializableFromMethod, JavaInitializableFromField { | ||
public static let asJNIParameterString = "L" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"L" is the type signature for a class. "J" should be the right string here according to https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276
public static func fromField(_ fieldID: JavaFieldID, on javaObject: JavaObject) throws -> Int64 { | ||
return try jni.GetInt64Field(of: javaObject, id: fieldID) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use "Long" in function Names instead of "Int64" since the original JNI API also uses "Long" (GetLongField()
etc.) and I think we should stick to it.
Though I see that from a Swift standpoint this might be weird.
Not sure what @ephemer thinks about that.
1d9db4f
to
327e1ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would wait for @ephemer s opinion about the naming
I agree with @rikner in that we should call it We're getting what we defined in Java as a |
|
||
// Int64 aka JavaLong | ||
|
||
extension Int64: JavaParameterConvertible, JavaInitializableFromMethod, JavaInitializableFromField { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should define this as an extension on JavaLong
, and return / cast values to JavaLong
wherever relevant - it's the same type, but it makes the API's intent clearer
public static let asJNIParameterString = "J" | ||
|
||
public func toJavaParameter() -> JavaParameter { | ||
return JavaParameter(long: Int64(self)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to recast a JavaLong to a JavaLong :)
The commit message about |
a1b4639
to
2497791
Compare
This adds the ability to pass
Int64/JavaLongs
between worlds.I'm not quite sure if the naming of the functions is correct. Do we want to
getInt64Fields
or do we want togetLongFields
?