Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Core to 13.23.2 #1557

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -135,6 +137,13 @@ class SyncEnumTests {
}
}

@Test
fun websocketResultCode() {
checkEnum(realm_sync_socket_callback_result_e::class) { nativeValue ->
WebsocketCallbackResult.of(nativeValue)
}
}

private inline fun <T : Any> checkEnum(
enumClass: KClass<out Any>,
mapNativeValue: (Int) -> T?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion packages/cinterop/src/native/realm.def
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pthread.h>
#include <time.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
}
}
2 changes: 1 addition & 1 deletion packages/external/core
Submodule core updated 59 files
+28 −2 CHANGELOG.md
+0 −59 Jenkinsfile
+1 −1 Package.swift
+6 −2 bindgen/src/realm_helpers.h
+1 −1 dependencies.list
+86 −0 evergreen/config.yml
+13,470 −11,749 src/external/json/json.hpp
+1 −0 src/external/s2/CMakeLists.txt
+68 −25 src/realm.h
+5 −3 src/realm/CMakeLists.txt
+0 −86 src/realm/array.cpp
+28 −30 src/realm/array_with_find.hpp
+1 −1 src/realm/cluster_tree.cpp
+1 −1 src/realm/cluster_tree.hpp
+4 −4 src/realm/db.cpp
+12 −0 src/realm/error_codes.h
+10 −16 src/realm/group.hpp
+40 −42 src/realm/object-store/c_api/socket_provider.cpp
+13 −5 src/realm/object-store/c_api/types.hpp
+8 −2 src/realm/object-store/util/bson/bson.cpp
+0 −1 src/realm/query_engine.hpp
+34 −4 src/realm/sync/network/default_socket.cpp
+5 −0 src/realm/sync/network/network_ssl.cpp
+13 −19 src/realm/sync/network/websocket.cpp
+6 −7 src/realm/sync/network/websocket.hpp
+1 −0 src/realm/sync/noinst/client_history_impl.cpp
+12 −8 src/realm/sync/noinst/client_impl_base.cpp
+12 −9 src/realm/sync/noinst/server/server.cpp
+10 −6 src/realm/sync/subscriptions.cpp
+8 −6 src/realm/sync/transform.cpp
+17 −13 src/realm/table.cpp
+8 −7 src/realm/table.hpp
+3 −3 src/realm/timestamp.hpp
+7 −3 src/realm/util/interprocess_mutex.hpp
+2 −0 src/realm/util/logger.cpp
+4 −4 src/realm/util/serializer.cpp
+2 −0 src/realm/util/timestamp_logger.cpp
+4 −1 test/CMakeLists.txt
+1 −1 test/fuzz_tester.hpp
+19 −14 test/object-store/audit.cpp
+1,123 −1,024 test/object-store/c_api/c_api.cpp
+4 −2 test/object-store/migrations.cpp
+9 −0 test/object-store/object.cpp
+8 −6 test/object-store/realm.cpp
+1 −1 test/object-store/sync/flx_migration.cpp
+2 −0 test/object-store/sync/flx_sync.cpp
+6 −2 test/object-store/util/sync/sync_test_utils.cpp
+13 −0 test/test_file.cpp
+8 −8 test/test_json.cpp
+64 −0 test/test_shared.cpp
+2 −2 test/test_table.cpp
+3 −3 test/test_util_websocket.cpp
+10 −4 test/util/test_path.cpp
+8 −1 test/util/test_path.hpp
+4 −5 test/util/unit_test.cpp
+1 −1 test/util/unit_test.hpp
+6 −0 tools/build-apple-device.sh
+47 −19 tools/cmake/SpecialtyBuilds.cmake
+10 −6 tools/cmake/xcode.toolchain.cmake
8 changes: 6 additions & 2 deletions packages/jni-swig-stub/realm.i
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()"
Expand Down Expand Up @@ -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"

Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down