Skip to content

Commit

Permalink
Merge pull request #40 from ctripcorp/main
Browse files Browse the repository at this point in the history
Merge main to dev-wasm
  • Loading branch information
qiaoyuang authored Aug 14, 2023
2 parents 80b7257 + bad20e0 commit a4e5004
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 30 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

- Date format: YYYY-MM-dd

## v1.1.1 / 2023-xx-xx
## v1.1.1 / 2023-08-12

### sqllin-dsl
### All

* *Breaking Change*: Remove the public API `DBEntity`([#36](https://github.com/ctripcorp/SQLlin/pull/36)), any data classes used in _sqllin-dsl_ don't need to extend `DBEntity` anymore.
* Update `Kotlin`'s version to `1.9.0`

### sqllin-dsl

* Deprecated the public API `DBEntity`([#36](https://github.com/ctripcorp/SQLlin/pull/36), [#37](https://github.com/ctripcorp/SQLlin/pull/37)), any data classes used in _sqllin-dsl_ don't need to extend `DBEntity` anymore

### sqllin-driver

* Fix a bug about empty `ByteArray` on native platforms([#30](https://github.com/ctripcorp/SQLlin/pull/30))

### sqllin-processor

* Update `KSP`'s version to `1.9.0-1.0.13`

## v1.1.0 / 2023-06-06

### All
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
VERSION=1.1.0
VERSION=1.1.1
GROUP=com.ctrip.kotlin

kotlinVersion=1.8.20
kspVersion=1.8.20-1.0.11
kotlinVersion=1.9.0
kspVersion=1.9.0-1.0.13

#Maven Publish Information
githubURL=https://github.com/ctripcorp/SQLlin
Expand Down
2 changes: 1 addition & 1 deletion sqllin-driver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ kotlin {
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
}
}
val androidMain by getting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.BetaInteropApi
import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Foundation.NSString
import platform.Foundation.create

Expand All @@ -26,6 +28,7 @@ import platform.Foundation.create
* @author yqiao
*/

@OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
internal actual fun bytesToString(bv: CPointer<ByteVar>): String = NSString.create(uTF8String = bv).toString()

internal actual inline val separatorChar: Char
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.Arena
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.ptr
import platform.posix.PTHREAD_MUTEX_RECURSIVE
Expand All @@ -37,6 +38,7 @@ import platform.posix.pthread_mutexattr_t
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal actual class Lock actual constructor() {

private val arena = Arena()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKString

/**
* The tools with Linux implementation
* @author yqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal actual fun bytesToString(bv: CPointer<ByteVar>): String = bv.toKString()

internal actual inline val separatorChar: Char
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.ctrip.sqllin.driver

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKString
import platform.posix.getcwd

Expand All @@ -24,5 +25,6 @@ import platform.posix.getcwd
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
actual fun getPlatformStringPath(): String =
getcwd(null, 0)?.toKString() ?: throw IllegalStateException("The temp path created error")
getcwd(null, 0u)?.toKString() ?: throw IllegalStateException("The temp path created error")
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.Arena
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.alloc
import kotlinx.cinterop.ptr
import platform.posix.PTHREAD_MUTEX_RECURSIVE
Expand All @@ -37,6 +38,7 @@ import platform.posix.pthread_mutexattr_tVar
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal actual class Lock actual constructor() {

private val arena = Arena()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKStringFromUtf8

/**
* The tools with Windows implementation
* @author yqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal actual fun bytesToString(bv: CPointer<ByteVar>): String = bv.toKStringFromUtf8()

internal actual inline val separatorChar: Char
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ import platform.posix._wgetcwd
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
actual fun getPlatformStringPath(): String =
_wgetcwd(null, 0)?.toKString() ?: throw IllegalStateException("Get database path wrong")
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package com.ctrip.sqllin.driver
import com.ctrip.sqllin.driver.cinterop.NativeDatabase
import com.ctrip.sqllin.driver.platform.Lock
import com.ctrip.sqllin.driver.platform.withLock
import kotlin.native.concurrent.AtomicInt
import kotlin.native.concurrent.AtomicReference
import kotlin.concurrent.AtomicInt
import kotlin.concurrent.AtomicReference

/**
* Database manager Native actual
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SQLiteResultCode(message: String, resultCode: Int) : SQLiteExceptio
"$message | error code ${
kotlin.run {
val code = resultCode and 0xff
SQLiteErrorType.values().find { it.code == code }
SQLiteErrorType.entries.find { it.code == code }
}
}") {
internal companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@ import com.ctrip.sqllin.sqlite3.sqlite3_errmsg
import com.ctrip.sqllin.sqlite3.sqlite3_exec
import com.ctrip.sqllin.sqlite3.sqlite3_open_v2
import com.ctrip.sqllin.sqlite3.sqlite3_prepare16_v2
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.CPointerVar
import kotlinx.cinterop.alloc
import kotlinx.cinterop.memScoped
import kotlinx.cinterop.ptr
import kotlinx.cinterop.toKString
import kotlinx.cinterop.value
import kotlinx.cinterop.wcstr
import kotlinx.cinterop.*

/**
* The native database wrapper for `sqlite3`, interop with SQLite C APIs directly
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal class NativeDatabase private constructor(val dbPointer: CPointer<sqlite3>) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ import com.ctrip.sqllin.sqlite3.sqlite3_finalize
import com.ctrip.sqllin.sqlite3.sqlite3_last_insert_rowid
import com.ctrip.sqllin.sqlite3.sqlite3_reset
import com.ctrip.sqllin.sqlite3.sqlite3_step
import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.readBytes
import kotlinx.cinterop.refTo
import kotlinx.cinterop.reinterpret
import kotlinx.cinterop.toKString
import kotlinx.cinterop.*
import platform.posix.usleep

/**
* The native statement wrapper for `sqlite3_stmt`, interop with SQLite C APIs directly
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal class NativeStatement(
private val database: NativeDatabase,
private val cStatementPointer: CPointer<sqlite3_stmt>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ package com.ctrip.sqllin.driver.platform

import kotlinx.cinterop.ByteVar
import kotlinx.cinterop.CPointer
import kotlinx.cinterop.ExperimentalForeignApi

/**
* The tools with platform-specific implementation
* @author yqiao
*/

@OptIn(ExperimentalForeignApi::class)
internal expect fun bytesToString(bv: CPointer<ByteVar>): String

internal expect val separatorChar: Char
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.ctrip.sqllin.dsl.sql.statement.TransactionStatementsGroup
import kotlinx.serialization.KSerializer
import kotlinx.serialization.modules.EmptySerializersModule
import kotlinx.serialization.serializer
import kotlin.jvm.Volatile
import kotlin.concurrent.Volatile

/**
* Database object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.ctrip.sqllin.dsl.sql.Table
import com.ctrip.sqllin.dsl.sql.clause.*
import com.ctrip.sqllin.dsl.sql.compiler.QueryDecoder
import kotlinx.serialization.DeserializationStrategy
import kotlin.jvm.Volatile
import kotlin.concurrent.Volatile

/**
* Select statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.ctrip.sqllin.dsl.sql.statement

import kotlin.jvm.Volatile
import kotlin.concurrent.Volatile

/**
* A sample Stack implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.ctrip.sqllin.dsl

import kotlinx.cinterop.ExperimentalForeignApi
import kotlinx.cinterop.toKString
import platform.posix.getcwd

Expand All @@ -24,7 +25,8 @@ import platform.posix.getcwd
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
actual fun getPlatformStringPath(): String =
getcwd(null, 0)?.toKString() ?: throw IllegalStateException("The temp path created error")
getcwd(null, 0u)?.toKString() ?: throw IllegalStateException("The temp path created error")

actual val pathSeparator: Char = '/'
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import platform.posix._wgetcwd
* @author yaqiao
*/

@OptIn(ExperimentalForeignApi::class)
actual fun getPlatformStringPath(): String =
_wgetcwd(null, 0)?.toKString() ?: throw IllegalStateException("Get database path wrong")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.google.devtools.ksp.symbol.*
import java.io.OutputStreamWriter

/**
* Generate the clause property for data class that present the database entity
* Generate the clause properties for data classes that present the database entity
* @author yaqiao
*/

Expand Down

0 comments on commit a4e5004

Please sign in to comment.