realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Upgrade to HEAD of Realm Core's master #6637

Closed kneth closed 2 weeks ago

kneth commented 3 weeks ago

What, How & Why?

Next core release will come with a number of breaking changes. This PR is a preparation for the release, and it requires https://github.com/realm/realm-core/pull/7623 to be merged and release.

The Binding Generator has some limitations, and in conjunction with https://github.com/realm/realm-core/pull/7623 this PR works around them.

In https://github.com/realm/realm-core/pull/7300, a new user is introduced (app::User) which inherit from SyncUser. As both classes are used with std::shared_ptr (annotated SharedPtrWrapper in spec.xml), it is not possible to generate code. The ~solution~ hack is to downcast all objects. In most cases the downcasting has no effect but for the user classes. For user classes we will use only one - app::User - and downcast SyncUser to app::User.

ā˜‘ļø ToDos

kneth commented 3 weeks ago

We didn't test the performance of this, right? I mean - its a pretty critical code path.

I have changed it so we don't downcast but I hope that a C++ compiler will generate very little code for

Foo *foo = new Foo();
auto bar = std::dynamic_pointer_cast<Foo>(foo);