Skip to content

Commit

Permalink
Merge branch 'flutter-3.13-dart-3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Oct 16, 2023
2 parents 792e238 + 2b4d47e commit dc3851d
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 75 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# Prefer running on Ubuntu over Dart Docker image
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.3
sdk: 3.1.3
- name: Install ObjectBox C-API
run: ./install.sh
- name: Integration test
Expand All @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.10.4
flutter-version: 3.13.6
cache: true
- run: ./tool/init.sh

Expand All @@ -48,8 +48,8 @@ jobs:
sdk:
# Always include lowest supported version (see sdk key in objectbox and generator
# pubspec.yaml, but may be higher due to dependencies).
- 3.1.3
- 3.0.3
- 2.19.6
- 2.18.6
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
# Include lowest working version (use lowest tested Dart SDK as a guideline, see lib tests
# above; but may be higher due to dependency conflicts)
# https://docs.flutter.dev/development/tools/sdk/releases lists included Dart SDK.
- 3.10.4
- 3.13.6
- 3.7.12
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# Prefer running on Ubuntu over Dart Docker image
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.3
sdk: 3.1.3
- name: Get dependencies
run: |
dart pub get --directory=benchmark
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
# Prefer running on Ubuntu over Dart Docker image
- uses: dart-lang/setup-dart@v1
with:
sdk: 3.0.3
sdk: 3.1.3
- name: Install coverage tools
run: |
./tool/apt-install.sh lcov
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ stages:
variables:
# Note: use specific tags as docker images may not always be pulled due to "if-not-present" pull policy.
# Thus, do not use tags like latest/beta, but check https://hub.docker.com/_/dart?tab=tags for latest.
DART_VERSION: '3.0.3'
DART_VERSION: '3.1.3'

# Make PUB_CACHE cacheable in GitLab;
# see also https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77791/diffs and
Expand Down Expand Up @@ -88,7 +88,7 @@ test-lib:linux:x64:
# pulled due to "if-not-present" pull policy. Check https://hub.docker.com/_/dart?tab=tags.
# Always include lowest supported version (see sdk key in objectbox and generator
# pubspec.yaml, but may be higher due to dependencies).
- DART_VERSION: [ '2.18.6', '2.19.6', '3.0.3' ]
- DART_VERSION: [ '2.18.6', '3.0.3', '3.1.3' ]

# Runs tests with coverage on the objectbox package.
# Note: As this requires to run tests, make sure this does not block the actual test jobs so test
Expand Down
92 changes: 49 additions & 43 deletions objectbox/lib/src/native/bindings/objectbox_c.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1360,8 +1360,8 @@ class ObjectBoxC {
}

