Skip to content

Commit

Permalink
Bump to core 13.20.1 & prepare 0.3.0 release (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
leemaguire authored Sep 15, 2023
1 parent 650a7fd commit 1a3e097
Show file tree
Hide file tree
Showing 23 changed files with 511 additions and 105 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
x.y.z Release notes (yyyy-MM-dd)
0.3.0 Release notes (2023-09-15)
=============================================================

### Fixed
Expand Down Expand Up @@ -27,12 +27,16 @@ x.y.z Release notes (yyyy-MM-dd)
### Breaking Changes
* `managed<>::value()` has been renamed to `managed<>::detach()` to better convey that the returned value will be unmanaged. In the case where the value is a
pointer type it is up to the consumer of the value to manage the lifetime of the object.
* `sync_session::wait_for_upload_completion` & `sync_session::wait_for_download_completion` now returns a `realm::status` in its callback instead of a `std::error_code`.
* `is_connection_level_protocol_error`, `is_session_level_protocol_error` & `is_client_error` has been removed from `realm::sync_error` and is replaced by
`realm::sync_error::user_info()`, `realm::sync_error::compensating_writes_info()`, & `realm::sync_error::get_status()`.
* Data ingest Realms must now specify a schema containing the Asymmetric objects and their dependencies e.g `experimental::open<experimental::AllTypesAsymmetricObject, experimental::EmbeddedFoo>(user.flexible_sync_configuration())`.

### Compatibility
* Fileformat: Generates files with format v22.

### Internals
* None
* Upgraded to Core v13.20.1

----------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/realm/realm-core.git", revision: "f1434caadda443b4ed2261b91ea4f43ab1ee2aa5")
.package(url: "https://github.com/realm/realm-core.git", revision: "1eb93c9619f6a05b5a91c2719690606016802e0b")
],
targets: [
cppSdkTarget,
Expand Down
2 changes: 1 addition & 1 deletion realm-core
Submodule realm-core updated 305 files
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ set(SOURCES
cpprealm/experimental/managed_binary.cpp
cpprealm/experimental/managed_primary_key.cpp
cpprealm/experimental/managed_decimal.cpp
cpprealm/experimental/types.cpp) # REALM_SOURCES
cpprealm/experimental/types.cpp
cpprealm/internal/bridge/status.cpp) # REALM_SOURCES

set(HEADERS
cpprealm/sdk.hpp
Expand Down Expand Up @@ -128,7 +129,8 @@ set(HEADERS
cpprealm/experimental/sdk.hpp
cpprealm/internal/bridge/decimal128.hpp
cpprealm/experimental/managed_decimal.hpp
cpprealm/persisted_decimal128.hpp) # REALM_INSTALL_HEADERS
cpprealm/persisted_decimal128.hpp
cpprealm/internal/bridge/status.hpp) # REALM_INSTALL_HEADERS

