-
Notifications
You must be signed in to change notification settings - Fork 67
Make the "environment" parameter to @JavaMethod initializers optional #102
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
Conversation
…ly-typed and default to nil
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.
Looks ok to me, seems that's what @DougGregor had in mind -- leaving to him to approve the javakit bits.
Module wise I'm not sure if the separate VM module gained us anything, either seems fine.
| return [ | ||
| """ | ||
| self = \(raw: tryKeyword) Self.dynamicJavaNewObject(in: environment\(raw: arguments)) | ||
| let _environment = environment == nil ? \(raw: tryKeyword) JavaVirtualMachine.shared().environment() : environment! |
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.
maybe this would be nicer, without resorting to the !
| let _environment = environment == nil ? \(raw: tryKeyword) JavaVirtualMachine.shared().environment() : environment! | |
| let environment = | |
| if let environment { | |
| environment | |
| } else { | |
| \(raw: tryKeyword) JavaVirtualMachine.shared().environment() | |
| } |
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.
Ah, I had the same comment earlier ;)
DougGregor
left a comment
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 would like to remove the unnecessary force-unwraps, but otherwise this looks good to me and thank you!
| public init(_ enumValue: \(raw: name), environment: JNIEnvironment) { | ||
| let classObj = try! JavaClass<Self>(in: environment) | ||
| public init(_ enumValue: \(raw: name), environment: JNIEnvironment? = nil) { | ||
| let _environment = environment == nil ? try! JavaVirtualMachine.shared().environment() : environment! |
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'd rather do this without the force-unwraps, even if it's more verbose:
let _environment = if let environment {
environment
} else {
try! JavaVirtualMachine.shared().environment()
}| return [ | ||
| """ | ||
| self = \(raw: tryKeyword) Self.dynamicJavaNewObject(in: environment\(raw: arguments)) | ||
| let _environment = environment == nil ? \(raw: tryKeyword) JavaVirtualMachine.shared().environment() : environment! |
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.
Ah, I had the same comment earlier ;)
The VM module really didn't seem to be buying us anything, so I'm fine with collapsing it into JavaKit. |
…ed on PR conmments
|
LGTM, thanks a lot 👍 |
Closes #70
Make the "environment" parameter to @JavaMethod initializers optionally-typed and default to nil