Skip to content

Commit ccb90ae

Browse files
committed
Update C lib to 0.18.1
1 parent e5c976d commit ccb90ae

File tree

10 files changed

+854
-101
lines changed

10 files changed

+854
-101
lines changed

build/ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd "${script_dir}/.." # move to project root dir
77

88
args="$@"
99

10-
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/main/download.sh) --quiet --sync 0.15.1
10+
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-c/main/download.sh) --quiet --sync 0.18.1
1111
export CGO_LDFLAGS="-L$(pwd -P)/lib -Wl,-rpath -Wl,$(pwd -P)/lib"
1212

1313
if [[ "$(uname)" == MINGW* ]]; then

install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ $ErrorActionPreference = "Stop"
77
# Configure supported HTTPS protocols
88
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls
99

10-
$libVersion = '0.15.1'
10+
$libVersion = '0.18.1'
1111
$libVariant = 'objectbox' # or 'objectbox-sync'
1212
$downloadDir = 'download'
1313
$extractedLibDir = "$downloadDir\objectbox-$libVersion"

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
cLibVersion=0.15.1
4+
cLibVersion=0.18.1
55
os=$(uname)
66
cLibArgs="$*"
77

objectbox/c-callbacks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ var cCallbackMutex sync.Mutex
123123
var cCallbackMap = make(map[cCallbackId]cCallable)
124124

125125
// The result is actually not a memory pointer, just a number. That's also how it's used in cCallbackLookup().
126-
func (cbId cCallbackId) cPtrArg() C.uintptr_t {
127-
return C.uintptr_t(cbId)
126+
func (cbId cCallbackId) cPtr() unsafe.Pointer {
127+
return unsafe.Pointer(uintptr(cbId))
128128
}
129129

130130
// Returns the next cCallbackId in a sequence (NOT checking its availability), skipping zero.

objectbox/objectbox-sync.h

Lines changed: 299 additions & 17 deletions
Large diffs are not rendered by default.

objectbox/objectbox.h

Lines changed: 523 additions & 52 deletions
Large diffs are not rendered by default.

objectbox/sync-client.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ type SyncLoginFailure uint64 // TODO enumerate possible values
266266
// SetConnectionListener sets or overrides a previously set listener for a "connection" event.
267267
func (client *SyncClient) SetConnectionListener(callback syncConnectionListener) error {
268268
if callback == nil {
269-
C.obx_sync_listener_connect(client.cClient, nil, 0)
269+
C.obx_sync_listener_connect(client.cClient, nil, nil)
270270
cCallbackUnregister(client.cCallbacks[cCallbackIndexConnection])
271271
} else {
272272
if cbId, err := cCallbackRegister(cVoidCallback(func() {
273273
callback()
274274
})); err != nil {
275275
return err
276276
} else {
277-
C.obx_sync_listener_connect(client.cClient, (*C.OBX_sync_listener_connect)(cVoidCallbackDispatchPtr), cbId.cPtrArg())
277+
C.obx_sync_listener_connect(client.cClient, (*C.OBX_sync_listener_connect)(cVoidCallbackDispatchPtr), cbId.cPtr())
278278
client.swapCallbackId(cCallbackIndexConnection, cbId)
279279
}
280280
}
@@ -284,15 +284,15 @@ func (client *SyncClient) SetConnectionListener(callback syncConnectionListener)
284284
// SetDisconnectionListener sets or overrides a previously set listener for a "disconnection" event.
285285
func (client *SyncClient) SetDisconnectionListener(callback syncDisconnectionListener) error {
286286
if callback == nil {
287-
C.obx_sync_listener_disconnect(client.cClient, nil, 0)
287+
C.obx_sync_listener_disconnect(client.cClient, nil, nil)
288288
cCallbackUnregister(client.cCallbacks[cCallbackIndexDisconnection])
289289
} else {
290290
if cbId, err := cCallbackRegister(cVoidCallback(func() {
291291
callback()
292292
})); err != nil {
293293
return err
294294
} else {
295-
C.obx_sync_listener_disconnect(client.cClient, (*C.OBX_sync_listener_disconnect)(cVoidCallbackDispatchPtr), cbId.cPtrArg())
295+
C.obx_sync_listener_disconnect(client.cClient, (*C.OBX_sync_listener_disconnect)(cVoidCallbackDispatchPtr), cbId.cPtr())
296296
client.swapCallbackId(cCallbackIndexDisconnection, cbId)
297297
}
298298
}
@@ -302,15 +302,15 @@ func (client *SyncClient) SetDisconnectionListener(callback syncDisconnectionLis
302302
// SetLoginListener sets or overrides a previously set listener for a "login" event.
303303
func (client *SyncClient) SetLoginListener(callback syncLoginListener) error {
304304
if callback == nil {
305-
C.obx_sync_listener_login(client.cClient, nil, 0)
305+
C.obx_sync_listener_login(client.cClient, nil, nil)
306306
cCallbackUnregister(client.cCallbacks[cCallbackIndexLogin])
307307
} else {
308308
if cbId, err := cCallbackRegister(cVoidCallback(func() {
309309
callback()
310310
})); err != nil {
311311
return err
312312
} else {
313-
C.obx_sync_listener_login(client.cClient, (*C.OBX_sync_listener_login)(cVoidCallbackDispatchPtr), cbId.cPtrArg())
313+
C.obx_sync_listener_login(client.cClient, (*C.OBX_sync_listener_login)(cVoidCallbackDispatchPtr), cbId.cPtr())
314314
client.swapCallbackId(cCallbackIndexLogin, cbId)
315315
}
316316
}
@@ -320,15 +320,15 @@ func (client *SyncClient) SetLoginListener(callback syncLoginListener) error {
320320
// SetLoginFailureListener sets or overrides a previously set listener for a "login" event.
321321
func (client *SyncClient) SetLoginFailureListener(callback syncLoginFailureListener) error {
322322
if callback == nil {
323-
C.obx_sync_listener_login_failure(client.cClient, nil, 0)
323+
C.obx_sync_listener_login_failure(client.cClient, nil, nil)
324324
cCallbackUnregister(client.cCallbacks[cCallbackIndexLoginFailure])
325325
} else {
326326
if cbId, err := cCallbackRegister(cVoidUint64Callback(func(code uint64) {
327327
callback(SyncLoginFailure(code))
328328
})); err != nil {
329329
return err
330330
} else {
331-
C.obx_sync_listener_login_failure(client.cClient, (*C.OBX_sync_listener_login_failure)(cVoidUint64CallbackDispatchPtr), cbId.cPtrArg())
331+
C.obx_sync_listener_login_failure(client.cClient, (*C.OBX_sync_listener_login_failure)(cVoidUint64CallbackDispatchPtr), cbId.cPtr())
332332
client.swapCallbackId(cCallbackIndexLoginFailure, cbId)
333333
}
334334
}
@@ -338,15 +338,15 @@ func (client *SyncClient) SetLoginFailureListener(callback syncLoginFailureListe
338338
// SetCompletionListener sets or overrides a previously set listener for a "login" event.
339339
func (client *SyncClient) SetCompletionListener(callback syncCompletionListener) error {
340340
if callback == nil {
341-
C.obx_sync_listener_complete(client.cClient, nil, 0)
341+
C.obx_sync_listener_complete(client.cClient, nil, nil)
342342
cCallbackUnregister(client.cCallbacks[cCallbackIndexCompletion])
343343
} else {
344344
if cbId, err := cCallbackRegister(cVoidCallback(func() {
345345
callback()
346346
})); err != nil {
347347
return err
348348
} else {
349-
C.obx_sync_listener_complete(client.cClient, (*C.OBX_sync_listener_complete)(cVoidCallbackDispatchPtr), cbId.cPtrArg())
349+
C.obx_sync_listener_complete(client.cClient, (*C.OBX_sync_listener_complete)(cVoidCallbackDispatchPtr), cbId.cPtr())
350350
client.swapCallbackId(cCallbackIndexCompletion, cbId)
351351
}
352352
}
@@ -356,7 +356,7 @@ func (client *SyncClient) SetCompletionListener(callback syncCompletionListener)
356356
// SetServerTimeListener sets or overrides a previously set listener for a "login" event.
357357
func (client *SyncClient) SetServerTimeListener(callback syncTimeListener) error {
358358
if callback == nil {
359-
C.obx_sync_listener_server_time(client.cClient, nil, 0)
359+
C.obx_sync_listener_server_time(client.cClient, nil, nil)
360360
cCallbackUnregister(client.cCallbacks[cCallbackIndexServerTime])
361361
} else {
362362
if cbId, err := cCallbackRegister(cVoidInt64Callback(func(timestampNs int64) {
@@ -365,7 +365,7 @@ func (client *SyncClient) SetServerTimeListener(callback syncTimeListener) error
365365
})); err != nil {
366366
return err
367367
} else {
368-
C.obx_sync_listener_server_time(client.cClient, (*C.OBX_sync_listener_server_time)(cVoidInt64CallbackDispatchPtr), cbId.cPtrArg())
368+
C.obx_sync_listener_server_time(client.cClient, (*C.OBX_sync_listener_server_time)(cVoidInt64CallbackDispatchPtr), cbId.cPtr())
369369
client.swapCallbackId(cCallbackIndexServerTime, cbId)
370370
}
371371
}
@@ -376,15 +376,15 @@ func (client *SyncClient) SetServerTimeListener(callback syncTimeListener) error
376376
// SyncChange event is issued after a transaction is applied to the local database.
377377
func (client *SyncClient) SetChangeListener(callback syncChangeListener) error {
378378
if callback == nil {
379-
C.obx_sync_listener_change(client.cClient, nil, 0)
379+
C.obx_sync_listener_change(client.cClient, nil, nil)
380380
cCallbackUnregister(client.cCallbacks[cCallbackIndexChange])
381381
} else {
382382
if cbId, err := cCallbackRegister(cVoidConstVoidCallback(func(cChangeList unsafe.Pointer) {
383383
callback(cSyncChangeArrayToGo((*C.OBX_sync_change_array)(cChangeList)))
384384
})); err != nil {
385385
return err
386386
} else {
387-
C.obx_sync_listener_change(client.cClient, (*C.OBX_sync_listener_change)(cVoidConstVoidCallbackDispatchPtr), cbId.cPtrArg())
387+
C.obx_sync_listener_change(client.cClient, (*C.OBX_sync_listener_change)(cVoidConstVoidCallbackDispatchPtr), cbId.cPtr())
388388
client.swapCallbackId(cCallbackIndexChange, cbId)
389389
}
390390
}

objectbox/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ func VersionLibStatic() Version {
7272

7373
// VersionLibMin returns the minimum Version of the dynamic linked ObjectBox library that is compatible with this Go version
7474
func VersionLibMin() Version {
75-
return Version{0, 15, 0, ""}
75+
return Version{0, 18, 0, ""}
7676
}
7777

7878
// VersionLibMinRecommended returns the minimum recommended Version of the dynamic linked ObjectBox library.
7979
// This version not only considers compatibility with this Go version, but also known issues older (compatible) versions.
8080
// It is guaranteed to be at least VersionLibMin()
8181
func VersionLibMinRecommended() Version {
82-
return Version{0, 15, 1, ""}
82+
return Version{0, 18, 1, ""}
8383
}
8484

8585
// VersionInfo returns a printable version string

test/query_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ func TestQueries(t *testing.T) {
229229
{1, s{`Float32 between -1.000000 and 1.000000`}, box.Query(E.Float32.Between(-1, 1)), nil},
230230
{2, s{`Float32 between 47.740002 and 95.480003`}, box.Query(E.Float32.Between(e.Float32, e.Float32*2)), nil},
231231

232-
{6, s{`ByteVector == byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.Equals(e.ByteVector)), nil},
233-
// {994, s{`ByteVector != byte[5]{0x01020305 08`}, box.Query(E.ByteVector.NotEquals(e.ByteVector)), nil},
234-
{989, s{`ByteVector > byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.GreaterThan(e.ByteVector)), nil},
235-
{995, s{`ByteVector >= byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.GreaterOrEqual(e.ByteVector)), nil},
236-
{5, s{`ByteVector < byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.LessThan(e.ByteVector)), nil},
237-
{11, s{`ByteVector <= byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.LessOrEqual(e.ByteVector)), nil},
232+
{6, s{`ByteVector == byte[5]{0x0102030508}`}, box.Query(E.ByteVector.Equals(e.ByteVector)), nil},
233+
// {994, s{`ByteVector != byte[5]{0x0102030508`}, box.Query(E.ByteVector.NotEquals(e.ByteVector)), nil},
234+
{989, s{`ByteVector > byte[5]{0x0102030508}`}, box.Query(E.ByteVector.GreaterThan(e.ByteVector)), nil},
235+
{995, s{`ByteVector >= byte[5]{0x0102030508}`}, box.Query(E.ByteVector.GreaterOrEqual(e.ByteVector)), nil},
236+
{5, s{`ByteVector < byte[5]{0x0102030508}`}, box.Query(E.ByteVector.LessThan(e.ByteVector)), nil},
237+
{11, s{`ByteVector <= byte[5]{0x0102030508}`}, box.Query(E.ByteVector.LessOrEqual(e.ByteVector)), nil},
238238

239239
{256, s{`Bool == 1`}, box.Query(E.Bool.Equals(true)), nil},
240240
{744, s{`Bool == 0`}, box.Query(E.Bool.Equals(false)), nil},
@@ -384,11 +384,11 @@ func TestQueryParams(t *testing.T) {
384384
{498, s{`Float32 > 47.740002`}, box.Query(E.Float32.GreaterThan(e.Float32)),
385385
func(q i) error { return eq(q).SetFloat64Params(E.Float32, float64(e.Float32)) }},
386386

387-
{6, s{`ByteVector == byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.Equals(nil)),
387+
{6, s{`ByteVector == byte[5]{0x0102030508}`}, box.Query(E.ByteVector.Equals(nil)),
388388
func(q i) error { return eq(q).SetBytesParams(E.ByteVector, e.ByteVector) }},
389389
{1000, s{`ByteVector > byte[0]""`}, box.Query(E.ByteVector.GreaterThan(nil)),
390390
func(q i) error { return eq(q).SetBytesParams(E.ByteVector, nil) }},
391-
{5, s{`ByteVector < byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.LessThan(nil)),
391+
{5, s{`ByteVector < byte[5]{0x0102030508}`}, box.Query(E.ByteVector.LessThan(nil)),
392392
func(q i) error { return eq(q).SetBytesParams(E.ByteVector, e.ByteVector) }},
393393

394394
{1, s{`Related == 1`}, box.Query(E.Related.Equals(0)),
@@ -566,11 +566,11 @@ func TestQueryAliasParams(t *testing.T) {
566566
{498, s{`Float32 > 47.740002`}, box.Query(E.Float32.GreaterThan(e.Float32).As(alias)),
567567
func(q i) error { return eq(q).SetFloat64Params(alias, float64(e.Float32)) }},
568568

569-
{6, s{`ByteVector == byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.Equals(nil).As(alias)),
569+
{6, s{`ByteVector == byte[5]{0x0102030508}`}, box.Query(E.ByteVector.Equals(nil).As(alias)),
570570
func(q i) error { return eq(q).SetBytesParams(alias, e.ByteVector) }},
571571
{1000, s{`ByteVector > byte[0]""`}, box.Query(E.ByteVector.GreaterThan(nil).As(alias)),
572572
func(q i) error { return eq(q).SetBytesParams(alias, nil) }},
573-
{5, s{`ByteVector < byte[5]{0x01020305 08}`}, box.Query(E.ByteVector.LessThan(nil).As(alias)),
573+
{5, s{`ByteVector < byte[5]{0x0102030508}`}, box.Query(E.ByteVector.LessThan(nil).As(alias)),
574574
func(q i) error { return eq(q).SetBytesParams(alias, e.ByteVector) }},
575575
})
576576
}

test/version_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestExpectedObjectBoxVersion(t *testing.T) {
5555

5656
versionLib := objectbox.VersionLib()
5757
versionLibInt := versionLib.Major*10000 + versionLib.Minor*100 + versionLib.Patch
58-
assert.True(t, versionLibInt >= 1501) // Update with new releases (won't fail if forgotten)
58+
assert.True(t, versionLibInt >= 1801) // Update with new releases (won't fail if forgotten)
5959
assert.True(t, versionLibInt < 10000) // Future next major release
6060
}
6161

0 commit comments

Comments
 (0)