late final _opt_get_max_db_size_in_kbPtr = _lookup<
ffi.NativeFunction<
ffi.Uint64 Function(ffi.Pointer<OBX_store_options>)>>(
ffi
.NativeFunction<ffi.Uint64 Function(ffi.Pointer<OBX_store_options>)>>(
'obx_opt_get_max_db_size_in_kb');
late final _opt_get_max_db_size_in_kb = _opt_get_max_db_size_in_kbPtr
.asFunction<int Function(ffi.Pointer<OBX_store_options>)>();
Expand All @@ -1377,8 +1377,8 @@ class ObjectBoxC {
}

late final _opt_get_max_data_size_in_kbPtr = _lookup<
ffi.NativeFunction<
ffi.Uint64 Function(ffi.Pointer<OBX_store_options>)>>(
ffi
.NativeFunction<ffi.Uint64 Function(ffi.Pointer<OBX_store_options>)>>(
'obx_opt_get_max_data_size_in_kb');
late final _opt_get_max_data_size_in_kb = _opt_get_max_data_size_in_kbPtr
.asFunction<int Function(ffi.Pointer<OBX_store_options>)>();
Expand All @@ -1394,9 +1394,9 @@ class ObjectBoxC {
}

late final _opt_get_debug_flagsPtr = _lookup<
ffi.NativeFunction<
ffi.Uint32 Function(
ffi.Pointer<OBX_store_options>)>>('obx_opt_get_debug_flags');
ffi
.NativeFunction<ffi.Uint32 Function(ffi.Pointer<OBX_store_options>)>>(
'obx_opt_get_debug_flags');
late final _opt_get_debug_flags = _opt_get_debug_flagsPtr
.asFunction<int Function(ffi.Pointer<OBX_store_options>)>();

Expand All @@ -1411,8 +1411,9 @@ class ObjectBoxC {
}

late final _opt_freePtr = _lookup<
ffi.NativeFunction<
ffi.Void Function(ffi.Pointer<OBX_store_options>)>>('obx_opt_free');
ffi
.NativeFunction<ffi.Void Function(ffi.Pointer<OBX_store_options>)>>(
'obx_opt_free');
late final _opt_free =
_opt_freePtr.asFunction<void Function(ffi.Pointer<OBX_store_options>)>();

Expand Down Expand Up @@ -2193,9 +2194,9 @@ class ObjectBoxC {
}

late final _cursor_seekPtr = _lookup<
ffi.NativeFunction<
obx_err Function(
ffi.Pointer<OBX_cursor>, obx_id)>>('obx_cursor_seek');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_cursor>, obx_id)>>(
'obx_cursor_seek');
late final _cursor_seek =
_cursor_seekPtr.asFunction<int Function(ffi.Pointer<OBX_cursor>, int)>();

Expand Down Expand Up @@ -2232,9 +2233,9 @@ class ObjectBoxC {
}

late final _cursor_removePtr = _lookup<
ffi.NativeFunction<
obx_err Function(
ffi.Pointer<OBX_cursor>, obx_id)>>('obx_cursor_remove');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_cursor>, obx_id)>>(
'obx_cursor_remove');
late final _cursor_remove = _cursor_removePtr
.asFunction<int Function(ffi.Pointer<OBX_cursor>, int)>();

Expand Down Expand Up @@ -4779,9 +4780,9 @@ class ObjectBoxC {
}

late final _query_offsetPtr = _lookup<
ffi.NativeFunction<
obx_err Function(
ffi.Pointer<OBX_query>, ffi.Size)>>('obx_query_offset');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_query>, ffi.Size)>>(
'obx_query_offset');
late final _query_offset =
_query_offsetPtr.asFunction<int Function(ffi.Pointer<OBX_query>, int)>();

Expand Down Expand Up @@ -4822,9 +4823,9 @@ class ObjectBoxC {
}

late final _query_limitPtr = _lookup<
ffi.NativeFunction<
obx_err Function(
ffi.Pointer<OBX_query>, ffi.Size)>>('obx_query_limit');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_query>, ffi.Size)>>(
'obx_query_limit');
late final _query_limit =
_query_limitPtr.asFunction<int Function(ffi.Pointer<OBX_query>, int)>();

Expand Down Expand Up @@ -7295,9 +7296,9 @@ class ObjectBoxC {
}

late final _sync_heartbeat_intervalPtr = _lookup<
ffi.NativeFunction<
obx_err Function(ffi.Pointer<OBX_sync>,
ffi.Uint64)>>('obx_sync_heartbeat_interval');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_sync>, ffi.Uint64)>>(
'obx_sync_heartbeat_interval');
late final _sync_heartbeat_interval = _sync_heartbeat_intervalPtr
.asFunction<int Function(ffi.Pointer<OBX_sync>, int)>();

Expand Down Expand Up @@ -7330,9 +7331,9 @@ class ObjectBoxC {
}

late final _sync_request_updates_modePtr = _lookup<
ffi.NativeFunction<
obx_err Function(ffi.Pointer<OBX_sync>,
ffi.Int32)>>('obx_sync_request_updates_mode');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_sync>, ffi.Int32)>>(
'obx_sync_request_updates_mode');
late final _sync_request_updates_mode = _sync_request_updates_modePtr
.asFunction<int Function(ffi.Pointer<OBX_sync>, int)>();

Expand Down Expand Up @@ -7405,9 +7406,9 @@ class ObjectBoxC {
}

