Skip to content

Commit d427eb2

Browse files
dart run ffigen to update C API Dart bindings.
1 parent 55cdfe6 commit d427eb2

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

objectbox/lib/src/native/bindings/objectbox_c.dart

+32-1
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,11 @@ class ObjectBoxC {
11201120
_store_is_open_ptr.asFunction<_dart_store_is_open>();
11211121

11221122
/// Attach to a previously opened store matching the path of the DB directory, which was used for opening the store.
1123-
/// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed.
1123+
/// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed
1124+
/// via obx_store_close().
11241125
/// The actual underlying store is only closed when the last store OBX_store instance is closed.
11251126
/// @returns nullptr if no open store was found (i.e. not opened before or already closed)
1127+
/// @see obx_store_clone() for "attaching" to a available store instance.
11261128
ffi.Pointer<OBX_store> store_attach(
11271129
ffi.Pointer<ffi.Int8> path,
11281130
) {
@@ -1160,6 +1162,27 @@ class ObjectBoxC {
11601162
late final _dart_store_attach_or_open _store_attach_or_open =
11611163
_store_attach_or_open_ptr.asFunction<_dart_store_attach_or_open>();
11621164

1165+
/// Clone a previously opened store; while a store instance is usable from multiple threads, situations may exist
1166+
/// in which cloning a store simplifies the overall lifecycle.
1167+
/// E.g. when a store is used for multiple threads and it may only be fully released once the last thread completes.
1168+
/// The returned store is a new instance (e.g. different pointer value) with its own lifetime and must also be closed
1169+
/// via obx_store_close().
1170+
/// The actual underlying store is only closed when the last store OBX_store instance is closed.
1171+
/// @returns nullptr if the store could not be cloned
1172+
/// @see obx_store_attach() for "cloning" using the store's path.
1173+
ffi.Pointer<OBX_store> store_clone(
1174+
ffi.Pointer<OBX_store> store,
1175+
) {
1176+
return _store_clone(
1177+
store,
1178+
);
1179+
}
1180+
1181+
late final _store_clone_ptr =
1182+
_lookup<ffi.NativeFunction<_c_store_clone>>('obx_store_clone');
1183+
late final _dart_store_clone _store_clone =
1184+
_store_clone_ptr.asFunction<_dart_store_clone>();
1185+
11631186
/// For stores created outside of this C API, e.g. via C++ or Java, this is how you can use it via C too.
11641187
/// Like this, it is OK to use the same store instance (same database) from multiple languages in parallel.
11651188
/// Note: the store's life time will still be managed outside of the C API;
@@ -7679,6 +7702,14 @@ typedef _dart_store_attach_or_open = ffi.Pointer<OBX_store> Function(
76797702
ffi.Pointer<ffi.Uint8> out_attached,
76807703
);
76817704

7705+
typedef _c_store_clone = ffi.Pointer<OBX_store> Function(
7706+
ffi.Pointer<OBX_store> store,
7707+
);
7708+
7709+
typedef _dart_store_clone = ffi.Pointer<OBX_store> Function(
7710+
ffi.Pointer<OBX_store> store,
7711+
);
7712+
76827713
typedef _c_store_wrap = ffi.Pointer<OBX_store> Function(
76837714
ffi.Pointer<ffi.Void> core_store,
76847715
);

0 commit comments

Comments
 (0)