Unverified Commit 33718654 authored by Zach Knox's avatar Zach Knox
Browse files

Pods update

parent 6dab2e31
PODS:
- Crashlytics (3.10.1):
- Fabric (~> 1.7.5)
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- DeckTransition (2.0.0)
- Fabric (1.7.6)
- ObjectMapper (3.1.0)
- ObjectMapper+Realm (0.5):
- Fabric (1.7.7)
- ObjectMapper (3.2.0)
- ObjectMapper+Realm (0.6):
- ObjectMapper
- RealmSwift
- Realm (3.3.2):
- Realm/Headers (= 3.3.2)
- Realm/Headers (3.3.2)
- RealmSwift (3.3.2):
- Realm (= 3.3.2)
- Realm (3.6.0):
- Realm/Headers (= 3.6.0)
- Realm/Headers (3.6.0)
- RealmSwift (3.6.0):
- Realm (= 3.6.0)
DEPENDENCIES:
- Crashlytics
......@@ -22,13 +22,13 @@ DEPENDENCIES:
- RealmSwift
SPEC CHECKSUMS:
Crashlytics: aee1a064cbbf99b32efa3f056a5f458d846bc8ff
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
DeckTransition: 2300694f94fbeca2c103f365dc9dc09ffae14a4f
Fabric: f8d42c893bb187326a7968b62abe55c36a987a46
ObjectMapper: 20505058f54e5c3ca69e1d6de9897d152a5369a6
ObjectMapper+Realm: 3188789fb77c189c7a83cb625333a607eb61a08f
Realm: d927fbf66df5532cfafc08afb5f7e53ded37b894
RealmSwift: 4e903a494e05d866581d69ad6f7e7b879d446baf
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
ObjectMapper+Realm: 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 08b464b462d4f31bbd4ba5f5a1c8722ef0a700b7
RealmSwift: 973e1499c44ab571f894c2c908e2db450be280c3
PODFILE CHECKSUM: 1225e83da50847e17730900da3b05d9d69748392
......
PODS:
- Crashlytics (3.10.1):
- Fabric (~> 1.7.5)
- Crashlytics (3.10.2):
- Fabric (~> 1.7.7)
- DeckTransition (2.0.0)
- Fabric (1.7.6)
- ObjectMapper (3.1.0)
- ObjectMapper+Realm (0.5):
- Fabric (1.7.7)
- ObjectMapper (3.2.0)
- ObjectMapper+Realm (0.6):
- ObjectMapper
- RealmSwift
- Realm (3.3.2):
- Realm/Headers (= 3.3.2)
- Realm/Headers (3.3.2)
- RealmSwift (3.3.2):
- Realm (= 3.3.2)
- Realm (3.6.0):
- Realm/Headers (= 3.6.0)
- Realm/Headers (3.6.0)
- RealmSwift (3.6.0):
- Realm (= 3.6.0)
DEPENDENCIES:
- Crashlytics
......@@ -22,13 +22,13 @@ DEPENDENCIES:
- RealmSwift
SPEC CHECKSUMS:
Crashlytics: aee1a064cbbf99b32efa3f056a5f458d846bc8ff
Crashlytics: 0360624eea1c978a743feddb2fb1ef8b37fb7a0d
DeckTransition: 2300694f94fbeca2c103f365dc9dc09ffae14a4f
Fabric: f8d42c893bb187326a7968b62abe55c36a987a46
ObjectMapper: 20505058f54e5c3ca69e1d6de9897d152a5369a6
ObjectMapper+Realm: 3188789fb77c189c7a83cb625333a607eb61a08f
Realm: d927fbf66df5532cfafc08afb5f7e53ded37b894
RealmSwift: 4e903a494e05d866581d69ad6f7e7b879d446baf
Fabric: bda89e242bce1b7b8ab264248cf3407774ce0095
ObjectMapper: 5cccd2de6f253eda859df8116a5a554d9769e859
ObjectMapper+Realm: 4cf44ed3202a73f08594e21e13eb3f8aa9b5a664
Realm: 08b464b462d4f31bbd4ba5f5a1c8722ef0a700b7
RealmSwift: 973e1499c44ab571f894c2c908e2db450be280c3
PODFILE CHECKSUM: 1225e83da50847e17730900da3b05d9d69748392
......
# ObjectMapper+Realm
[![Platform](https://img.shields.io/cocoapods/p/ObjectMapper+Realm.svg?style=flat)](http://cocoapods.org/pods/ObjectMapper+Realm)
[![Version](https://img.shields.io/cocoapods/v/ObjectMapper+Realm.svg?style=flat)](http://cocoapods.org/pods/ObjectMapper+Realm)
[![Build Status](https://travis-ci.org/Jakenberg/ObjectMapper-Realm.svg?branch=master)](https://travis-ci.org/Jakenberg/ObjectMapper-Realm)
[![codecov](https://codecov.io/gh/Jakenberg/ObjectMapper-Realm/branch/master/graph/badge.svg)](https://codecov.io/gh/Jakenberg/ObjectMapper-Realm)
[![License](https://img.shields.io/cocoapods/l/ObjectMapper+Realm.svg?style=flat)](http://cocoapods.org/pods/ObjectMapper+Realm)
![Build Status](https://circleci.com/gh/Jakenberg/ObjectMapper-Realm.svg?style=shield)
![codecov](https://codecov.io/gh/Jakenberg/ObjectMapper-Realm/branch/master/graph/badge.svg)
[![Platform](https://img.shields.io/cocoapods/p/ObjectMapper+Realm.svg?style=flat)](http://cocoapods.org/pods/ObjectMapper+Realm)
[![License](https://img.shields.io/cocoapods/l/ObjectMapper+Realm.svg?style=flat)](https://github.com/Jakenberg/ObjectMapper-Realm/blob/master/LICENSE)
## Installation
## Installation [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
ObjectMapper+Realm is available through [CocoaPods](http://cocoapods.org). To install
ObjectMapper+Realm is available through [CocoaPods](http://cocoapods.org/pods/ObjectMapper+Realm). To install
it, simply add the following line to your Podfile:
```ruby
......
......@@ -62,52 +62,54 @@ public final class Map {
/// The Key paramater can be a period separated string (ex. "distance.value") to access sub objects.
public subscript(key: String) -> Map {
// save key and value associated to it
return self[key, delimiter: ".", ignoreNil: false]
return self.subscript(key: key)
}
public subscript(key: String, delimiter delimiter: String) -> Map {
let nested = key.contains(delimiter)
return self[key, nested: nested, delimiter: delimiter, ignoreNil: false]
return self.subscript(key: key, delimiter: delimiter)
}
public subscript(key: String, nested nested: Bool) -> Map {
return self[key, nested: nested, delimiter: ".", ignoreNil: false]
return self.subscript(key: key, nested: nested)
}
public subscript(key: String, nested nested: Bool, delimiter delimiter: String) -> Map {
return self[key, nested: nested, delimiter: delimiter, ignoreNil: false]
return self.subscript(key: key, nested: nested, delimiter: delimiter)
}
public subscript(key: String, ignoreNil ignoreNil: Bool) -> Map {
return self[key, delimiter: ".", ignoreNil: ignoreNil]
return self.subscript(key: key, ignoreNil: ignoreNil)
}
public subscript(key: String, delimiter delimiter: String, ignoreNil ignoreNil: Bool) -> Map {
let nested = key.contains(delimiter)
return self[key, nested: nested, delimiter: delimiter, ignoreNil: ignoreNil]
return self.subscript(key: key, delimiter: delimiter, ignoreNil: ignoreNil)
}
public subscript(key: String, nested nested: Bool, ignoreNil ignoreNil: Bool) -> Map {
return self[key, nested: nested, delimiter: ".", ignoreNil: ignoreNil]
return self.subscript(key: key, nested: nested, ignoreNil: ignoreNil)
}
public subscript(key: String, nested nested: Bool, delimiter delimiter: String, ignoreNil ignoreNil: Bool) -> Map {
public subscript(key: String, nested nested: Bool?, delimiter delimiter: String, ignoreNil ignoreNil: Bool) -> Map {
return self.subscript(key: key, nested: nested, delimiter: delimiter, ignoreNil: ignoreNil)
}
private func `subscript`(key: String, nested: Bool? = nil, delimiter: String = ".", ignoreNil: Bool = false) -> Map {
// save key and value associated to it
currentKey = key
keyIsNested = nested
keyIsNested = nested ?? key.contains(delimiter)
nestedKeyDelimiter = delimiter
if mappingType == .fromJSON {
// check if a value exists for the current key
// do this pre-check for performance reasons
if nested == false {
if keyIsNested {
// break down the components of the key that are separated by delimiter
(isKeyPresent, currentValue) = valueFor(ArraySlice(key.components(separatedBy: delimiter)), dictionary: JSON)
} else {
let object = JSON[key]
let isNSNull = object is NSNull
isKeyPresent = isNSNull ? true : object != nil
currentValue = isNSNull ? nil : object
} else {
// break down the components of the key that are separated by .
(isKeyPresent, currentValue) = valueFor(ArraySlice(key.components(separatedBy: delimiter)), dictionary: JSON)
}
// update isKeyPresent if ignoreNil is true
......@@ -120,9 +122,24 @@ public final class Map {
}
public func value<T>() -> T? {
return currentValue as? T
let value = currentValue as? T
// Swift 4.1 breaks Float casting from `NSNumber`. So Added extra checks for `Flaot` `[Float]` and `[String:Float]`
if value == nil && T.self == Float.self {
if let v = currentValue as? NSNumber {
return v.floatValue as? T
}
} else if value == nil && T.self == [Float].self {
if let v = currentValue as? [Double] {
return v.flatMap{ Float($0) } as? T
}
} else if value == nil && T.self == [String:Float].self {
if let v = currentValue as? [String:Double] {
return v.mapValues{ Float($0) } as? T
}
}
return value
}
}
/// Fetch value from JSON dictionary, loop through keyPathComponents until we reach the desired object
......@@ -133,9 +150,10 @@ private func valueFor(_ keyPathComponents: ArraySlice<String>, dictionary: [Stri
}
if let keyPath = keyPathComponents.first {
let isTail = keyPathComponents.count == 1
let object = dictionary[keyPath]
if object is NSNull {
return (true, nil)
return (isTail, nil)
} else if keyPathComponents.count > 1, let dict = object as? [String: Any] {
let tail = keyPathComponents.dropFirst()
return valueFor(tail, dictionary: dict)
......@@ -143,7 +161,7 @@ private func valueFor(_ keyPathComponents: ArraySlice<String>, dictionary: [Stri
let tail = keyPathComponents.dropFirst()
return valueFor(tail, array: array)
} else {
return (object != nil, object)
return (isTail && object != nil, object)
}
}
......@@ -162,10 +180,11 @@ private func valueFor(_ keyPathComponents: ArraySlice<String>, array: [Any]) ->
if let keyPath = keyPathComponents.first,
let index = Int(keyPath) , index >= 0 && index < array.count {
let isTail = keyPathComponents.count == 1
let object = array[index]
if object is NSNull {
return (true, nil)
return (isTail, nil)
} else if keyPathComponents.count > 1, let array = object as? [Any] {
let tail = keyPathComponents.dropFirst()
return valueFor(tail, array: array)
......@@ -173,7 +192,7 @@ private func valueFor(_ keyPathComponents: ArraySlice<String>, array: [Any]) ->
let tail = keyPathComponents.dropFirst()
return valueFor(tail, dictionary: dict)
} else {
return (true, object)
return (isTail, object)
}
}
......
......@@ -98,7 +98,7 @@ internal final class ToJSON {
if let field = field {
basicType(field, map: map)
} else if map.shouldIncludeNilValues {
basicType(NSNull(), map: map) //If BasicType is nil, emil NSNull into the JSON output
basicType(NSNull(), map: map) //If BasicType is nil, emit NSNull into the JSON output
}
}
......@@ -111,6 +111,8 @@ internal final class ToJSON {
class func optionalObject<N: BaseMappable>(_ field: N?, map: Map) {
if let field = field {
object(field, map: map)
} else if map.shouldIncludeNilValues {
basicType(NSNull(), map: map) //If field is nil, emit NSNull into the JSON output
}
}
......
......@@ -961,6 +961,7 @@ T Realm::resolve_thread_safe_reference(ThreadSafeReference<T> reference)
if (reference_version < current_version) {
// Duplicate config for uncached Realm so we don't advance the user's Realm
Realm::Config config = m_coordinator->get_config();
config.automatic_change_notifications = false;
config.cache = false;
config.schema = util::none;
SharedRealm temporary_realm = m_coordinator->get_realm(config);
......
......@@ -157,6 +157,23 @@ SyncMetadataManager::SyncMetadataManager(std::string path,
};
m_metadata_config = std::move(config);
m_client_uuid = [&]() -> std::string {
TableRef table = ObjectStore::table_for_object_type(realm->read_group(), c_sync_clientMetadata);
if (table->is_empty()) {
realm->begin_transaction();
if (table->is_empty()) {
size_t idx = table->add_empty_row();
REALM_ASSERT_DEBUG(idx == 0);
auto uuid = uuid_string();
table->set_string(m_client_schema.idx_uuid, idx, uuid);
realm->commit_transaction();
return uuid;
}
realm->cancel_transaction();
}
return table->get_string(m_client_schema.idx_uuid, 0);
}();
}
SyncUserMetadataResults SyncMetadataManager::all_unmarked_users() const
......@@ -309,26 +326,6 @@ util::Optional<SyncFileActionMetadata> SyncMetadataManager::get_file_action_meta
return SyncFileActionMetadata(std::move(schema), std::move(realm), table->get(row_idx));
}
std::string SyncMetadataManager::client_uuid() const
{
auto realm = Realm::get_shared_realm(m_metadata_config);
TableRef table = ObjectStore::table_for_object_type(realm->read_group(), c_sync_clientMetadata);
if (table->is_empty()) {
realm->begin_transaction();
if (table->is_empty()) {
size_t idx = table->add_empty_row();
REALM_ASSERT_DEBUG(idx == 0);
auto uuid = uuid_string();
table->set_string(m_client_schema.idx_uuid, idx, uuid);
realm->commit_transaction();
return uuid;
}
realm->cancel_transaction();
}
return table->get_string(m_client_schema.idx_uuid, 0);
}
// MARK: - Sync user metadata
SyncUserMetadata::SyncUserMetadata(Schema schema, SharedRealm realm, RowExpr row)
......
......@@ -364,13 +364,14 @@ struct sync_session_states::Dying : public SyncSession::State {
struct sync_session_states::Inactive : public SyncSession::State {
void enter_state(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
{
// Inform any queued-up completion handlers that they were cancelled.
for (auto& package : session.m_completion_wait_packages) {
package.callback(util::error::operation_aborted);
}
auto completion_wait_packages = std::move(session.m_completion_wait_packages);
session.m_completion_wait_packages.clear();
session.m_session = nullptr;
session.unregister(lock);
session.unregister(lock); // releases lock
// Inform any queued-up completion handlers that they were cancelled.
for (auto& package : completion_wait_packages)
package.callback(util::error::operation_aborted);
}
bool revive_if_needed(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
......@@ -519,7 +520,7 @@ void SyncSession::handle_error(SyncError error)
{
std::unique_lock<std::mutex> lock(m_state_mutex);
user_to_invalidate = user();
cancel_pending_waits();
cancel_pending_waits(lock);
}
if (user_to_invalidate)
user_to_invalidate->invalidate();
......@@ -584,7 +585,7 @@ void SyncSession::handle_error(SyncError error)
}
case NextStateAfterError::error: {
std::unique_lock<std::mutex> lock(m_state_mutex);
cancel_pending_waits();
cancel_pending_waits(lock);
break;
}
}
......@@ -593,13 +594,15 @@ void SyncSession::handle_error(SyncError error)
}
}
void SyncSession::cancel_pending_waits()
void SyncSession::cancel_pending_waits(std::unique_lock<std::mutex>& lock)
{
auto packages = std::move(m_completion_wait_packages);
lock.unlock();
// Inform any queued-up completion handlers that they were cancelled.
for (auto& package : m_completion_wait_packages) {
for (auto& package : packages) {
package.callback(util::error::operation_aborted);
}
m_completion_wait_packages.clear();
}
void SyncSession::handle_progress_update(uint64_t downloaded, uint64_t downloadable,
......@@ -621,6 +624,16 @@ void SyncSession::create_sync_session()
session_config.ssl_trust_certificate_path = m_config.ssl_trust_certificate_path;
session_config.ssl_verify_callback = m_config.ssl_verify_callback;
session_config.multiplex_ident = m_multiplex_identity;
if (m_config.authorization_header_name) {
session_config.authorization_header_name = *m_config.authorization_header_name;
}
session_config.custom_http_headers = m_config.custom_http_headers;
if (m_config.url_prefix) {
session_config.url_prefix = *m_config.url_prefix;
}
m_session = m_client.make_session(m_realm_path, std::move(session_config));
// The next time we get a token, call `bind()` instead of `refresh()`.
......
......@@ -625,7 +625,7 @@ id RLMAccessorContext::propertyValue(__unsafe_unretained id const obj, size_t pr
return static_cast<RLMListBase *>(object_getIvar(obj, prop.swiftIvar))._rlmArray;
}
else { // optional
value = static_cast<RLMOptionalBase *>(object_getIvar(obj, prop.swiftIvar)).underlyingValue;
value = RLMGetOptional(static_cast<RLMOptionalBase *>(object_getIvar(obj, prop.swiftIvar)));
}
}
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment