From 38053817726102ca4f989784564a29d7d9f7e586 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Wed, 1 Nov 2023 07:03:16 +0000 Subject: [PATCH] Update Core to 13.23.2 (#1557) --- CHANGELOG.md | 2 +- .../realm/kotlin/test/sync/SyncEnumTests.kt | 9 ++++ .../interop/sync/ProtocolErrorCode.kt | 19 +++++++ .../interop/sync/ProtocolErrorCode.kt | 44 ++++++++++++++++ packages/cinterop/src/native/realm.def | 2 +- .../interop/sync/ProtocolErrorCode.kt | 50 +++++++++++++++++++ packages/external/core | 2 +- packages/jni-swig-stub/realm.i | 8 ++- .../test/mongodb/common/SyncedRealmTests.kt | 1 - 9 files changed, 131 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf9ce2d1e..2ca238e662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ GET requests. (Issue [#1517](https://github.com/realm/realm-kotlin/pull/1517)) * Minimum Android SDK: 16. ### Internal -* Updated to Realm Core 13.23.1, commit 3618b2e9d679cd2880be8df17b79d4cc6d71ff76. +* Updated to Realm Core 13.23.2, commit e6271d72308b40399890060f58a88cf568c2ee22. ## 1.11.1 (2023-09-07) diff --git a/packages/cinterop/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/sync/SyncEnumTests.kt b/packages/cinterop/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/sync/SyncEnumTests.kt index 1effc3cd32..4d12f28409 100644 --- a/packages/cinterop/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/sync/SyncEnumTests.kt +++ b/packages/cinterop/src/androidInstrumentedTest/kotlin/io/realm/kotlin/test/sync/SyncEnumTests.kt @@ -28,6 +28,7 @@ import io.realm.kotlin.internal.interop.realm_sync_errno_connection_e import io.realm.kotlin.internal.interop.realm_sync_errno_session_e import io.realm.kotlin.internal.interop.realm_sync_session_resync_mode_e import io.realm.kotlin.internal.interop.realm_sync_session_state_e +import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e import io.realm.kotlin.internal.interop.realm_user_state_e import io.realm.kotlin.internal.interop.realm_web_socket_errno_e import io.realm.kotlin.internal.interop.sync.AuthProvider @@ -38,6 +39,7 @@ import io.realm.kotlin.internal.interop.sync.MetadataMode import io.realm.kotlin.internal.interop.sync.SyncConnectionErrorCode import io.realm.kotlin.internal.interop.sync.SyncSessionErrorCode import io.realm.kotlin.internal.interop.sync.SyncSessionResyncMode +import io.realm.kotlin.internal.interop.sync.WebsocketCallbackResult import io.realm.kotlin.internal.interop.sync.WebsocketErrorCode import org.junit.Test import kotlin.reflect.KClass @@ -135,6 +137,13 @@ class SyncEnumTests { } } + @Test + fun websocketResultCode() { + checkEnum(realm_sync_socket_callback_result_e::class) { nativeValue -> + WebsocketCallbackResult.of(nativeValue) + } + } + private inline fun checkEnum( enumClass: KClass, mapNativeValue: (Int) -> T? diff --git a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index b7984a1d84..dae3a68dd8 100644 --- a/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/commonMain/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -124,3 +124,22 @@ expect enum class WebsocketErrorCode : CodeDescription { internal fun of(nativeValue: Int): WebsocketErrorCode? } } + +/** + * Wrapper for C-API `realm_sync_socket_callback_result` + * See https://github.com/realm/realm-core/blob/master/src/realm/error_codes.h#L298 + */ +expect enum class WebsocketCallbackResult : CodeDescription { + RLM_ERR_SYNC_SOCKET_SUCCESS, + RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED, + RLM_ERR_SYNC_SOCKET_RUNTIME, + RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY, + RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED, + RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED, + RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED, + RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT; + + companion object { + fun of(nativeValue: Int): WebsocketCallbackResult? + } +} diff --git a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index 8ba8028fa8..d0fa2de33e 100644 --- a/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/jvm/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -19,6 +19,7 @@ package io.realm.kotlin.internal.interop.sync import io.realm.kotlin.internal.interop.CodeDescription import io.realm.kotlin.internal.interop.realm_sync_errno_connection_e import io.realm.kotlin.internal.interop.realm_sync_errno_session_e +import io.realm.kotlin.internal.interop.realm_sync_socket_callback_result_e import io.realm.kotlin.internal.interop.realm_web_socket_errno_e actual enum class SyncConnectionErrorCode( @@ -135,3 +136,46 @@ actual enum class WebsocketErrorCode( } } } + +actual enum class WebsocketCallbackResult(override val description: String, override val nativeValue: Int) : CodeDescription { + + RLM_ERR_SYNC_SOCKET_SUCCESS( + "Websocket callback success", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_SUCCESS + ), + RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED( + "Websocket callback aborted", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED + ), + RLM_ERR_SYNC_SOCKET_RUNTIME( + "Websocket Runtime error", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_RUNTIME + ), + RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY( + "Websocket out of memory ", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY + ), + RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED( + "Websocket address space exhausted", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED + ), + RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED( + "Websocket connection closed", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED + ), + RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED( + "Websocket not supported", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED + ), + RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT( + "Websocket invalid argument", + realm_sync_socket_callback_result_e.RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT + ); + + actual companion object { + actual fun of(nativeValue: Int): WebsocketCallbackResult? = + values().firstOrNull { value -> + value.nativeValue == nativeValue + } + } +} diff --git a/packages/cinterop/src/native/realm.def b/packages/cinterop/src/native/realm.def index 0c92edfbee..ec72bbd95a 100644 --- a/packages/cinterop/src/native/realm.def +++ b/packages/cinterop/src/native/realm.def @@ -11,7 +11,7 @@ headerFilter = realm.h realm/error_codes.h // libraryPaths.macos_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/ // libraryPaths.ios_x64 = ../external/core/build-macos_x64/src/realm/object-store/c_api ../external/core/build-macos_x64/src/realm ../external/core/build-macos_x64/src/realm/parser ../external/core/build-macos_x64/src/realm/object-store/ linkerOpts = -lcompression -lz -framework Foundation -framework CoreFoundation -framework Security -strictEnums = realm_errno realm_error_category realm_sync_errno_client realm_sync_errno_connection realm_sync_errno_session realm_web_socket_errno +strictEnums = realm_errno realm_error_category realm_sync_errno_client realm_sync_errno_connection realm_sync_errno_session realm_web_socket_errno realm_sync_socket_callback_result --- #include #include diff --git a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt index 20817a0ae5..818028eeb2 100644 --- a/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt +++ b/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/sync/ProtocolErrorCode.kt @@ -18,6 +18,7 @@ package io.realm.kotlin.internal.interop.sync import io.realm.kotlin.internal.interop.CodeDescription import realm_wrapper.realm_sync_errno_connection import realm_wrapper.realm_sync_errno_session +import realm_wrapper.realm_sync_socket_callback_result import realm_wrapper.realm_web_socket_errno actual enum class SyncConnectionErrorCode( @@ -138,3 +139,52 @@ actual enum class WebsocketErrorCode( } } } + +actual enum class WebsocketCallbackResult( + override val description: String, + nativeError: realm_sync_socket_callback_result +) : CodeDescription { + + RLM_ERR_SYNC_SOCKET_SUCCESS( + "Websocket callback success", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_SUCCESS + ), + RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED( + "Websocket callback aborted", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_OPERATION_ABORTED + ), + RLM_ERR_SYNC_SOCKET_RUNTIME( + "Websocket Runtime error", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_RUNTIME + ), + RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY( + "Websocket out of memory ", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_OUT_OF_MEMORY + ), + RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED( + "Websocket address space exhausted", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_ADDRESS_SPACE_EXHAUSTED + ), + RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED( + "Websocket connection closed", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_CONNECTION_CLOSED + ), + RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED( + "Websocket not supported", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_NOT_SUPPORTED + ), + RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT( + "Websocket invalid argument", + realm_sync_socket_callback_result.RLM_ERR_SYNC_SOCKET_INVALID_ARGUMENT + ); + + override val nativeValue: Int = nativeError.value.toInt() + val asNativeEnum: realm_sync_socket_callback_result = nativeError + + actual companion object { + actual fun of(nativeValue: Int): WebsocketCallbackResult? = + values().firstOrNull { value -> + value.nativeValue == nativeValue + } + } +} diff --git a/packages/external/core b/packages/external/core index 3618b2e9d6..e6271d7230 160000 --- a/packages/external/core +++ b/packages/external/core @@ -1 +1 @@ -Subproject commit 3618b2e9d679cd2880be8df17b79d4cc6d71ff76 +Subproject commit e6271d72308b40399890060f58a88cf568c2ee22 diff --git a/packages/jni-swig-stub/realm.i b/packages/jni-swig-stub/realm.i index 02880c1df5..8bc6d3b223 100644 --- a/packages/jni-swig-stub/realm.i +++ b/packages/jni-swig-stub/realm.i @@ -301,7 +301,7 @@ return $jnicall; realm_flx_sync_mutable_subscription_set_t*, realm_flx_sync_subscription_desc_t*, realm_set_t*, realm_async_open_task_t*, realm_dictionary_t*, realm_sync_session_connection_state_notification_token_t*, - realm_dictionary_changes_t*, realm_scheduler_t* }; + realm_dictionary_changes_t*, realm_scheduler_t*, realm_sync_socket_t* }; // For all functions returning a pointer or bool, check for null/false and throw an error if // realm_get_last_error returns true. @@ -330,6 +330,11 @@ bool realm_object_is_valid(const realm_object_t*); } jresult = (jboolean)result; } + +%typemap(javaimports) realm_sync_socket_callback_result %{ +import static io.realm.kotlin.internal.interop.realm_errno_e.*; +%} + // Just showcasing a wrapping concept. Maybe we should just go with `long` (apply void* as above) //%typemap(jstype) realm_t* "LongPointerWrapper" //%typemap(javain) realm_t* "$javainput.ptr()" @@ -431,4 +436,3 @@ bool realm_object_is_valid(const realm_object_t*); %include "realm.h" %include "realm/error_codes.h" %include "src/main/jni/realm_api_helpers.h" - diff --git a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt index e486bd9e4d..9ee6a43c5a 100644 --- a/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt +++ b/packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncedRealmTests.kt @@ -1260,7 +1260,6 @@ class SyncedRealmTests { } assertTrue(customLogger.logs.isNotEmpty()) assertTrue(customLogger.logs.any { it.contains("Connection[1]: Negotiated protocol version:") }, "Missing Connection[1]") - assertTrue(customLogger.logs.any { it.contains("MyCustomApp/1.0.0") }, "Missing MyCustomApp/1.0.0") } }