Skip to content

Commit 52cff67

Browse files
Merge pull request #372 from objectbox/c-lib-0.15.0
Update C library to 0.15.2
2 parents b3ab73f + cc753b7 commit 52cff67

File tree

21 files changed

+1969
-585
lines changed

21 files changed

+1969
-585
lines changed

dev-doc/updating-c-library.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Updating the C library
2+
3+
It's important that the generated dart bindings and the c-api library version match.
4+
Dart won't error on C function signature mismatch, leading to obscure memory bugs.
5+
6+
- Update [install.sh](../install.sh).
7+
8+
## Flutter libs
9+
Update `flutter_libs` and `sync_flutter_libs` with **compatible library versions**:
10+
11+
- Linux and Windows
12+
- Shortcut: search and replace e.g. `set(OBJECTBOX_VERSION 0.15.2)` in `CMakeLists.txt`.
13+
- [flutter_libs Linux](../flutter_libs/linux/CMakeLists.txt)
14+
- [flutter_libs Windows](../flutter_libs/windows/CMakeLists.txt)
15+
- [sync_flutter_libs Linux](../sync_flutter_libs/linux/CMakeLists.txt)
16+
- [sync_flutter_libs Windows](../sync_flutter_libs/windows/CMakeLists.txt)
17+
- Android ([view releases](https://github.com/objectbox/objectbox-java/releases))
18+
- Shortcut: search and replace `-android:3.1.2` in `build.gradle` files.
19+
- In [flutter_libs](../flutter_libs/android/build.gradle)
20+
- In [sync_flutter_libs](../sync_flutter_libs/android/build.gradle)
21+
- Swift (iOS/macOS) ([view releases](https://github.com/objectbox/objectbox-swift/releases))
22+
- Shortcut: search and replace e.g. `s.dependency 'ObjectBox', '1.7.0` in `.podspec` files.
23+
- In [flutter_libs for iOS](../flutter_libs/ios/objectbox_flutter_libs.podspec)
24+
- In [flutter_libs for macOS](../flutter_libs/macos/objectbox_flutter_libs.podspec)
25+
- In [sync_flutter_libs for iOS](../sync_flutter_libs/ios/objectbox_sync_flutter_libs.podspec)
26+
- In [sync_flutter_libs for macOS](../sync_flutter_libs/macos/objectbox_sync_flutter_libs.podspec)
27+
28+
## Dart bindings
29+
Download source code of an [objectbox-c release version](https://github.com/objectbox/objectbox-c/releases).
30+
- Update [objectbox.h](../objectbox/lib/src/native/bindings/objectbox.h)
31+
- Update [objectbox-dart.h](../objectbox/lib/src/native/bindings/objectbox-dart.h)
32+
- Update [objectbox-sync.h](../objectbox/lib/src/native/bindings/objectbox-sync.h)
33+
- Replace `const void*` by `const uint8_t*` in all objectbox*.h files
34+
(see ffigen note in [pubspec.yaml](../objectbox/pubspec.yaml)).
35+
- Execute `dart run ffigen` in the `objectbox` directory. This requires LLVM libraries
36+
(see [ffigen docs](https://pub.dev/packages/ffigen#installing-llvm)
37+
and the ffigen section in [pubspec.yaml](../objectbox/pubspec.yaml)).
38+
- Copy/update enums from [objectbox_c.dart](../objectbox/lib/src/native/bindings/objectbox_c.dart)
39+
in [enums.dart](../objectbox/lib/src/modelinfo/enums.dart).
40+
- Have a look at the changed files to see if some call sites need to be updated.

flutter_libs/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ repositories {
1616

1717
dependencies {
1818
// https://search.maven.org/search?q=g:io.objectbox%20objectbox-android
19-
implementation "io.objectbox:objectbox-android:3.0.1"
19+
implementation "io.objectbox:objectbox-android:3.1.2"
2020
}

flutter_libs/ios/objectbox_flutter_libs.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414
s.source_files = 'Classes/**/*'
1515

1616
s.dependency 'Flutter'
17-
s.dependency 'ObjectBox', '1.6.0'
17+
s.dependency 'ObjectBox', '1.7.0'
1818

1919
# Flutter.framework does not contain a i386 or arm64. Only x86_64 simulators are supported.
2020
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }

flutter_libs/linux/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ set(objectbox_flutter_libs_bundled_libraries
2626

2727
# ----------------------------------------------------------------------
2828

29-
set(OBJECTBOX_VERSION 0.14.0)
29+
set(OBJECTBOX_VERSION 0.15.2)
3030

3131
set(OBJECTBOX_ARCH ${CMAKE_SYSTEM_PROCESSOR})
3232
if (${OBJECTBOX_ARCH} MATCHES "x86_64")

flutter_libs/macos/objectbox_flutter_libs.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414
s.source_files = 'Classes/**/*'
1515

1616
s.dependency 'FlutterMacOS'
17-
s.dependency 'ObjectBox', '1.6.0'
17+
s.dependency 'ObjectBox', '1.7.0'
1818

1919
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
2020
s.swift_version = '5.3'

flutter_libs/windows/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set(objectbox_flutter_libs_bundled_libraries
2525

2626
# ----------------------------------------------------------------------
2727

28-
set(OBJECTBOX_VERSION 0.14.0)
28+
set(OBJECTBOX_VERSION 0.15.2)
2929

3030
set(OBJECTBOX_ARCH ${CMAKE_SYSTEM_PROCESSOR})
3131
if (${OBJECTBOX_ARCH} MATCHES "AMD64")

install.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ set -eu
44
# https://github.com/objectbox/objectbox-c/releases
55
# It's important that the generated dart bindings and the c-api library version match. Dart won't error on C function
66
# signature mismatch, leading to obscure memory bugs.
7-
# After upgrading to a different C-API version:
8-
# * update lib/src/bindings/objectbox.h
9-
# * execute pub run ffigen
10-
# * have a look at the changed files to see if some call sites need to be updated
11-
cLibVersion=0.14.0
7+
# For how to upgrade the version see dev-doc/updating-c-library.md
8+
cLibVersion=0.15.2
129
os=$(uname)
1310
cLibArgs="$*"
1411

objectbox/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## latest
22

33
* Add an option to change code-generator's `output_dir` in `pubspec.yaml`. #341
4+
* Update: [objectbox-c 0.15.2](https://github.com/objectbox/objectbox-c/releases/tag/v0.15.0).
5+
* Update: [objectbox-android 3.1.2](https://github.com/objectbox/objectbox-java/releases/tag/V3.1.0).
6+
* Update: [objectbox-swift 1.7.0](https://github.com/objectbox/objectbox-swift/releases/tag/v1.7.0).
47

58
## 1.3.0 (2021-11-22)
69

objectbox/lib/src/modelinfo/enums.dart

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Note: the enums in this file are copied from native/bindings/objectbox-c.dart
1+
// Note: the enums in this file are copied from native/bindings/objectbox_c.dart
22
// to avoid package:ffi import which would break compatibility with web.
33

44
// ignore_for_file: public_member_api_docs, constant_identifier_names
@@ -64,103 +64,116 @@ int propertyTypeToOBXPropertyType(PropertyType type) {
6464
}
6565
}
6666

67-
/// /// Bit-flags defining the behavior of entities.
68-
/// /// Note: Numbers indicate the bit position
67+
/// Bit-flags defining the behavior of entities.
68+
/// Note: Numbers indicate the bit position
6969
abstract class OBXEntityFlags {
70-
/// /// Enable "data synchronization" for this entity type: objects will be synced with other stores over the network.
71-
/// /// It's possible to have local-only (non-synced) types and synced types in the same store (schema/data model).
70+
/// Enable "data synchronization" for this entity type: objects will be synced with other stores over the network.
71+
/// It's possible to have local-only (non-synced) types and synced types in the same store (schema/data model).
7272
static const int SYNC_ENABLED = 2;
73+
74+
/// Makes object IDs for a synced types (SYNC_ENABLED is set) global.
75+
/// By default (not using this flag), the 64 bit object IDs have a local scope and are not unique globally.
76+
/// This flag tells ObjectBox to treat object IDs globally and thus no ID mapping (local <-> global) is performed.
77+
/// Often this is used with assignable IDs (ID_SELF_ASSIGNABLE property flag is set) and some special ID scheme.
78+
/// Note: typically you won't do this with automatically assigned IDs, set by the local ObjectBox store.
79+
/// Two devices would likely overwrite each other's object during sync as object IDs are prone to collide.
80+
/// It might be OK if you can somehow ensure that only a single device will create new IDs.
81+
static const int SHARED_GLOBAL_IDS = 4;
7382
}
7483

75-
/// /// Bit-flags defining the behavior of properties.
76-
/// /// Note: Numbers indicate the bit position
84+
/// Bit-flags defining the behavior of properties.
85+
/// Note: Numbers indicate the bit position
7786
abstract class OBXPropertyFlags {
78-
/// /// 64 bit long property (internally unsigned) representing the ID of the entity.
79-
/// /// May be combined with: NON_PRIMITIVE_TYPE, ID_MONOTONIC_SEQUENCE, ID_SELF_ASSIGNABLE.
87+
/// 64 bit long property (internally unsigned) representing the ID of the entity.
88+
/// May be combined with: NON_PRIMITIVE_TYPE, ID_MONOTONIC_SEQUENCE, ID_SELF_ASSIGNABLE.
8089
static const int ID = 1;
8190

82-
/// /// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null)
91+
/// On languages like Java, a non-primitive type is used (aka wrapper types, allowing null)
8392
static const int NON_PRIMITIVE_TYPE = 2;
8493

85-
/// /// Unused yet
94+
/// Unused yet
8695
static const int NOT_NULL = 4;
8796
static const int INDEXED = 8;
8897

89-
/// /// Unused yet
98+
/// Unused yet
9099
static const int RESERVED = 16;
91100

92-
/// /// Unique index
101+
/// Unique index
93102
static const int UNIQUE = 32;
94103

95-
/// /// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse)
104+
/// Unused yet: Use a persisted sequence to enforce ID to rise monotonic (no ID reuse)
96105
static const int ID_MONOTONIC_SEQUENCE = 64;
97106

98-
/// /// Allow IDs to be assigned by the developer
107+
/// Allow IDs to be assigned by the developer
99108
static const int ID_SELF_ASSIGNABLE = 128;
100109

101-
/// /// Unused yet
110+
/// Unused yet
102111
static const int INDEX_PARTIAL_SKIP_NULL = 256;
103112

104-
/// /// Used by References for 1) back-references and 2) to clear references to deleted objects (required for ID reuse)
113+
/// Used by References for 1) back-references and 2) to clear references to deleted objects (required for ID reuse)
105114
static const int INDEX_PARTIAL_SKIP_ZERO = 512;
106115

107-
/// /// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations
116+
/// Virtual properties may not have a dedicated field in their entity class, e.g. target IDs of to-one relations
108117
static const int VIRTUAL = 1024;
109118

110-
/// /// Index uses a 32 bit hash instead of the value
111-
/// /// 32 bits is shorter on disk, runs well on 32 bit systems, and should be OK even with a few collisions
119+
/// Index uses a 32 bit hash instead of the value
120+
/// 32 bits is shorter on disk, runs well on 32 bit systems, and should be OK even with a few collisions
112121
static const int INDEX_HASH = 2048;
113122

114-
/// /// Index uses a 64 bit hash instead of the value
115-
/// /// recommended mostly for 64 bit machines with values longer >200 bytes; small values are faster with a 32 bit hash
123+
/// Index uses a 64 bit hash instead of the value
124+
/// recommended mostly for 64 bit machines with values longer >200 bytes; small values are faster with a 32 bit hash
116125
static const int INDEX_HASH64 = 4096;
117126

118-
/// /// The actual type of the variable is unsigned (used in combination with numeric OBXPropertyType_*).
119-
/// /// While our default are signed ints, queries & indexes need do know signing info.
120-
/// /// Note: Don't combine with ID (IDs are always unsigned internally).
127+
/// The actual type of the variable is unsigned (used in combination with numeric OBXPropertyType_*).
128+
/// While our default are signed ints, queries & indexes need do know signing info.
129+
/// Note: Don't combine with ID (IDs are always unsigned internally).
121130
static const int UNSIGNED = 8192;
122131

123-
/// /// By defining an ID companion property, a special ID encoding scheme is activated involving this property.
124-
/// ///
125-
/// /// For Time Series IDs, a companion property of type Date or DateNano represents the exact timestamp.
132+
/// By defining an ID companion property, a special ID encoding scheme is activated involving this property.
133+
///
134+
/// For Time Series IDs, a companion property of type Date or DateNano represents the exact timestamp.
126135
static const int ID_COMPANION = 16384;
127136

128137
/// Unique on-conflict strategy: the object being put replaces any existing conflicting object (deletes it).
129138
static const int UNIQUE_ON_CONFLICT_REPLACE = 32768;
130139
}
131140

132141
abstract class OBXPropertyType {
133-
/// ///< 1 byte
142+
/// < 1 byte
134143
static const int Bool = 1;
135144

136-
/// ///< 1 byte
145+
/// < 1 byte
137146
static const int Byte = 2;
138147

139-
/// ///< 2 bytes
148+
/// < 2 bytes
140149
static const int Short = 3;
141150

142-
/// ///< 1 byte
151+
/// < 1 byte
143152
static const int Char = 4;
144153

145-
/// ///< 4 bytes
154+
/// < 4 bytes
146155
static const int Int = 5;
147156

148-
/// ///< 8 bytes
157+
/// < 8 bytes
149158
static const int Long = 6;
150159

151-
/// ///< 4 bytes
160+
/// < 4 bytes
152161
static const int Float = 7;
153162

154-
/// ///< 8 bytes
163+
/// < 8 bytes
155164
static const int Double = 8;
156165
static const int String = 9;
157166

158-
/// ///< Unix timestamp (milliseconds since 1970) in 8 bytes
167+
/// < Unix timestamp (milliseconds since 1970) in 8 bytes
159168
static const int Date = 10;
160169
static const int Relation = 11;
161170

162-
/// ///< Unix timestamp (nanoseconds since 1970) in 8 bytes
171+
/// < Unix timestamp (nanoseconds since 1970) in 8 bytes
163172
static const int DateNano = 12;
173+
174+
/// < Flexible" type, which may contain scalars (integers, floating points), strings or
175+
/// < containers (lists and maps). Note: a flex map must use string keys.
176+
static const int Flex = 13;
164177
static const int ByteVector = 23;
165178
static const int StringVector = 30;
166179
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import 'dart:ffi';
22
import 'dart:io' show Platform;
33

44
import 'helpers.dart';
5-
import 'objectbox-c.dart';
5+
import 'objectbox_c.dart';
66

77
// let files importing bindings.dart also get all the OBX_* types
8-
export 'objectbox-c.dart';
8+
export 'objectbox_c.dart';
99

1010
// ignore_for_file: public_member_api_docs
1111
// ignore_for_file: non_constant_identifier_names

0 commit comments

Comments
 (0)