late final _sync_wait_for_logged_in_statePtr = _lookup<
ffi.NativeFunction<
obx_err Function(ffi.Pointer<OBX_sync>,
ffi.Uint64)>>('obx_sync_wait_for_logged_in_state');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_sync>, ffi.Uint64)>>(
'obx_sync_wait_for_logged_in_state');
late final _sync_wait_for_logged_in_state = _sync_wait_for_logged_in_statePtr
.asFunction<int Function(ffi.Pointer<OBX_sync>, int)>();

Expand All @@ -7428,9 +7429,9 @@ class ObjectBoxC {
}

late final _sync_updates_requestPtr = _lookup<
ffi.NativeFunction<
obx_err Function(
ffi.Pointer<OBX_sync>, ffi.Bool)>>('obx_sync_updates_request');
ffi
.NativeFunction<obx_err Function(ffi.Pointer<OBX_sync>, ffi.Bool)>>(
'obx_sync_updates_request');
late final _sync_updates_request = _sync_updates_requestPtr
.asFunction<int Function(ffi.Pointer<OBX_sync>, bool)>();

Expand Down Expand Up @@ -8166,9 +8167,9 @@ class ObjectBoxC {
}

late final _sync_server_portPtr = _lookup<
ffi.NativeFunction<
ffi.Uint16 Function(
ffi.Pointer<OBX_sync_server>)>>('obx_sync_server_port');
ffi
.NativeFunction<ffi.Uint16 Function(ffi.Pointer<OBX_sync_server>)>>(
'obx_sync_server_port');
late final _sync_server_port = _sync_server_portPtr
.asFunction<int Function(ffi.Pointer<OBX_sync_server>)>();

Expand All @@ -8182,9 +8183,9 @@ class ObjectBoxC {
}

late final _sync_server_connectionsPtr = _lookup<
ffi.NativeFunction<
ffi.Uint64 Function(
ffi.Pointer<OBX_sync_server>)>>('obx_sync_server_connections');
ffi
.NativeFunction<ffi.Uint64 Function(ffi.Pointer<OBX_sync_server>)>>(
'obx_sync_server_connections');
late final _sync_server_connections = _sync_server_connectionsPtr
.asFunction<int Function(ffi.Pointer<OBX_sync_server>)>();

