Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63918fd

Browse files
committed
Updated for Version 2
1 parentac6813d commit63918fd

File tree

239 files changed

+12418
-5652
lines changed

Some content is hidden

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

239 files changed

+12418
-5652
lines changed

‎.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentrykind="src"path="src"/>
4-
<classpathentrykind="lib"path="/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar"sourcepath="/Library/Java/JavaVirtualMachines/1.6.0_41-b02-445.jdk/Contents/Home/src.jar"/>
4+
<classpathentrykind="lib"path="/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar"sourcepath="/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/src.zip"/>
55
<classpathentrykind="output"path="bin"/>
66
</classpath>

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ parameters/java
77
parameters/javax
88
parameters/classes
99
parameters/launcher
10+
/bin/

‎JDBC/AppDelegate.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTableViewDataSource, NSTab
6565
Thread({
6666

6767
do{
68-
iftryClass.forName(self.driverClass.stringValue)==nil{
68+
iftryJavaClass.forName(self.driverClass.stringValue)==nil{
6969
returnself.alert("Could not load driver class");
7070
}
7171

@@ -77,7 +77,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTableViewDataSource, NSTab
7777
else{returnself.alert("Unable to connect using information supplied, consult console")}
7878

7979
letstatement=try connection.createStatement()!
80-
if !(try statement.execute(self.SQL.stringValue)){
80+
if !(try statement.execute(sql:self.SQL.stringValue)){
8181
returnself.alert("Could not execute SQL:\(self.SQL.stringValue)");
8282
}
8383

@@ -88,13 +88,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSTableViewDataSource, NSTab
8888
iflet result=try statement.getResultSet(),let md=try result.getMetaData(){
8989
letncols=try md.getColumnCount()
9090
foriin1...ncols{
91-
model.columnNames.append(try md.getColumnName(i)??"Column\(i)")
91+
model.columnNames.append(try md.getColumnName(column:i)??"Column\(i)")
9292
}
9393

9494
whiletry result.next(){
9595
varrow=[String]()
9696
foriin1...ncols{
97-
row.append(try result.getString( i)??"null")
97+
row.append(try result.getString(columnIndex:i)??"null")
9898
}
9999
model.data.append( row)
100100
}

‎README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Development inside Xcode with the Oracle JVM is a little more complicated. It se
5555
that JNI_CreateJavaVM generates a SIGSEGV internally as part of normal operation
5656
which is trapped using a signal handler so it can proceed on the command line.
5757
Unfortunately, this is caught by Xcode debugger lldb and it suspends and will not
58-
continue until you enter"pr h -s false SIGSEGV" into the debug console each time
58+
continue until you enter`pr h -s false SIGSEGV` into the debug console each time
5959
you run the program. The alternative is to not use the debugger at all in your scheme.
6060

6161
Perversely, with AWT and Swing on macOS the JVM needs to be created on the main thread
@@ -78,44 +78,36 @@ the jre. Use the examples. directory to build using the following commands:
7878
swift build -Xlinker -L$JVM_LIBRARY_PATH -Xlinker -rpath -Xlinker$JVM_LIBRARY_PATH -Xlinker -ljvm
7979
```
8080

81-
Builds on Linux need to be made with the latest preview 6.The swing source in
81+
The swing source in
8282
"examples/Sources" shows how to receive events and subclass a Java class to have certain
8383
methods such as java.awt.Canvas.paint() be implemented in Swift. More on this later.
8484

85-
###Android
85+
###Android Development
8686

8787
For Android, consult the modified versions of the swift-android-samples and the associated
88-
gradle build system pluginswift-android-gradlefrom the[originalAndroidport](https://github.com/SwiftAndroid).
89-
Thisrequires a Ubuntu 15 systemorVM,a Lollipop (api 21) or better device and a Swift-3.0
90-
toolchain built with Android support. Instructions for this process are available in the
88+
gradle build system plugin from the[AndroidToochain](https://github.com/SwiftJava/android_toolchain).
89+
Thisrun on macOSorUbuntu 16.04, and requiresa Lollipop (api 21) or better device.
90+
More detaills and context are available in the
9191
[Swift README for Android](https://github.com/apple/swift/blob/master/docs/Android.md)
9292
and[this comprehensive tutorial](https://medium.com/@ephemer/how-we-put-an-app-in-the-android-play-store-using-swift-67bd99573e3c)
9393
but hopefully the scripts in the modified gradle plugin take most of the pain out of it.
9494

95-
Once you have a toolchain you should be able to type the following commands:
95+
Once you have a toolchainand run its setup.sh scriptyou should be able to type the following commands:
9696

9797
```Shell
98-
cd swift-android-gradle
99-
./gradlew install
100-
```
101-
102-
This install of gradle plugin will tell you which environment variables need to be set up.
103-
Now, connect the Android phone and type:
104-
105-
```Shell
106-
cd ../swift-android-samples/swifthello
98+
cd swift-android-samples/swifthello
10799
./gradlew installDebug
108100
```
109101

110-
For a new application define two Java interfaces, one for messaging from Java to Swift
102+
For a new application, define two Java interfaces, one for messaging from Java to Swift
111103
with it's name ending in "Listener" and one for messaging back into Java from Swift.
112104
You then use ./genswift.sh from this project to generate the Swift binding code:
113105

114106
```Shell
115107
./genswift.sh your.package your.jar
116108
```
117109

118-
This generates Swift classes and a third Java source src/org/genie/your_package/YourAppProxy.java
110+
This generates Swift classes and a third Java source src/org/swiftjava/your_package/YourAppProxy.java
119111
that also needs to be included in your project. Consult the script genhello.sh and project
120112
"swift-android-samples/swifthello" for details. The source "swift-android-samples/swifthello/src/main/swift/Sources/main.swift"
121113
shows how to set this up with a native method called from the main activity.
@@ -164,7 +156,7 @@ provide a Swift implementation of the "run()" method callable from Java.
164156
This approach is also taken for processing events and all interfaces with names
165157
ending in "Listener", "Manager" or "Handler" also have "Base" classes generated
166158
for subclassing along with Java Proxy classes. On macOS and Linux these classes
167-
are compiled into a jar file~/genie.jar using the genjar.sh script for this to work.
159+
are compiled into a jar file~/swiftjava.jar using the genjar.sh script for this to work.
168160

169161
```Swift
170162
classMyActionListener:ActionListenerBase{
@@ -176,6 +168,11 @@ are compiled into a jar file ~/genie.jar using the genjar.sh script for this to
176168
quitButton.addActionListener(MyActionListener());
177169
```
178170

171+
Any interface/protocol from a Java interface can be added to a class to enable it to
172+
be passed to Java provide it's name ends in`Listener`. The implementation is a little
173+
complex but does not have an appreciable overhead. structs can also be made accesable
174+
to Java in this way but the object will no be live i.e. a coy of the struct will be taken.
175+
179176
Some event processing is also done by subclassing concrete classes that have names
180177
ending in "Adapter". Slightly modified Swift "Base" classes and Java Proxies are also
181178
generated for this. Other classes have methods that are intended to be responsibility
@@ -190,17 +187,19 @@ javaObject to your classes' javaObject. Due to the use of generics you'll
190187
also be prompted to provide a null implementation of the "required" initialiser.
191188

192189
```Swift
190+
classMyCanvas:CanvasBase{
191+
193192
init(imageProducer:ImageProducer) {
194193
super.init(javaObject:nil)
195-
CanvasBase().withJavaObject {
196-
self.javaObject=$0
197-
}
194+
inherit(CanvasBase())
198195
image=createImage(imageProducer)
199196
}
200197

201198
requiredinit(javaObject: jobject?) {
202199
fatalError("init(javaObject:) has not been implemented")
203200
}
201+
202+
...
204203
```
205204

206205
Consult the Swing examples codefor further details.
@@ -225,5 +224,5 @@ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TOR
225224
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
226225

227226
This License does not apply to the code generated from the Apple distribution of the Java VM
228-
which are provided under the provisions of "Fair Use"but your use is ultimately subject
227+
which are provided under the provisions of"Fair Use"and your useis ultimately subject
229228
to the original License Agreement.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp