diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 928b50cfee..2b4e709cd3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -498,6 +498,11 @@ jobs: needs.check-cache.outputs.android-test-sync-apk-cache-hit != 'true') steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + - name: Checkout code uses: actions/checkout@v3 with: @@ -1350,12 +1355,6 @@ jobs: with: cache-read-only: false - - name: Restore m2-buildrepo (mac) - uses: actions/download-artifact@v3 - with: - name: packages-macos-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - name: Restore m2-buildrepo (ios) uses: actions/download-artifact@v3 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 835afb0f19..dd6f9d4aac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ * Updated to CMake 3.27.7 * Updated to Realm Core 13.26.0, commit 5533505d18fda93a7a971d58a191db5005583c92. * Adding Sync tests via Github Action. +* Updated to Swig 4.2.0. (Issue [GitHub #1632](https://github.com/realm/realm-kotlin/issues/1632)[JIRA RKOTLIN-1001](https://jira.mongodb.org/browse/RKOTLIN-1001)) ## 1.13.1-SNAPSHOT (YYYY-MM-DD) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a83a4d590..0cd3db7f53 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ We welcomes all contributions! The only requirement we have is that, like many o ### Prerequisites -- Swig 4.1.0 or above. On Mac this can be installed using Homebrew: `brew install swig`. +- Swig 4.2.0 or above. On Mac this can be installed using Homebrew: `brew install swig`. - Ccache. On Mac this can be installed using Homebrew: `brew install ccache`. - CMake 3.18.1 or above. Can be installed through the Android SDK Manager. - Java 11. diff --git a/packages/jni-swig-stub/realm.i b/packages/jni-swig-stub/realm.i index fcaae087eb..bbbad4dcbd 100644 --- a/packages/jni-swig-stub/realm.i +++ b/packages/jni-swig-stub/realm.i @@ -283,13 +283,13 @@ typedef jstring realm_string_t; } %typemap(out) (realm_string_t) "$result = to_jstring(jenv, StringData{$1.data, $1.size});" +// Type map to allow passing void* as Long %typemap(jstype) void* "long" %typemap(javain) void* "$javainput" %typemap(javadirectorin) void* "$1" %typemap(javaout) void* { -return $jnicall; + return $jnicall; } - // Reuse above type maps on other pointers too %apply void* { realm_t*, realm_config_t*, realm_schema_t*, realm_object_t* , realm_query_t*, realm_results_t*, realm_notification_token_t*, realm_object_changes_t*, @@ -346,6 +346,9 @@ import static io.realm.kotlin.internal.interop.realm_errno_e.*; // Array wrappers to allow building (continuous allocated) arrays of the corresponding types from // JVM %include "carrays.i" +// Workaround for updated Swig behavior with 4.2.0 +// https://github.com/swig/swig/commit/ecaa052f3d319834a66aaa07047be3662e5e52e2#diff-cd2fcc891412baae0fc46479c0870cbdd18133d06d68dcd216be8a37ecf77b37R10 +%apply int { size_t nelements, size_t index } %array_functions(realm_class_info_t, classArray); %array_functions(realm_property_info_t, propertyArray); %array_functions(realm_property_info_t*, propertyArrayArray); @@ -355,9 +358,9 @@ import static io.realm.kotlin.internal.interop.realm_errno_e.*; %array_functions(realm_query_arg_t, queryArgArray); %array_functions(realm_user_identity_t, identityArray); %array_functions(realm_app_user_apikey_t, apiKeyArray); - -// Work around issues with realm_size_t on Windows https://jira.mongodb.org/browse/RKOTLIN-332 -%apply int64_t[] { size_t* }; +// Workaround for updated Swig behavior with 4.2.0 +// https://github.com/swig/swig/commit/ecaa052f3d319834a66aaa07047be3662e5e52e2#diff-cd2fcc891412baae0fc46479c0870cbdd18133d06d68dcd216be8a37ecf77b37R10 +%clear size_t nelements, size_t index; // bool output parameter %apply bool* OUTPUT { bool* out_found, bool* did_create, bool* did_delete_realm, bool* out_inserted, @@ -367,30 +370,51 @@ import static io.realm.kotlin.internal.interop.realm_errno_e.*; // uint64_t output parameter for realm_get_num_versions %apply int64_t* OUTPUT { uint64_t* out_versions_count }; -// Enable passing uint8_t* parameters for realm_config_get_encryption_key and realm_config_set_encryption_key as Byte[] -%apply int8_t[] {uint8_t *key}; -%apply int8_t[] {uint8_t *out_key}; -%apply int8_t[] {const uint8_t* data}; - -// Enable passing uint8_t [64] parameter for realm_sync_client_config_set_metadata_encryption_key as Byte[] -%apply int8_t[] {uint8_t [64]}; - -// Enable passing uint8_t [2] parameter for realm_decimal128 as Long[] -%apply int64_t[] {uint64_t w[2]}; - -%typemap(out) uint64_t w[2] %{ - $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2); +// Enable passing uint8_t* as byte[] +%apply int8_t[] {uint8_t*}; // +%typemap(in) uint8_t* (jbyte *jarr) %{ + if(!SWIG_JavaArrayInSchar(jenv, &jarr, (signed char **)&$1, $input)) return $null; %} - -%typemap(freearg) const uint8_t* data; -%typemap(out) const uint8_t* data %{ +%typemap(out) uint8_t* %{ $result = SWIG_JavaArrayOutSchar(jenv, (signed char *)result, arg1->size); %} +%typemap(argout) uint8_t* %{ +SWIG_JavaArrayArgoutSchar(jenv, jarr$argnum, (signed char *)$1, $input); +%} +%typemap(freearg) uint8_t*; + +// Reuse above typemap for passing uint8_t[64] parameter for realm_sync_client_config_set_metadata_encryption_key as Byte[] +%apply uint8_t* {uint8_t [64]}; -// Enable passing output argument pointers as long[] +// Enable passing void** as long[] %apply int64_t[] {void **}; -%apply void** {realm_object_t**, realm_list_t**, size_t*, realm_class_key_t*, - realm_property_key_t*, realm_user_t**, realm_set_t**, realm_results_t**}; +%typemap(in) void ** (jlong *jarr) %{ + if(!SWIG_JavaArrayInLonglong(jenv, &jarr, (long long **)&$1, $input)) return $null; +%} +%typemap(out) void ** %{ + $result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, arg1->size); +%} +%typemap(argout) void ** %{ + SWIG_JavaArrayArgoutLonglong(jenv, jarr$argnum, (long long *)$1, $input); +%} +%typemap(freearg) void**; + +// Reuse above typemap for void** (from apply int64_t[]) {void **}) to pass various pointer types as +// long[] +%apply void** {realm_object_t**, realm_list_t**, realm_class_key_t*, size_t*, +realm_property_key_t*, realm_user_t**, realm_set_t**, realm_results_t**}; + +// Enable passing uint64_t [2] parameter for realm_decimal128 as Long[] +%apply int64_t[] {uint64_t w[2]}; +%typemap(in) uint64_t w[2] (jlong *jarr) %{ +if(!SWIG_JavaArrayInLonglong(jenv, &jarr, (long long **)&$1, $input)) return $null; +%} +%typemap(argout) uint64_t w[2] %{ +SWIG_JavaArrayArgoutLonglong(jenv, jarr$argnum, (long long *)$1, $input); +%} +%typemap(out) uint64_t w[2] %{ +$result = SWIG_JavaArrayOutLonglong(jenv, (long long *)result, 2); +%} %apply uint32_t[] {realm_class_key_t*};