Skip to content

Commit 21768ef

Browse files
committed
Updated for Version 2
1 parent 2c039ee commit 21768ef

File tree

166 files changed

+15581
-13292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+15581
-13292
lines changed

LICENSE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

2-
This representation of the Java apis is generated from the Apple distribution of the Java VM
3-
which are provided under the provisions of "Fair Use" but your use is ultimately subject
4-
to the original License Agreement.
2+
This representation of the Java apis is provided under the provisions of "Fair Use" but
3+
your use is ultimately subject to the Oracle Binary Code License Agreement available here:
4+
5+
http://www.oracle.com/technetwork/java/javase/terms/license/index.html
56

67
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
78
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
89
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
910
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1011
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ import PackageDescription
1111
let package = Package(
1212
name: "com_apple",
1313
dependencies: [
14-
.Package(url: "https://github.com/SwiftJava/javax_swing.git", versions: Version(1,0,0)..<Version(2,0,0)),
14+
.Package(url: "https://github.com/SwiftJava/javax_swing.git", versions: Version(2,0,0)..<Version(3,0,0)),
1515
]
1616
)

Sources/AboutHandler.swift

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import java_swift
33

44
/// generated by: genswift.java 'java/lang|java/util|java/sql|java/awt|javax/swing' ///
55

6-
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ///
7-
/// Tue Dec 20 11:52:04 GMT 2016 ///
6+
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ///
7+
/// Fri Aug 04 11:17:08 BST 2017 ///
88

99
/// interface com.apple.eawt.AboutHandler ///
1010

@@ -13,10 +13,10 @@ public protocol AboutHandler: JavaProtocol {
1313
/// public abstract void com.apple.eawt.AboutHandler.handleAbout(com.apple.eawt.AppEvent$AboutEvent)
1414

1515
func handleAbout( arg0: AppEvent_AboutEvent? )
16-
func handleAbout( _ _arg0: AppEvent_AboutEvent? )
1716

1817
}
1918

