├── .gitignore ├── README.md ├── build.gradle ├── consoleout.png ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── notepad ├── android │ ├── build.gradle │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ ├── co │ │ │ └── touchlab │ │ │ │ └── kurgan │ │ │ │ └── play │ │ │ │ └── notepad │ │ │ │ └── Methods.kt │ │ └── org │ │ │ └── konan │ │ │ └── calculator │ │ │ └── MainActivity.kt │ │ └── res │ │ ├── drawable-hdpi │ │ ├── app_notes.png │ │ ├── ic_menu_compose.png │ │ ├── ic_menu_delete.png │ │ ├── ic_menu_edit.png │ │ ├── ic_menu_revert.png │ │ ├── ic_menu_save.png │ │ └── live_folder_notes.png │ │ ├── drawable-ldpi │ │ ├── app_notes.png │ │ └── live_folder_notes.png │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── app_notes.png │ │ ├── ic_launcher_background.xml │ │ ├── ic_menu_compose.png │ │ ├── ic_menu_delete.png │ │ ├── ic_menu_edit.png │ │ ├── ic_menu_revert.png │ │ ├── ic_menu_save.png │ │ └── live_folder_notes.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── note_editor.xml │ │ ├── noteslist_item.xml │ │ └── title_editor.xml │ │ ├── menu │ │ ├── editor_options_menu.xml │ │ ├── list_context_menu.xml │ │ └── list_options_menu.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── ios │ ├── build.gradle │ ├── calculator.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ │ └── xcuserdata │ │ │ │ └── kgalligan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── kgalligan.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ ├── calculator │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift │ ├── ioslibs │ │ └── libdbarch.a │ ├── klibrepo │ │ ├── ios_arm64 │ │ │ ├── kurgan.klib │ │ │ ├── objcsrc.klib │ │ │ └── objcsrc.klib-build │ │ │ │ ├── kotlin │ │ │ │ └── objcsrc │ │ │ │ │ └── objcsrc.kt │ │ │ │ └── manifest.properties │ │ └── ios_x64 │ │ │ ├── kurgan.klib │ │ │ ├── objcsrc.klib │ │ │ └── objcsrc.klib-build │ │ │ ├── kotlin │ │ │ └── objcsrc │ │ │ │ └── objcsrc.kt │ │ │ └── manifest.properties │ └── src │ │ └── main │ │ └── kotlin │ │ └── co │ │ └── touchlab │ │ └── kurgan │ │ └── play │ │ ├── PlayRuntime.kt │ │ └── notepad │ │ └── Methods.kt └── src │ └── main │ ├── kotlin │ └── co │ │ └── touchlab │ │ └── kurgan │ │ └── play │ │ └── notepad │ │ └── Methods.kt │ └── sqldelight │ └── co │ └── touchlab │ └── kurgan │ └── play │ └── notepad │ └── Note.sq ├── settings.gradle └── simulatorscreen.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/shelf 3 | *.iml 4 | /dependencies/all 5 | dist 6 | kotlin-native-*.tar.gz 7 | translator/src/test/kotlin/tests/*/linked 8 | out 9 | tmp 10 | workspace.xml 11 | *.versionsBackup 12 | 13 | local.properties 14 | .gradle 15 | build 16 | translator/.gradle/2.9/taskArtifacts 17 | 18 | kotstd/kotstd.iml 19 | 20 | # test suit products. 21 | *.bc 22 | *.bc.o 23 | *.kt.S 24 | *.kt.exe 25 | *.log 26 | test.output 27 | *.kexe 28 | 29 | # Ignore Gradle GUI config 30 | gradle-app.setting 31 | 32 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 33 | !gradle-wrapper.jar 34 | 35 | # Cache of project 36 | .gradletasknamecache 37 | 38 | # local project files 39 | lib/ 40 | .idea/ 41 | proto/compiler/protoc-artifacts 42 | proto/compiler/tests 43 | 44 | proto/compiler/google/src/google/protobuf/compiler/kotlin/bin 45 | proto/compiler/google/src/google/protobuf/compiler/kotlin/protoc 46 | 47 | peformance/build 48 | 49 | # translator auto generated artifacts 50 | kotstd/ll 51 | 52 | # test teamcity property: commitable only with -f 53 | backend.native/tests/teamcity-test.property 54 | 55 | # Sample output 56 | samples/**/*.kt.bc-build 57 | samples/androidNativeActivity/Polyhedron -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SQLite & SQLDelight Sample 2 | 3 | This example shows a first pass on creating a Kotlin/Native SQLite interface and common interface that is a stand in for Android's 4 | SQLite stack. It also includes SQLDelight's Kotlin Common source gen which allows multiplatform database development. 5 | 6 | ## Notes 7 | 8 | This is super, super early. The app does nothing except insert and query a bunch of data. Some of the architecture needs a rethink 9 | due to the threading model of Kotlin/Native. All the rest of the notes in [blog post](https://medium.com/@kpgalligan/sqlite-sqldelight-%EF%B8%8F-kotlin-multiplatform-f24fe7cba338)/video. 10 | 11 | ## Building 12 | 13 | Right now (11:19am Friday) the Android app compiles but won't actually do anything. May fix but that's not the interesting part of 14 | the demo, and I promised to publish this by today, so priorities. 15 | 16 | 1: Clone Kotlin/Native: https://github.com/JetBrains/kotlin-native. 17 | 18 | 2: Modify some source in Kotlin/Native. I've filed [an issue](https://github.com/JetBrains/kotlin-native/issues/1539), 19 | but for now, you need to remove the check code. Open the file: 20 | ``` 21 | backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt 22 | ``` 23 | 24 | Comment out a block starting at line 521 (example below starts at 519 for context). 25 | 26 | ```kotlin 27 | val initMethod = expression.descriptor.getObjCInitMethod()!! 28 | 29 | /*if (!expression.descriptor.objCConstructorIsDesignated()) { 30 | context.reportCompilationError( 31 | "Unable to call non-designated initializer as super constructor", 32 | currentFile, 33 | expression 34 | ) 35 | }*/ 36 | 37 | val initMethodInfo = initMethod.getExternalObjCMethodInfo()!! 38 | ``` 39 | 40 | 3: Run the Kotlin/Native build steps: 41 | ```bash 42 | ./gradlew dependencies:update 43 | ./gradlew bundle 44 | ``` 45 | 46 | 3a: Optional, but poke around some of the samples and make sure they work. The 'calculator' samples specifically. This is 47 | built on that. 48 | 49 | 4: Add that dir to your environment variables (I put in ~/.bash_profile) 50 | ``` 51 | export KOTLIN_NATIVE_DIR=[Your path] 52 | ``` 53 | 54 | 5: Download [J2objc 2.1.1](https://github.com/google/j2objc/releases/tag/2.1.1). Unzip to a local path. If you're not the 55 | self sabotaging type, I'd suggest a path with no spaces. 56 | 57 | 6: Add that to environment variables 58 | ``` 59 | export J2OBJC_RUNTIME=[unzip path] 60 | ``` 61 | 62 | ### Sanity Check! 63 | 64 | Here's my ~/.bash_profile 65 | ``` 66 | export J2OBJC_RUNTIME=/Users/kgalligan/bin/j2objc-2.1.1 67 | export KOTLIN_NATIVE_DIR=/Users/kgalligan/temp2/kotlin-native 68 | ``` 69 | 70 | I didn't mention it above, but you've got Xcode installed and you've built a few things with it. Especially something 71 | that will force the command line tools to be installed. If you haven't done options step 3a above, I'd say do it. Really 72 | shouldn't be optional. 73 | 74 | ### More Steps 75 | 76 | 7: Open Intellij and open this sample project in it. **Intellij**, not Android Studio. Might be OK, but haven't tried. 77 | 78 | 8: Manually run the task to generate the SQLDelight interfaces: generateSqlDelightInterface. I've been running that from the Gradle UI 79 | ":notepad>Tasks>sqldelight>generateSqlDelightInterface". Verify that those are built by looking in notepad/build/sqldelight. If not, 80 | you're probably not getting to the next steps. 81 | 82 | 9: Build the ios app specifically. 83 | 84 | ```bash 85 | ./gradlew :notepad:ios:build 86 | ``` 87 | 88 | 10: Open the Xcode project. It's in 'notepad/ios'. Open 'calculator.xcodeproj' (For the non-Xcode crowd, it's a folder, but sort of not really) 89 | 90 | 11: Select a simulator profile, and run. It'll take *a while*. When it's done, you should see the following. 91 | 92 | ![simulator screen](simulatorscreen.png) 93 | 94 | There are 2 buttons and a label. The "Insert Stuff" button will run the shared code found in: 95 | 96 | ``` 97 | notepad/src/main/kotlin/co/touchlab/kurgan/play/notepad/Methods.kt 98 | ``` 99 | 100 | This creates the database, then schedules 3 inserts of 15000 rows each, followed by a select of 10 rows. All is written to 101 | the console output, which should look like this. 102 | 103 | ![console out](consoleout.png) 104 | 105 | What does "Memory" button do? Well, you'll need to learn how Kotlin/Native handles memory to fully understand, but it 106 | runs the insert loops and only cleans up memory at the end of it, as opposed to the first button with cleans on each loop. 107 | If you're interested, open the project in Instruments and open in "Leaks" profile. The first button will be flat. Second will 108 | have a sawtooth. Not super important for the demo, but interesting. 109 | 110 | ## FAQ 111 | 112 | Q: Can I try this in my app? 113 | A: Sure, but don't. 114 | 115 | Q: Where's the SQLite source? 116 | A: Well, I've learned quite a bit about Kotlin/Native architecture and threads, and there's some refactoring that's needed anyway. For example, 117 | you can get a blob from results, but can't pass one to a query. I'll have another release in a few weeks with other bits. The actual SQLite 118 | code is from Doppl, so you can see that [here](https://doppllib.github.io/). 119 | 120 | Q: The generated SQLDelight isn't compiling! 121 | A: SQLdelight with Kotlin is being heavily developed, and to get the Kotlin/Native build, I need source, so the runtime is copy/pasted, but 122 | the generator code is looking at a SNAPSHOT. If that's been updated, it might break (it did for me 2 hours before my talk). Ping me on 123 | twitter at [@kpgalligan](https://twitter.com/kpgalligan) if this is happening and I'll republish. 124 | 125 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.buildConfig = [ 3 | 'compileSdk': 27, 4 | 'minSdk' : 24, 5 | 'targetSdk' : 27, 6 | 7 | 'version' : [ 8 | 'major': 1, 9 | 'minor': 2, 10 | 'patch': 1, 11 | 'build': 0, 12 | ], 13 | ] 14 | 15 | ext.versions = [ 16 | 'supportLibrary' : '27.1.0', 17 | 'kotlin' : '1.2.41', 18 | 'kotlinCoroutines': '0.22.5', 19 | 'sqldelight' : '1.0.0-SNAPSHOT' 20 | ] 21 | 22 | ext.deps = [ 23 | 'kotlin' : [ 24 | 'stdlib' : [ 25 | 'common': "org.jetbrains.kotlin:kotlin-stdlib-common:${versions.kotlin}", 26 | 'jdk' : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}", 27 | 'js' : "org.jetbrains.kotlin:kotlin-stdlib-js:${versions.kotlin}", 28 | ], 29 | 'coroutines': [ 30 | 'common' : "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${versions.kotlinCoroutines}", 31 | 'jdk' : "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinCoroutines}", 32 | 'js' : "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${versions.kotlinCoroutines}", 33 | 'android': "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlinCoroutines}", 34 | 'rx2' : "org.jetbrains.kotlinx:kotlinx-coroutines-rx2:${versions.kotlinCoroutines}", 35 | ], 36 | ], 37 | 'android' : [ 38 | 'arch': [ 39 | 'dbFramework': 'android.arch.persistence:db-framework:1.0.0', 40 | ], 41 | ], 42 | 43 | 'sqldelight': [ 44 | 'android': "com.squareup.sqldelight:android-driver:${versions.sqldelight}", 45 | 'runtime': "com.squareup.sqldelight:runtime:${versions.sqldelight}", 46 | ] 47 | ] 48 | 49 | repositories { 50 | jcenter() 51 | google() 52 | maven { url "https://kotlin.bintray.com/kotlinx" } 53 | gradlePluginPortal() 54 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 55 | maven { url 'https://dl.bintray.com/doppllib/j2objc' } 56 | // maven { url j2objcMavenDeploy } 57 | } 58 | 59 | dependencies { 60 | classpath 'com.android.tools.build:gradle:3.2.0-alpha08' 61 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" 62 | classpath "com.squareup.sqldelight:gradle-plugin:${versions.sqldelight}" 63 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:${project.property('konan.plugin.version')}" 64 | } 65 | } 66 | 67 | allprojects { 68 | repositories { 69 | jcenter() 70 | google() 71 | maven { url "https://kotlin.bintray.com/kotlinx" } 72 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } 73 | maven { url 'https://dl.bintray.com/doppllib/j2objc' } 74 | // maven { url j2objcMavenDeploy } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /consoleout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/consoleout.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | konan.home=/Users/kgalligan/temp3/kotlin-native/dist 2 | #konan.version=0.7 3 | konan.plugin.version=+ 4 | j2objc_runtime=2.1.1 5 | org.gradle.configureondemand=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 18 10:33:08 EDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /notepad/android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | //apply plugin: 'org.jetbrains.kotlin.platform.common' 3 | //apply plugin: 'kotlin-platform-android' 4 | apply plugin: 'org.jetbrains.kotlin.platform.android' 5 | apply plugin: 'kotlin-kapt' 6 | 7 | android { 8 | compileSdkVersion buildConfig.compileSdk 9 | 10 | defaultConfig { 11 | minSdkVersion buildConfig.minSdk 12 | 13 | testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' 14 | } 15 | 16 | compileOptions { 17 | sourceCompatibility JavaVersion.VERSION_1_8 18 | targetCompatibility JavaVersion.VERSION_1_8 19 | } 20 | 21 | } 22 | 23 | dependencies { 24 | expectedBy project(':notepad') 25 | 26 | implementation deps.kotlin.stdlib.jdk 27 | implementation deps.sqldelight.android 28 | implementation deps.android.arch.dbFramework 29 | 30 | implementation "com.android.support:appcompat-v7:27.1.1" 31 | } 32 | 33 | kotlin { 34 | experimental { 35 | coroutines 'enable' 36 | } 37 | } 38 | 39 | tasks.getByName("preBuild").dependsOn(":notepad:generateSqlDelightInterface") 40 | -------------------------------------------------------------------------------- /notepad/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /notepad/android/src/main/kotlin/co/touchlab/kurgan/play/notepad/Methods.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kurgan.play.notepad 2 | 3 | import java.util.concurrent.* 4 | import co.touchlab.kurgan.architecture.database.sqldelight.SqlDelightDatabaseHelper 5 | 6 | actual fun memzy(body: () -> Unit) = body() 7 | 8 | private val executorService = Executors.newSingleThreadExecutor() 9 | private val mainHandler = android.os.Handler(android.os.Looper.getMainLooper()) 10 | 11 | 12 | actual fun runOnBackground(workerData: WorkerData){ 13 | executorService.execute { 14 | r.run() 15 | } 16 | } 17 | 18 | actual fun createHolder(db: SqlDelightDatabaseHelper)= HelperHolder(db) 19 | 20 | /* 21 | actual fun runOnMain(r:Runner){ 22 | mainHandler.post { 23 | r.run() 24 | } 25 | }*/ 26 | -------------------------------------------------------------------------------- /notepad/android/src/main/kotlin/org/konan/calculator/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package org.konan.calculator 2 | 3 | import android.os.Bundle 4 | import android.support.v7.app.AppCompatActivity 5 | import android.widget.EditText 6 | import android.widget.TextView 7 | import co.touchlab.kurgan.play.notepad.Note 8 | //import org.konan.arithmeticparser.parseAndCompute 9 | 10 | class MainActivity : AppCompatActivity() { 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | 15 | val notez:Note? = null 16 | 17 | setContentView(R.layout.activity_main) 18 | 19 | val resultView = findViewById(R.id.computed_result) 20 | 21 | val input = findViewById(R.id.input) 22 | input.setOnEditorActionListener { input, _, _ -> 23 | val inputText = input.text.toString() 24 | /*val result = parseAndCompute(inputText).expression 25 | with(resultView) { 26 | text = if (result != null) inputText + " = " + result.toString() else "Unable to parse " + inputText 27 | }*/ 28 | true 29 | } 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/app_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/app_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/ic_menu_compose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/ic_menu_compose.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/ic_menu_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/ic_menu_delete.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/ic_menu_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/ic_menu_edit.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/ic_menu_revert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/ic_menu_revert.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/ic_menu_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/ic_menu_save.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-hdpi/live_folder_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-hdpi/live_folder_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-ldpi/app_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-ldpi/app_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-ldpi/live_folder_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable-ldpi/live_folder_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/app_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/app_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_menu_compose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/ic_menu_compose.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_menu_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/ic_menu_delete.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_menu_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/ic_menu_edit.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_menu_revert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/ic_menu_revert.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/ic_menu_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/ic_menu_save.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/drawable/live_folder_notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/android/src/main/res/drawable/live_folder_notes.png -------------------------------------------------------------------------------- /notepad/android/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /notepad/android/src/main/res/layout/note_editor.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 29 | -------------------------------------------------------------------------------- /notepad/android/src/main/res/layout/noteslist_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 26 | -------------------------------------------------------------------------------- /notepad/android/src/main/res/layout/title_editor.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 24 | 25 | 35 | 36 | 29 | 36 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /notepad/ios/calculator/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | KotlinCalc 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /notepad/ios/calculator/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // calculator 4 | // 5 | // Created by jetbrains on 01/12/2017. 6 | // Copyright © 2017 JetBrains. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import KotlinArithmeticParser 11 | 12 | class ViewController: UIViewController { 13 | var playRuntime: KAPPlayRuntime? 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | // Do any additional setup after loading the view, typically from a nib. 18 | 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | @IBAction func insertStuffAction(_ sender: Any) { 26 | initKotlin() 27 | playRuntime?.helloStart(mems: true) 28 | outputLabel.text = "Ran with memory dumps" 29 | } 30 | 31 | @IBAction func memoryAction(_ sender: Any) { 32 | initKotlin() 33 | playRuntime?.helloStart(mems: false) 34 | outputLabel.text = "Ran without memory dumps" 35 | } 36 | 37 | func initKotlin(){ 38 | if(playRuntime == nil){ 39 | playRuntime = KAPPlayRuntime() 40 | } 41 | } 42 | @IBOutlet weak var outputLabel: UILabel! 43 | @IBOutlet var partialResult: UILabel! 44 | 45 | 46 | 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /notepad/ios/ioslibs/libdbarch.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/ios/ioslibs/libdbarch.a -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_arm64/kurgan.klib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/ios/klibrepo/ios_arm64/kurgan.klib -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_arm64/objcsrc.klib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/ios/klibrepo/ios_arm64/objcsrc.klib -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_arm64/objcsrc.klib-build/manifest.properties: -------------------------------------------------------------------------------- 1 | #Wed May 02 17:12:58 EDT 2018 2 | package=objcsrc 3 | interop=true 4 | linkerOpts=-ljre_emul -lz -lsqlite3 -liconv -ldbarch -ObjC -framework Foundation -framework UIKit -framework Security 5 | includedHeaders=b427292a86af689d1e866227887aad07123714b3713d99c27493779e4beb338a 5ecc626e19136e500f961984ef7f81ea46cdf95b4f3f063f740cd343c2ef0781 b4e3a9f4ae501031dc8d112ff46db82e1fb2c8798e283d34aaecc3363c355072 e8145a7ad1fbdaf516ae3fe73cd0ca6d6599e9555142b112beb302770d481b00 350a1e6502f25a03c1ad797467399695b81e3fef99d24c2013e216d3d6765629 a1e4b84fa08e766cdc5347e15f838f2fc3b07e1ac7e9ae6da65cdff6e92abecf 7cd0fc62d4ed50ceaf6cce4ef9fbdfff687d2749707dff0834294b9110251d5f 4f332689a1bdce1d2e905fb2e3aa3667af97a46b0fb150424327464ad5b6816d c2c3f9dd049ecf88ea6762213eb37930ca78b8d373dfac721ab843f63fa5eefe fb6525c8fb7ef62bdf75ada3c8033423683830f2892b859fb08ea86e4c64fd15 9788d18fb0ab93e5ac211b3e6194bde61b4ee82d3c208fcac1e7d1b7cb3e1526 59c2c7cf3266b864c19e29ae0e3db7b24adaef8341ed401d1291b09ead5b8d76 81efc54f75bbe2b9b1f74c1ebd1167e6ab806151f29dfb56c35fcd1f85a279e3 88fbc032aa884cc49a6e55346a07305cc91f3dcf3dfb49ee99a668f5977b2c6b e4efb078f0f0e3243c942d999bd859c64158160111a5a63ff1407a944a23c46a cbca854583ebfa1f3e9e4b45040bc7f987d29f820420aab66972881c86f59e01 3599801ca37100292c13859785d22c6d8e33cce4bf98ddd4d799188524aa96fa f311b060a79dd170d4c38c13b49993a976fbb24cd9930fcd6324568197ac7a68 802cf07cf0e3cde677996d04639a7c48a4bdc35d2f2436ac9ea59c755ae24c45 f162e73b1fb10a8307d180eca6a3cea8051c51ba2b5101ea139cb6f04b1474ed d6b3d2bd55ec6f64123b3a48d59e1930e8af640c8f62bec87b354515de884ffc e8e3cb3d0c61091292c92b63cf07ca6e498430d28b682eac2026d42e326a9119 a3a23a5b839d49378248067219935bbf1a16af0ff4539d27e51f5d94223f9acd 250f0162bca733c09cda5090c3abb430e641bd114f24b66d4b15f50994de1f9f ec1c86a45a5048a24b4a9b315d7481826094a980bcba33c210ba20d8af4c3eee f309203af647392c5f9d4fe57c1fa7bbd3221381ea6474d7e6632efcfdee96cd 0aa6532321f20f0d7612181410eceadaa21294261af22e6fff65d3312c934739 4a5770da36971c661b01b6d0811f58c97b3cc6f40e684722128f7f077e4c3020 cc1f788c49b58918c66f6c913bf7219a57df6a2df9783549dd54acf87cb5e32c 8feaa2c7ee3834090b67da7b9a7cbf790b6ef5a317a8c755c14353d15b70a9b5 add59ddc48789cac1f5172d1b10364eb255a590f2aeea5a53814ff9edc457c3b ceed4467a4585cd2e5b086199da3fa4d0aceadd41ebb33e2cc59045b13def35c ea16c603667d35d5ba03bf4d0282e258231b7a3c08bbd6c250e1fc16b5fb62da b7870d9e34439bd732d9410cb057006092303beed91c11222735a780e8f6e24f 8b7ffaeabde1bfc6f9b48e8ce7dc8bc8d13893e63f020f7ecae3abb5a77fbcb3 68cd8d0db899067b41ce816577617b955a0b549239c9a3440e48aa8af26e2d79 86c56772532bb84356d6624c973174bd2058004c17886315329eb2b9a161acd4 c5ae41a6397e0a386d3cc1b29ef3eb2838aebe80d6731dc4ac7bddc1c1ad8491 2a45332d07b31792f1ef9f7fb2057128ec8881c121d682c7778a94771a16027d 4b0233a0b37dac06b3065d8dcc190289c7052f726b7ceea8bee2c5d84cf0ef41 f4eb5079321206f5928044e4ed62eb8b5e0ac405899524403337257f8c089b09 a10e8b772095396f6a6fc498ffdd41713e63ab6f5da0e20f0636a896307928f5 78b67f03f5b4c0143df2cbbaad1d6e25bb98fff6de1046560929d2e628116a68 adc31a734fd28758be286c280becfe4c6282f7764ce4a0301e90380f2d771702 131fff98e188b186d5293eea1729fdd2d2dadfb588df4ac200d245817bea0d99 57ba9b7d3012869cc5002bd1021ea40547b06af6c158489e0a7b214f472faa62 b12695bc7941970cc3f83415413568ca2ecac372517d553bcf3623dd620d294d 7a1b72d98295a8d41563f6f08558b666eb854c3ca57323d92525c491b4c3af6f 341904670b98e929c363a222379d136ac842e7a961c656facf987b57c28468d0 a418e94a99f30c43bdf13024ae43059e549989fbb91893cec4c1d72b97c72dce e03db6ae9de9e62b6a8e0760beafc6cadf892e8393a783da755dc8a26ebc3cd5 1de1b909e22b1282a7917c871710a4fdad37eea556dd9c2bd8f50b805ccf34d4 8306bf9b35dea83ed6aa765b4b3ed4fde9e1a871eab9c21dcd57ee79b0c107db 930a7298cbfe96b98b79f5963cf613c33824285f0898da9214b7668c57449f88 4f07b3e7be306d16a5334a269cba1de6f95e30d107a405f9f3051f913ea3a481 f0af014dd7d373f731c6f3a12714eda968944ca1fb9333b3d4c740926ac5a172 f953088844a7709f2d6e725116ff0f5bd2c92003ccbdf4c022ead9d732a66f76 2acb750d29739ed6ab0ce8aed54a6a2329c1b349862cbb7a5f5eb470953ced72 c6d2d6af0a2a430a891da1cc61478128f1138daff82ca1f62538b902d89a198d de98d2e512b02d4b6c4a75946e4b00727bd2d5e5369fac57e91845eef0b77ccc 6 | exportForwardDeclarations= 7 | headers=dbarch/mainDependencyOut.h dbarch/mainSourceOut.h java/util/Locale.h java/io/Closeable.h java/util/concurrent/ExecutorService.h java/util/concurrent/Executors.h java/lang/ThreadLocal.h java/lang/Long.h java/lang/System.h java/lang/Integer.h java/lang/Short.h java/lang/Boolean.h java/lang/Byte.h java/lang/Float.h java/lang/Double.h java/util/Set.h java/util/List.h java/io/File.h IOSPrimitiveArray.h IOSClass.h 8 | language=Objective-C 9 | -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_x64/kurgan.klib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/ios/klibrepo/ios_x64/kurgan.klib -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_x64/objcsrc.klib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/notepad/ios/klibrepo/ios_x64/objcsrc.klib -------------------------------------------------------------------------------- /notepad/ios/klibrepo/ios_x64/objcsrc.klib-build/manifest.properties: -------------------------------------------------------------------------------- 1 | #Wed May 02 17:14:42 EDT 2018 2 | package=objcsrc 3 | interop=true 4 | linkerOpts=-ljre_emul -lz -lsqlite3 -liconv -ldbarch -ObjC -framework Foundation -framework UIKit -framework Security 5 | includedHeaders=b427292a86af689d1e866227887aad07123714b3713d99c27493779e4beb338a 5ecc626e19136e500f961984ef7f81ea46cdf95b4f3f063f740cd343c2ef0781 b4e3a9f4ae501031dc8d112ff46db82e1fb2c8798e283d34aaecc3363c355072 e8145a7ad1fbdaf516ae3fe73cd0ca6d6599e9555142b112beb302770d481b00 350a1e6502f25a03c1ad797467399695b81e3fef99d24c2013e216d3d6765629 a1e4b84fa08e766cdc5347e15f838f2fc3b07e1ac7e9ae6da65cdff6e92abecf 7cd0fc62d4ed50ceaf6cce4ef9fbdfff687d2749707dff0834294b9110251d5f 4f332689a1bdce1d2e905fb2e3aa3667af97a46b0fb150424327464ad5b6816d c2c3f9dd049ecf88ea6762213eb37930ca78b8d373dfac721ab843f63fa5eefe fb6525c8fb7ef62bdf75ada3c8033423683830f2892b859fb08ea86e4c64fd15 9788d18fb0ab93e5ac211b3e6194bde61b4ee82d3c208fcac1e7d1b7cb3e1526 59c2c7cf3266b864c19e29ae0e3db7b24adaef8341ed401d1291b09ead5b8d76 81efc54f75bbe2b9b1f74c1ebd1167e6ab806151f29dfb56c35fcd1f85a279e3 88fbc032aa884cc49a6e55346a07305cc91f3dcf3dfb49ee99a668f5977b2c6b e4efb078f0f0e3243c942d999bd859c64158160111a5a63ff1407a944a23c46a cbca854583ebfa1f3e9e4b45040bc7f987d29f820420aab66972881c86f59e01 3599801ca37100292c13859785d22c6d8e33cce4bf98ddd4d799188524aa96fa f311b060a79dd170d4c38c13b49993a976fbb24cd9930fcd6324568197ac7a68 802cf07cf0e3cde677996d04639a7c48a4bdc35d2f2436ac9ea59c755ae24c45 f162e73b1fb10a8307d180eca6a3cea8051c51ba2b5101ea139cb6f04b1474ed d6b3d2bd55ec6f64123b3a48d59e1930e8af640c8f62bec87b354515de884ffc e8e3cb3d0c61091292c92b63cf07ca6e498430d28b682eac2026d42e326a9119 a3a23a5b839d49378248067219935bbf1a16af0ff4539d27e51f5d94223f9acd 250f0162bca733c09cda5090c3abb430e641bd114f24b66d4b15f50994de1f9f ec1c86a45a5048a24b4a9b315d7481826094a980bcba33c210ba20d8af4c3eee f309203af647392c5f9d4fe57c1fa7bbd3221381ea6474d7e6632efcfdee96cd 0aa6532321f20f0d7612181410eceadaa21294261af22e6fff65d3312c934739 4a5770da36971c661b01b6d0811f58c97b3cc6f40e684722128f7f077e4c3020 cc1f788c49b58918c66f6c913bf7219a57df6a2df9783549dd54acf87cb5e32c 8feaa2c7ee3834090b67da7b9a7cbf790b6ef5a317a8c755c14353d15b70a9b5 add59ddc48789cac1f5172d1b10364eb255a590f2aeea5a53814ff9edc457c3b ceed4467a4585cd2e5b086199da3fa4d0aceadd41ebb33e2cc59045b13def35c ea16c603667d35d5ba03bf4d0282e258231b7a3c08bbd6c250e1fc16b5fb62da b7870d9e34439bd732d9410cb057006092303beed91c11222735a780e8f6e24f 8b7ffaeabde1bfc6f9b48e8ce7dc8bc8d13893e63f020f7ecae3abb5a77fbcb3 68cd8d0db899067b41ce816577617b955a0b549239c9a3440e48aa8af26e2d79 86c56772532bb84356d6624c973174bd2058004c17886315329eb2b9a161acd4 c5ae41a6397e0a386d3cc1b29ef3eb2838aebe80d6731dc4ac7bddc1c1ad8491 2a45332d07b31792f1ef9f7fb2057128ec8881c121d682c7778a94771a16027d 4b0233a0b37dac06b3065d8dcc190289c7052f726b7ceea8bee2c5d84cf0ef41 f4eb5079321206f5928044e4ed62eb8b5e0ac405899524403337257f8c089b09 a10e8b772095396f6a6fc498ffdd41713e63ab6f5da0e20f0636a896307928f5 78b67f03f5b4c0143df2cbbaad1d6e25bb98fff6de1046560929d2e628116a68 adc31a734fd28758be286c280becfe4c6282f7764ce4a0301e90380f2d771702 131fff98e188b186d5293eea1729fdd2d2dadfb588df4ac200d245817bea0d99 57ba9b7d3012869cc5002bd1021ea40547b06af6c158489e0a7b214f472faa62 b12695bc7941970cc3f83415413568ca2ecac372517d553bcf3623dd620d294d 7a1b72d98295a8d41563f6f08558b666eb854c3ca57323d92525c491b4c3af6f 341904670b98e929c363a222379d136ac842e7a961c656facf987b57c28468d0 a418e94a99f30c43bdf13024ae43059e549989fbb91893cec4c1d72b97c72dce e03db6ae9de9e62b6a8e0760beafc6cadf892e8393a783da755dc8a26ebc3cd5 1de1b909e22b1282a7917c871710a4fdad37eea556dd9c2bd8f50b805ccf34d4 8306bf9b35dea83ed6aa765b4b3ed4fde9e1a871eab9c21dcd57ee79b0c107db 930a7298cbfe96b98b79f5963cf613c33824285f0898da9214b7668c57449f88 4f07b3e7be306d16a5334a269cba1de6f95e30d107a405f9f3051f913ea3a481 f0af014dd7d373f731c6f3a12714eda968944ca1fb9333b3d4c740926ac5a172 f953088844a7709f2d6e725116ff0f5bd2c92003ccbdf4c022ead9d732a66f76 2acb750d29739ed6ab0ce8aed54a6a2329c1b349862cbb7a5f5eb470953ced72 c6d2d6af0a2a430a891da1cc61478128f1138daff82ca1f62538b902d89a198d de98d2e512b02d4b6c4a75946e4b00727bd2d5e5369fac57e91845eef0b77ccc 6 | exportForwardDeclarations= 7 | headers=dbarch/mainDependencyOut.h dbarch/mainSourceOut.h java/util/Locale.h java/io/Closeable.h java/util/concurrent/ExecutorService.h java/util/concurrent/Executors.h java/lang/ThreadLocal.h java/lang/Long.h java/lang/System.h java/lang/Integer.h java/lang/Short.h java/lang/Boolean.h java/lang/Byte.h java/lang/Float.h java/lang/Double.h java/util/Set.h java/util/List.h java/io/File.h IOSPrimitiveArray.h IOSClass.h 8 | language=Objective-C 9 | -------------------------------------------------------------------------------- /notepad/ios/src/main/kotlin/co/touchlab/kurgan/play/PlayRuntime.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kurgan.play 2 | 3 | import co.touchlab.kurgan.architecture.* 4 | import co.touchlab.kurgan.play.notepad.* 5 | import co.touchlab.kurgan.architecture.database.sqlite.* 6 | import co.touchlab.kurgan.play.notepad.* 7 | import co.touchlab.kurgan.architecture.database.sqldelight.* 8 | import co.touchlab.kurgan.util.currentTimeMillis 9 | import com.squareup.sqldelight.db.SqlDatabase 10 | //import co.touchlab.kurgan.play.notepad.* 11 | import kotlinx.cinterop.* 12 | import objcsrc.* 13 | 14 | class PlayRuntime(){ 15 | 16 | init { 17 | val context = AndroidContentIOSContext() 18 | DopplRuntime.start() 19 | initApplicationDb(context) 20 | } 21 | 22 | fun helloStart(mems:Boolean){ 23 | Methods.testInserts(mems) 24 | } 25 | 26 | companion object { 27 | fun hi(mems: Boolean){ 28 | val pr = PlayRuntime() 29 | pr.helloStart(mems) 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /notepad/ios/src/main/kotlin/co/touchlab/kurgan/play/notepad/Methods.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kurgan.play.notepad 2 | 3 | import kotlinx.cinterop.* 4 | import objcsrc.* 5 | import konan.worker.* 6 | import co.touchlab.kurgan.architecture.database.sqldelight.SqlDelightDatabaseHelper 7 | 8 | actual fun memzy(body: () -> Unit){ 9 | memScoped { 10 | autoreleasepool { 11 | body() 12 | } 13 | } 14 | } 15 | 16 | private var myWorker :Worker? = null 17 | 18 | 19 | actual fun runOnBackground(workerData: WorkerData){ 20 | if(myWorker == null) { 21 | myWorker = startWorker() 22 | } 23 | 24 | when(workerData){ 25 | 26 | is InsertValues -> { 27 | myWorker!!.schedule(TransferMode.CHECKED,{InsertValues(workerData.holder, workerData.count, workerData.mems)}){ input -> 28 | input.runme() 29 | WorkerResult(1234) 30 | } 31 | } 32 | is SelectValues -> { 33 | myWorker!!.schedule(TransferMode.CHECKED,{SelectValues(workerData.holder, workerData.count)}){ input -> 34 | input.runme() 35 | WorkerResult(1234) 36 | } 37 | } 38 | else -> throw IllegalArgumentException("Don't know type of $workerData") 39 | } 40 | } 41 | 42 | actual fun createHolder(db: SqlDelightDatabaseHelper)= HelperHolder(db).freeze() -------------------------------------------------------------------------------- /notepad/src/main/kotlin/co/touchlab/kurgan/play/notepad/Methods.kt: -------------------------------------------------------------------------------- 1 | package co.touchlab.kurgan.play.notepad 2 | 3 | 4 | import co.touchlab.kurgan.architecture.database.sqldelight.SqlDelightDatabaseHelper 5 | import co.touchlab.kurgan.architecture.database.sqldelight.create 6 | import co.touchlab.kurgan.architecture.database.sqlite.* 7 | import co.touchlab.kurgan.util.currentTimeMillis 8 | import kotlin.coroutines.experimental.* 9 | import kotlin.coroutines.experimental.intrinsics.* 10 | 11 | data class HelperHolder(val dbOpenHelper : SqlDelightDatabaseHelper) 12 | 13 | class Methods{ 14 | companion object { 15 | fun testInserts(mems:Boolean){ 16 | val callback = object : PlatformSQLiteOpenHelperCallback(4){ 17 | override fun onCreate(db: SQLiteDatabase) { 18 | QueryWrapper.onCreate(QueryWrapper.create(db).getConnection()) 19 | println("Create table success!!!!!") 20 | } 21 | 22 | override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { 23 | QueryWrapper.onMigrate( 24 | QueryWrapper.create(db).getConnection(), 25 | oldVersion, 26 | newVersion 27 | ) 28 | } 29 | } 30 | 31 | val helperHolder = createHolder(SqlDelightDatabaseHelper(createOpenHelper("binkyiscool", callback, null))) 32 | runOnBackground(InsertValues(helperHolder,15000, mems)) 33 | runOnBackground(InsertValues(helperHolder,15000, mems)) 34 | runOnBackground(InsertValues(helperHolder, 15000, mems)) 35 | runOnBackground(SelectValues(helperHolder, 10)) 36 | } 37 | } 38 | } 39 | 40 | expect fun createHolder(db: SqlDelightDatabaseHelper):HelperHolder 41 | 42 | expect fun memzy(body: () -> Unit) 43 | 44 | expect fun runOnBackground(workerData: WorkerData) 45 | //expect fun runOnMain(r:Runner) 46 | 47 | 48 | interface WorkerData{ 49 | fun runme() 50 | } 51 | 52 | data class InsertValues(val holder:HelperHolder, val count:Int, val mems:Boolean):WorkerData{ 53 | override fun runme() { 54 | val queryWrapper = QueryWrapper(holder.dbOpenHelper) 55 | 56 | val noteQueries = queryWrapper.noteQueries 57 | 58 | println("Total Count: ${noteQueries.count().executeAsOne()}") 59 | 60 | val now = currentTimeMillis() 61 | 62 | noteQueries.transaction { 63 | if(mems) { 64 | for (i in 0 until count) { 65 | memzy { 66 | noteQueries.insertNote("asdf", "qwert 🥃👀", now, now, null) 67 | } 68 | } 69 | }else{ 70 | memzy { 71 | for (i in 0 until count) { 72 | noteQueries.insertNote("asdf", "qwert 🥃👀", now, now, null) 73 | } 74 | } 75 | } 76 | } 77 | } 78 | } 79 | data class SelectValues(val holder:HelperHolder, val count:Long):WorkerData{ 80 | override fun runme() { 81 | val queryWrapper = QueryWrapper(holder.dbOpenHelper) 82 | 83 | val noteQueries = queryWrapper.noteQueries 84 | 85 | val alls = noteQueries.selectAll(count).executeAsList() 86 | for(row in alls){ 87 | println("id: ${row.id}/title: ${row.title}/note: ${row.note}") 88 | } 89 | } 90 | } 91 | data class WorkerResult(val count:Int) -------------------------------------------------------------------------------- /notepad/src/main/sqldelight/co/touchlab/kurgan/play/notepad/Note.sq: -------------------------------------------------------------------------------- 1 | CREATE TABLE note( 2 | id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 3 | title TEXT NOT NULL, 4 | note TEXT, 5 | created INTEGER NOT NULL, 6 | modified INTEGER NOT NULL, 7 | hiblob BLOB 8 | ); 9 | 10 | 11 | insertNote: 12 | INSERT OR FAIL INTO note(title, note, created, modified, hiblob) 13 | VALUES (?, ?, ?, ?, ?) 14 | ; 15 | 16 | 17 | count: 18 | SELECT COUNT(id) 19 | FROM note 20 | ; 21 | 22 | selectAll: 23 | SELECT id, title, note 24 | FROM note 25 | LIMIT ? 26 | ; 27 | 28 | 29 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':notepad' 2 | include ':notepad:android' 3 | include ':notepad:ios' 4 | 5 | def kotlinNativeDir = System.getenv('KOTLIN_NATIVE_DIR') 6 | 7 | includeBuild "${kotlinNativeDir}/shared" 8 | includeBuild "${kotlinNativeDir}/tools/kotlin-native-gradle-plugin" 9 | -------------------------------------------------------------------------------- /simulatorscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/touchlab-lab/kotlinmultiios/76da577db728297aa31cab5d31f919c8b31d3945/simulatorscreen.png --------------------------------------------------------------------------------