add_library(cpprealm STATIC ${SOURCES} ${HEADERS})
include(GNUInstallDirs)
Expand Down
16 changes: 8 additions & 8 deletions src/cpprealm/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,37 @@ namespace realm {
#ifdef __i386__
static_assert(internal::bridge::SizeCheck<8, sizeof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<4, alignof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<28, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<40, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<4, alignof(realm::app::AppError)>{});
#elif __x86_64__
static_assert(internal::bridge::SizeCheck<16, sizeof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppCredentials)>{});
#if defined(__clang__)
static_assert(internal::bridge::SizeCheck<48, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<72, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppError)>{});
#elif defined(__GNUC__) || defined(__GNUG__)
static_assert(internal::bridge::SizeCheck<56, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<88, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppError)>{});
#endif
#elif __arm__
static_assert(internal::bridge::SizeCheck<8, sizeof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<4, alignof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<28, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<40, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<4, alignof(realm::app::AppError)>{});
#elif __aarch64__
static_assert(internal::bridge::SizeCheck<16, sizeof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppCredentials)>{});
#if defined(__clang__)
static_assert(internal::bridge::SizeCheck<48, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<72, sizeof(realm::app::AppError)>{});
#elif defined(__GNUC__) || defined(__GNUG__)
static_assert(internal::bridge::SizeCheck<56, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<78, sizeof(realm::app::AppError)>{});
#endif
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppError)>{});
#elif _WIN32
#if _DEBUG
static_assert(internal::bridge::SizeCheck<80, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<120, sizeof(realm::app::AppError)>{});
#else
static_assert(internal::bridge::SizeCheck<72, sizeof(realm::app::AppError)>{});
static_assert(internal::bridge::SizeCheck<104, sizeof(realm::app::AppError)>{});
#endif
static_assert(internal::bridge::SizeCheck<16, sizeof(realm::app::AppCredentials)>{});
static_assert(internal::bridge::SizeCheck<8, alignof(realm::app::AppCredentials)>{});
Expand Down
10 changes: 5 additions & 5 deletions src/cpprealm/app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,21 @@ struct app_error {
[[nodiscard]] bool is_client_error() const;
private:
#ifdef __i386__
std::aligned_storage<28, 4>::type m_error[1];
std::aligned_storage<40, 4>::type m_error[1];
#elif _WIN32
#if _DEBUG
std::aligned_storage<80, 8>::type m_error[1];
std::aligned_storage<120, 8>::type m_error[1];
#else
std::aligned_storage<72, 8>::type m_error[1];
std::aligned_storage<104, 8>::type m_error[1];
#endif
#elif __x86_64__
#if defined(__clang__)
std::aligned_storage<48, 8>::type m_error[1];
#elif defined(__GNUC__) || defined(__GNUG__)
std::aligned_storage<56, 8>::type m_error[1];
std::aligned_storage<88, 8>::type m_error[1];
#endif
#elif __arm__
std::aligned_storage<28, 4>::type m_error[1];
std::aligned_storage<40, 4>::type m_error[1];
#elif __aarch64__
#if defined(__clang__)
std::aligned_storage<48, 8>::type m_error[1];
Expand Down
3 changes: 2 additions & 1 deletion src/cpprealm/experimental/db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace realm::experimental {
internal::bridge::realm m_realm;
explicit db(realm::db_config config)
{
config.set_schema(db::schemas);
if (!config.get_schema())
config.set_schema(db::schemas);
m_realm = internal::bridge::realm(config);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpprealm/internal/bridge/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace realm::internal::bridge {
new (&m_object) Object(realm, link);
}
obj object::get_obj() const {
return reinterpret_cast<const Object*>(&m_object)->obj();
return reinterpret_cast<const Object*>(&m_object)->get_obj();
}
list object::get_list(const col_key& col_key) const {
return List(get_realm(), get_obj(), col_key);
Expand Down
7 changes: 7 additions & 0 deletions src/cpprealm/internal/bridge/realm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ namespace realm::internal::bridge {
reinterpret_cast<RealmConfig*>(&m_config)->schema_mode = static_cast<::realm::SchemaMode>(mode);
}

std::optional<schema> realm::config::get_schema() {
if (auto s = reinterpret_cast<RealmConfig*>(&m_config)->schema) {
return *s;
}
return std::nullopt;
}

schema realm::schema() const {
return m_realm->schema();
}
Expand Down
1 change: 1 addition & 0 deletions src/cpprealm/internal/bridge/realm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ namespace realm::internal::bridge {
void set_sync_config(const std::optional<struct sync_config>&);
void set_custom_http_headers(const std::map<std::string, std::string>& headers);
void set_schema_version(uint64_t version);
std::optional<schema> get_schema();
private:
#ifdef __i386__
std::aligned_storage<192, 8>::type m_config[1];
Expand Down
112 changes: 112 additions & 0 deletions src/cpprealm/internal/bridge/status.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include <cpprealm/internal/bridge/utils.hpp>
#include <cpprealm/internal/bridge/status.hpp>

#include <realm/status.hpp>

namespace realm::internal::bridge {

#ifdef __i386__
static_assert(SizeCheck<4, sizeof(::realm::Status)>{});
static_assert(SizeCheck<4, alignof(::realm::Status)>{});
static_assert(SizeCheck<4, sizeof(::realm::ErrorCategory)>{});
static_assert(SizeCheck<4, alignof(::realm::ErrorCategory)>{});
#elif __arm__
static_assert(SizeCheck<4, sizeof(::realm::Status)>{});
static_assert(SizeCheck<4, alignof(::realm::Status)>{});
static_assert(SizeCheck<4, sizeof(::realm::ErrorCategory)>{});
static_assert(SizeCheck<4, alignof(::realm::ErrorCategory)>{});
#elif __x86_64__
static_assert(SizeCheck<8, sizeof(::realm::Status)>{});
static_assert(SizeCheck<8, alignof(::realm::Status)>{});
static_assert(SizeCheck<4, sizeof(::realm::ErrorCategory)>{});
static_assert(SizeCheck<4, alignof(::realm::ErrorCategory)>{});
#elif __aarch64__
static_assert(SizeCheck<8, sizeof(::realm::Status)>{});
static_assert(SizeCheck<8, alignof(::realm::Status)>{});
static_assert(SizeCheck<4, sizeof(::realm::ErrorCategory)>{});
static_assert(SizeCheck<4, alignof(::realm::ErrorCategory)>{});
#elif _WIN32
static_assert(SizeCheck<8, sizeof(::realm::Status)>{});
static_assert(SizeCheck<8, alignof(::realm::Status)>{});
static_assert(SizeCheck<4, sizeof(::realm::ErrorCategory)>{});
static_assert(SizeCheck<4, alignof(::realm::ErrorCategory)>{});
#endif

error_category::error_category() {
new (&m_error_category) ErrorCategory();
}
error_category::error_category(error_category&& other) {
new (&m_error_category) ErrorCategory(std::move(*reinterpret_cast<ErrorCategory*>(&other.m_error_category)));

}
error_category::error_category(const error_category& other) {
new (&m_error_category) ErrorCategory(*reinterpret_cast<const ErrorCategory*>(&other.m_error_category));
}
error_category& error_category::operator=(const error_category& other) {
*reinterpret_cast<ErrorCategory*>(&m_error_category) = *reinterpret_cast<const ErrorCategory*>(&other.m_error_category);
return *this;
}
error_category& error_category::operator=(error_category&& other) {
*reinterpret_cast<ErrorCategory*>(&m_error_category) = std::move(*reinterpret_cast<ErrorCategory*>(&other.m_error_category));
return *this;
}

bool error_category::test(type cat) {
return reinterpret_cast<ErrorCategory*>(&m_error_category)->test(static_cast<::realm::ErrorCategory::Type>(cat));
}
error_category& error_category::set(type cat) {
reinterpret_cast<ErrorCategory*>(&m_error_category)->set(static_cast<::realm::ErrorCategory::Type>(cat));
return *this;
}
void error_category::reset(type cat) {
reinterpret_cast<ErrorCategory*>(&m_error_category)->reset(static_cast<::realm::ErrorCategory::Type>(cat));
}
bool error_category::operator==(const error_category& other) const {
return reinterpret_cast<const ErrorCategory*>(&m_error_category) == reinterpret_cast<const ErrorCategory*>(&other.m_error_category);
}
bool error_category::operator!=(const error_category& other) const {
return reinterpret_cast<const ErrorCategory*>(&m_error_category) != reinterpret_cast<const ErrorCategory*>(&other.m_error_category);
}
int error_category::value() const {
return reinterpret_cast<const ErrorCategory*>(&m_error_category)->value();
}

status::status(const ::realm::Status& other) {
new (&m_status) Status(other);
}
status::status(::realm::Status&& other) {
new (&m_status) Status(std::move(other));
}
status::status(const status& other) {
new (&m_status) Status(*reinterpret_cast<const Status*>(&other.m_status));
}
status::status(status&& other) {
new (&m_status) Status(std::move(*reinterpret_cast<Status*>(&other.m_status)));
}
status& status::operator=(const status& other) {
*reinterpret_cast<Status*>(&m_status) = *reinterpret_cast<const Status*>(&other.m_status);
return *this;
}
status& status::operator=(status&& other) {
*reinterpret_cast<Status*>(&m_status) = std::move(*reinterpret_cast<Status*>(&other.m_status));
return *this;
}

status::~status() {
reinterpret_cast<Status*>(&m_status)->~Status();
}

inline bool status::is_ok() const noexcept {
return reinterpret_cast<const Status*>(&m_status)->is_ok();
}
inline const std::string& status::reason() const noexcept {
return reinterpret_cast<const Status*>(&m_status)->reason();
}
inline error_codes::error status::code() const noexcept {
return static_cast<error_codes::error>(reinterpret_cast<const Status*>(&m_status)->code());
}
inline std::string_view status::code_string() const noexcept {
return reinterpret_cast<const Status*>(&m_status)->code_string();
}

}
Loading

0 comments on commit 1a3e097

Please sign in to comment.