19+
2020
open class AboutHandlerForward: JNIObjectForward, AboutHandler {
2121

2222
private static var AboutHandlerJNIClass: jclass?
@@ -28,7 +28,7 @@ open class AboutHandlerForward: JNIObjectForward, AboutHandler {
2828
open func handleAbout( arg0: AppEvent_AboutEvent? ) {
2929
var __args = [jvalue]( repeating: jvalue(), count: 1 )
3030
var __locals = [jobject]()
31-
__args[0] = JNIType.encode( value: arg0, locals: &__locals )
31+
__args[0] = JNIType.toJava( value: arg0 != nil ? arg0! as JNIObject : nil, locals: &__locals )
3232
JNIMethod.CallVoidMethod( object: javaObject, methodName: "handleAbout", methodSig: "(Lcom/apple/eawt/AppEvent$AboutEvent;)V", methodCache: &AboutHandlerForward.handleAbout_MethodID_2, args: &__args, locals: &__locals )
3333
}
3434

@@ -39,49 +39,53 @@ open class AboutHandlerForward: JNIObjectForward, AboutHandler {
3939
}
4040

4141

42-
private typealias AboutHandler_handleAbout_0_type = @convention(c) ( _: UnsafeMutablePointer<JNIEnv?>, _: jobject?, _: jobject? ) -> ()
42+
private typealias AboutHandler_handleAbout_0_type = @convention(c) ( _: UnsafeMutablePointer<JNIEnv?>, _: jobject?, _: jlong, _: jobject? ) -> ()
4343

44-
private func AboutHandler_handleAbout_0( _ __env: UnsafeMutablePointer<JNIEnv?>, _ __this: jobject?, _ arg0: jobject? ) -> () {
45-
AboutHandlerBase.swiftObject( jniEnv: __env, javaObject: __this ).handleAbout( arg0 != nil ? AppEvent_AboutEvent( javaObject: arg0 ) : nil )
44+
private func AboutHandler_handleAbout_0( _ __env: UnsafeMutablePointer<JNIEnv?>, _ __this: jobject?, _ __swiftObject: jlong, _ arg0: jobject? ) -> () {
45+
JNI.inNative = true;
46+
AboutHandlerLocal_.swiftObject( jniEnv: __env, javaObject: __this, swiftObject: __swiftObject ).handleAbout( arg0: arg0 != nil ? AppEvent_AboutEvent( javaObject: arg0 ) : nil )
47+
JNI.inNative = false;
4648
}
4749

48-
open class AboutHandlerBase: JNIObjectProxy, AboutHandler {
50+
open class AboutHandlerLocal_: JNILocalProxy<AboutHandler, Any> {
4951

50-
private static var nativesRegistered = false
52+
fileprivate static let _proxyClass: jclass = {
53+
var natives = [JNINativeMethod]()
5154

52-
private static func registerNatives() {
53-
if ( !nativesRegistered ) {
54-
var natives = [JNINativeMethod]()
55+
let AboutHandler_handleAbout_0_thunk: AboutHandler_handleAbout_0_type = AboutHandler_handleAbout_0
56+
natives.append( JNINativeMethod( name: strdup("__handleAbout"), signature: strdup("(JLcom/apple/eawt/AppEvent$AboutEvent;)V"), fnPtr: unsafeBitCast( AboutHandler_handleAbout_0_thunk, to: UnsafeMutableRawPointer.self ) ) )
5557

56-
let AboutHandler_handleAbout_0_thunk: AboutHandler_handleAbout_0_type = AboutHandler_handleAbout_0
57-
natives.append( JNINativeMethod( name: strdup("__handleAbout"), signature: strdup("(Lcom/apple/eawt/AppEvent$AboutEvent;)V"), fnPtr: unsafeBitCast( AboutHandler_handleAbout_0_thunk, to: UnsafeMutableRawPointer.self ) ) )
58+
natives.append( JNINativeMethod( name: strdup("__finalize"), signature: strdup("(J)V"), fnPtr: unsafeBitCast( JNIReleasableProxy__finalize_thunk, to: UnsafeMutableRawPointer.self ) ) )
5859

59-
withUnsafePointer(to: &natives[0]) {
60-
nativesPtr in
61-
let clazz = JNI.FindClass( "org/genie/com_apple/AboutHandlerProxy" )
62-
if JNI.api.RegisterNatives( JNI.env, clazz, nativesPtr, jint(natives.count) ) != jint(JNI_OK) {
63-
JNI.report( "Unable to register java natives" )
64-
}
60+
let clazz = JNI.FindClass( proxyClassName() )
61+
withUnsafePointer(to: &natives[0]) {
62+
nativesPtr in
63+
if JNI.api.RegisterNatives( JNI.env, clazz, nativesPtr, jint(natives.count) ) != jint(JNI_OK) {
64+
JNI.report( "Unable to register java natives" )
6565
}
66-
67-
nativesRegistered = true
6866
}
69-
}
7067

71-
public convenience init() {
72-
self.init( javaObject: nil )
73-
}
68+
defer { JNI.DeleteLocalRef( clazz ) }
69+
return JNI.api.NewGlobalRef( JNI.env, clazz )!
70+
}()
7471

75-
public required init( javaObject: jobject? ) {
76-
super.init( javaObject: javaObject )
77-
AboutHandlerBase.registerNatives()
78-
createProxy( javaClassName: "org/genie/com_apple/AboutHandlerProxy" )
79-
}
72+
override open class func proxyClassName() -> String { return "org/swiftjava/com_apple/AboutHandlerProxy" }
73+
override open class func proxyClass() -> jclass? { return _proxyClass }
74+
75+
}
76+
77+
extension AboutHandler {
8078

81-
static func swiftObject( jniEnv: UnsafeMutablePointer<JNIEnv?>?, javaObject: jobject? ) -> AboutHandlerBase {
82-
return unsafeBitCast( swiftPointer( jniEnv: jniEnv, object: javaObject ), to: AboutHandlerBase.self )
79+
public func localJavaObject( _ locals: UnsafeMutablePointer<[jobject]> ) -> jobject? {
80+
return AboutHandlerLocal_( owned: self, proto: self ).localJavaObject( locals )
8381
}
8482

83+
}
84+
85+
open class AboutHandlerBase: AboutHandler {
86+
87+
public init() {}
88+
8589
/// public abstract void com.apple.eawt.AboutHandler.handleAbout(com.apple.eawt.AppEvent$AboutEvent)
8690

8791
open func handleAbout( arg0: AppEvent_AboutEvent? ) /**/ {

Sources/AppEvent.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11

22
import java_swift
33
import java_util
4-
import java_lang
54

65
/// generated by: genswift.java 'java/lang|java/util|java/sql|java/awt|javax/swing' ///
76

8-
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ///
9-
/// Tue Dec 20 11:52:04 GMT 2016 ///
7+
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ///
8+
/// Fri Aug 04 11:17:07 BST 2017 ///
109

1110
/// class com.apple.eawt.AppEvent ///
1211

1312
open class AppEvent: java_util.EventObject {
1413

15-
public convenience init?( casting object: java_lang.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
14+
public convenience init?( casting object: java_swift.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
1615
self.init( javaObject: nil )
17-
if !object.validDownCast( toJavaClass: "com.apple.eawt.AppEvent", file, line ) {
18-
return nil
19-
}
2016
object.withJavaObject {
2117
self.javaObject = $0
2218
}
@@ -30,19 +26,20 @@ open class AppEvent: java_util.EventObject {
3026

3127
private static var source_FieldID: jfieldID?
3228

33-
override open var source: java_lang.JavaObject! {
29+
override open var source: java_swift.JavaObject! {
3430
get {
3531
var __locals = [jobject]()
3632
let __value = JNIField.GetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent.source_FieldID, object: javaObject, locals: &__locals )
37-
return __value != nil ? java_lang.JavaObject( javaObject: __value ) : nil
33+
return __value != nil ? java_swift.JavaObject( javaObject: __value ) : nil
3834
}
3935
set(newValue) {
4036
var __locals = [jobject]()
41-
let __value = JNIType.encode( value: newValue, locals: &__locals )
37+
let __value = JNIType.toJava( value: newValue != nil ? newValue! as JNIObject : nil, locals: &__locals )
4238
JNIField.SetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent.source_FieldID, object: javaObject, value: __value.l, locals: &__locals )
4339
}
4440
}
4541

4642
/// com.apple.eawt.AppEvent()
4743

4844
}
45+

Sources/AppEventListener.swift

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,57 @@ import java_swift
33

44
/// generated by: genswift.java 'java/lang|java/util|java/sql|java/awt|javax/swing' ///
55

6-
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ///
7-
/// Tue Dec 20 11:52:04 GMT 2016 ///
6+
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ///
7+
/// Fri Aug 04 11:17:08 BST 2017 ///
88

99
/// interface com.apple.eawt.AppEventListener ///
1010

1111
public protocol AppEventListener: JavaProtocol {
1212

1313
}
1414

15+
1516
open class AppEventListenerForward: JNIObjectForward, AppEventListener {
1617

1718
private static var AppEventListenerJNIClass: jclass?
1819

1920
}
2021

2122

22-
open class AppEventListenerBase: JNIObjectProxy, AppEventListener {
23+
open class AppEventListenerLocal_: JNILocalProxy<AppEventListener, Any> {
2324

24-
private static var nativesRegistered = false
25+
fileprivate static let _proxyClass: jclass = {
26+
var natives = [JNINativeMethod]()
2527

26-
private static func registerNatives() {
27-
if ( !nativesRegistered ) {
28-
var natives = [JNINativeMethod]()
28+
natives.append( JNINativeMethod( name: strdup("__finalize"), signature: strdup("(J)V"), fnPtr: unsafeBitCast( JNIReleasableProxy__finalize_thunk, to: UnsafeMutableRawPointer.self ) ) )
2929

30-
withUnsafePointer(to: &natives[0]) {
31-
nativesPtr in
32-
let clazz = JNI.FindClass( "org/genie/com_apple/AppEventListenerProxy" )
33-
if JNI.api.RegisterNatives( JNI.env, clazz, nativesPtr, jint(natives.count) ) != jint(JNI_OK) {
34-
JNI.report( "Unable to register java natives" )
35-
}
30+
let clazz = JNI.FindClass( proxyClassName() )
31+
withUnsafePointer(to: &natives[0]) {
32+
nativesPtr in
33+
if JNI.api.RegisterNatives( JNI.env, clazz, nativesPtr, jint(natives.count) ) != jint(JNI_OK) {
34+
JNI.report( "Unable to register java natives" )
3635
}
37-
38-
nativesRegistered = true
3936
}
40-
}
4137

42-
public convenience init() {
43-
self.init( javaObject: nil )
44-
}
38+
defer { JNI.DeleteLocalRef( clazz ) }
39+
return JNI.api.NewGlobalRef( JNI.env, clazz )!
40+
}()
4541

46-
public required init( javaObject: jobject? ) {
47-
super.init( javaObject: javaObject )
48-
AppEventListenerBase.registerNatives()
49-
createProxy( javaClassName: "org/genie/com_apple/AppEventListenerProxy" )
50-
}
42+
override open class func proxyClassName() -> String { return "org/swiftjava/com_apple/AppEventListenerProxy" }
43+
override open class func proxyClass() -> jclass? { return _proxyClass }
44+
45+
}
46+
47+
extension AppEventListener {
5148

52-
static func swiftObject( jniEnv: UnsafeMutablePointer<JNIEnv?>?, javaObject: jobject? ) -> AppEventListenerBase {
53-
return unsafeBitCast( swiftPointer( jniEnv: jniEnv, object: javaObject ), to: AppEventListenerBase.self )
49+
public func localJavaObject( _ locals: UnsafeMutablePointer<[jobject]> ) -> jobject? {
50+
return AppEventListenerLocal_( owned: self, proto: self ).localJavaObject( locals )
5451
}
5552

5653
}
54+
55+
open class AppEventListenerBase: AppEventListener {
56+
57+
public init() {}
58+
59+
}

Sources/AppEvent_AboutEvent.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11

22
import java_swift
3-
import java_lang
43

54
/// generated by: genswift.java 'java/lang|java/util|java/sql|java/awt|javax/swing' ///
65

7-
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ///
8-
/// Tue Dec 20 11:52:04 GMT 2016 ///
6+
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ///
7+
/// Fri Aug 04 11:17:07 BST 2017 ///
98

109
/// class com.apple.eawt.AppEvent$AboutEvent ///
1110

1211
open class AppEvent_AboutEvent: AppEvent {
1312

14-
public convenience init?( casting object: java_lang.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
13+
public convenience init?( casting object: java_swift.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
1514
self.init( javaObject: nil )
16-
if !object.validDownCast( toJavaClass: "com.apple.eawt.AppEvent$AboutEvent", file, line ) {
17-
return nil
18-
}
1915
object.withJavaObject {
2016
self.javaObject = $0
2117
}
@@ -29,19 +25,20 @@ open class AppEvent_AboutEvent: AppEvent {
2925

3026
private static var source_FieldID: jfieldID?
3127

32-
override open var source: java_lang.JavaObject! {
28+
override open var source: java_swift.JavaObject! {
3329
get {
3430
var __locals = [jobject]()
3531
let __value = JNIField.GetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent_AboutEvent.source_FieldID, object: javaObject, locals: &__locals )
36-
return __value != nil ? java_lang.JavaObject( javaObject: __value ) : nil
32+
return __value != nil ? java_swift.JavaObject( javaObject: __value ) : nil
3733
}
3834
set(newValue) {
3935
var __locals = [jobject]()
40-
let __value = JNIType.encode( value: newValue, locals: &__locals )
36+
let __value = JNIType.toJava( value: newValue != nil ? newValue! as JNIObject : nil, locals: &__locals )
4137
JNIField.SetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent_AboutEvent.source_FieldID, object: javaObject, value: __value.l, locals: &__locals )
4238
}
4339
}
4440

4541
/// com.apple.eawt.AppEvent$AboutEvent()
4642

4743
}
44+
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11

22
import java_swift
3-
import java_lang
43

54
/// generated by: genswift.java 'java/lang|java/util|java/sql|java/awt|javax/swing' ///
65

7-
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home ///
8-
/// Tue Dec 20 11:52:04 GMT 2016 ///
6+
/// JAVA_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home ///
7+
/// Fri Aug 04 11:17:07 BST 2017 ///
98

109
/// class com.apple.eawt.AppEvent$AppForegroundEvent ///
1110

1211
open class AppEvent_AppForegroundEvent: AppEvent {
1312

14-
public convenience init?( casting object: java_lang.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
13+
public convenience init?( casting object: java_swift.JavaObject, _ file: StaticString = #file, _ line: Int = #line ) {
1514
self.init( javaObject: nil )
16-
if !object.validDownCast( toJavaClass: "com.apple.eawt.AppEvent$AppForegroundEvent", file, line ) {
17-
return nil
18-
}
1915
object.withJavaObject {
2016
self.javaObject = $0
2117
}
@@ -29,19 +25,20 @@ open class AppEvent_AppForegroundEvent: AppEvent {
2925

3026
private static var source_FieldID: jfieldID?
3127

32-
override open var source: java_lang.JavaObject! {
28+
override open var source: java_swift.JavaObject! {
3329
get {
3430
var __locals = [jobject]()
3531
let __value = JNIField.GetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent_AppForegroundEvent.source_FieldID, object: javaObject, locals: &__locals )
36-
return __value != nil ? java_lang.JavaObject( javaObject: __value ) : nil
32+
return __value != nil ? java_swift.JavaObject( javaObject: __value ) : nil
3733
}
3834
set(newValue) {
3935
var __locals = [jobject]()
40-
let __value = JNIType.encode( value: newValue, locals: &__locals )
36+
let __value = JNIType.toJava( value: newValue != nil ? newValue! as JNIObject : nil, locals: &__locals )
4137
JNIField.SetObjectField( fieldName: "source", fieldType: "Ljava/lang/Object;", fieldCache: &AppEvent_AppForegroundEvent.source_FieldID, object: javaObject, value: __value.l, locals: &__locals )
4238
}
4339
}
4440

4541
/// com.apple.eawt.AppEvent$AppForegroundEvent()
4642

4743
}
44+

0 commit comments

Comments
 (0)