Expand Down Expand Up @@ -8805,13 +8806,18 @@ class ObjectBoxC {

class _SymbolAddresses {
final ObjectBoxC _library;

_SymbolAddresses(this._library);

ffi.Pointer<ffi.NativeFunction<obx_err Function(ffi.Pointer<OBX_store>)>>
get store_close => _library._store_closePtr;

ffi.Pointer<ffi.NativeFunction<obx_err Function(ffi.Pointer<OBX_query>)>>
get query_close => _library._query_closePtr;

ffi.Pointer<ffi.NativeFunction<obx_err Function(ffi.Pointer<OBX_query_prop>)>>
get query_prop_close => _library._query_prop_closePtr;

ffi.Pointer<ffi.NativeFunction<obx_err Function(ffi.Pointer<OBX_admin>)>>
get admin_close => _library._admin_closePtr;
}
Expand Down Expand Up @@ -9548,8 +9554,8 @@ typedef OBX_custom_msg_server_func_shutdown = ffi
/// Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.
/// @param bytes lazy bytes storing the message
/// @param server_user_data User supplied data returned by the function that created the server
typedef OBX_custom_msg_server_func_client_connection_send_async
= ffi.NativeFunction<
typedef OBX_custom_msg_server_func_client_connection_send_async = ffi
.NativeFunction<
ffi.Bool Function(
ffi.Pointer<OBX_bytes_lazy> bytes,
ffi.Pointer<ffi.Void> server_user_data,
Expand All @@ -9566,8 +9572,8 @@ typedef OBX_custom_msg_server_func_client_connection_close = ffi.NativeFunction<
/// Note that the custom server may already have been shutdown at this point (e.g. no server user data is supplied).
/// Must be provided to implement a custom server. See notes on OBX_custom_msg_server_functions for more details.
/// @param server_user_data User supplied data returned by the function that created the server
typedef OBX_custom_msg_server_func_client_connection_shutdown
= ffi.NativeFunction<
typedef OBX_custom_msg_server_func_client_connection_shutdown = ffi
.NativeFunction<
ffi.Void Function(ffi.Pointer<ffi.Void> connection_user_data)>;

/// Struct of the custom client function callbacks. In order to implement the custom client, you must provide
Expand Down
7 changes: 7 additions & 0 deletions objectbox_test/test/basics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import 'package:objectbox/src/native/bindings/helpers.dart';
import 'package:objectbox/src/native/version.dart';
import 'package:test/test.dart';

import 'test_env.dart';

void main() {
test("Dart version test helper", () {
expect(atLeastDart("2.15.0"), true);
expect(atLeastDart("999.0.0"), false);
});

print("Testing basics of ObjectBox using C lib V${libraryVersion()}");

// Prior to Dart 2.6, the exception wasn't accessible and may have crashed.
Expand Down
35 changes: 18 additions & 17 deletions objectbox_test/test/box_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,18 @@ void main() {
final object = TestEntity2()..value = 42;
final future = box.putQueuedAwaitResult(object);

try {
await future;
} catch (e) {
// TODO: Mac in GitHub CI (not locally reproducible yet)...
if (Platform.isMacOS) {
expect(e is ObjectBoxException, isTrue);
expect((e as ObjectBoxException).message, '');
} else {
expect(e is UniqueViolationException, isTrue);
expect(e.toString(), contains('Unique constraint'));
}
if (Platform.isMacOS && !atLeastDart('3.1.0')) {
// Before Dart 3.1 an incorrect exception is thrown on macOS.
expect(
() async => await future,
throwsA(
predicate((e) => e is ObjectBoxException && e.message == '')));
} else {
expect(
() async => await future,
throwsA(predicate((e) =>
e is UniqueViolationException &&
e.message.contains('Unique constraint'))));
}

expect(object.id, isNull); // ID must remain unassigned
Expand Down Expand Up @@ -834,7 +835,7 @@ void main() {
await store.runInTransactionAsync(TxMode.write, callback, simpleItems());
count = box.count();
expect(count, equals(6));
}, skip: notAtLeastDart2_15_0());
});

test('async txn - send and receive relations', () async {
final testBox = store.box<TestEntity>();
Expand Down Expand Up @@ -862,7 +863,7 @@ void main() {
object.relA.target;
object.relManyA.length;
}
}, skip: notAtLeastDart2_15_0());
});

test('failing transactions', () {
expect(
Expand Down Expand Up @@ -896,7 +897,7 @@ void main() {
}, simpleItems()),
throwsA('test-exception'));
expect(box.count(), equals(0));
}, skip: notAtLeastDart2_15_0());
});

test('recursive write in write transaction', () {
store.runInTransaction(TxMode.write, () {
Expand All @@ -922,7 +923,7 @@ void main() {
});
}, simpleItems());
expect(box.count(), equals(12));
}, skip: notAtLeastDart2_15_0());
});

test('recursive read in write transaction', () {
int count = store.runInTransaction(TxMode.write, () {
Expand All @@ -940,7 +941,7 @@ void main() {
return store.runInTransaction(TxMode.read, box.count);
}, simpleItems());
expect(count, equals(6));
}, skip: notAtLeastDart2_15_0());
});

test('recursive write in read -> fails during creation', () {
expect(
Expand All @@ -964,7 +965,7 @@ void main() {
}, simpleItems()),
throwsA(predicate((StateError e) => e.toString().contains(
'Bad state: failed to create transaction: Cannot start a write transaction inside a read only transaction (OBX_ERROR code 10001)'))));
}, skip: notAtLeastDart2_15_0());
});

test('failing in recursive txn', () {
store.runInTransaction(TxMode.write, () {
Expand Down
Loading

0 comments on commit dc3851d

Please sign in to comment.