Skip to content

Commit

Permalink
Merge pull request #3718 from realm/mar/update-object-store
Browse files Browse the repository at this point in the history
Pull in some object store changes
  • Loading branch information
bdash committed Jun 8, 2016
2 parents c3855dd + b81362f commit 4ab337f
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 87 deletions.
3 changes: 2 additions & 1 deletion Realm.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Pod::Spec.new do |s|
source_files = 'Realm/*.{m,mm}',
'Realm/ObjectStore/*.cpp',
'Realm/ObjectStore/impl/*.cpp',
'Realm/ObjectStore/impl/apple/*.cpp'
'Realm/ObjectStore/impl/apple/*.cpp',
'Realm/ObjectStore/util/*.cpp'

s.module_map = 'Realm/module.modulemap'
s.compiler_flags = "-DREALM_HAVE_CONFIG -DREALM_COCOA_VERSION='@\"#{s.version}\"' -D__ASSERTMACROS__"
Expand Down
22 changes: 22 additions & 0 deletions Realm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@
5D66102A1BE98DD00021E04F /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; };
5D66102E1BE98E500021E04F /* Realm.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5D659ED91BE04556006515A0 /* Realm.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5D66102F1BE98E540021E04F /* RealmSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5D660FCC1BE98C560021E04F /* RealmSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
5DB591A91D063DF8001D8F93 /* atomic_shared_ptr.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 5DB591A61D063DF8001D8F93 /* atomic_shared_ptr.hpp */; };
5DB591AA1D063DF8001D8F93 /* format.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DB591A71D063DF8001D8F93 /* format.cpp */; };
5DB591AB1D063DF8001D8F93 /* format.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 5DB591A81D063DF8001D8F93 /* format.hpp */; };
5DB591AC1D0775D2001D8F93 /* format.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5DB591A71D063DF8001D8F93 /* format.cpp */; };
5DD7557F1BE056DE002800DA /* external_commit_helper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F2118A81B97CBE1005A4CFE /* external_commit_helper.cpp */; };
5DD755801BE056DE002800DA /* index_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FBD05FA1B94E1C3004559CF /* index_set.cpp */; };
5DD755811BE056DE002800DA /* object_schema.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FAE25561B8CEBBE00D01405 /* object_schema.cpp */; };
Expand Down Expand Up @@ -614,6 +618,9 @@
5D6610121BE98D880021E04F /* TestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestCase.swift; sourceTree = "<group>"; };
5D6610131BE98D880021E04F /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUtils.h; sourceTree = "<group>"; };
5D6610141BE98D880021E04F /* TestUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestUtils.mm; sourceTree = "<group>"; };
5DB591A61D063DF8001D8F93 /* atomic_shared_ptr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = atomic_shared_ptr.hpp; path = ObjectStore/util/atomic_shared_ptr.hpp; sourceTree = "<group>"; };
5DB591A71D063DF8001D8F93 /* format.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = format.cpp; path = ObjectStore/util/format.cpp; sourceTree = "<group>"; };
5DB591A81D063DF8001D8F93 /* format.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = format.hpp; path = ObjectStore/util/format.hpp; sourceTree = "<group>"; };
5DD755CF1BE056DE002800DA /* Realm.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework.static; includeInIndex = 0; path = Realm.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5DD755E01BE05C19002800DA /* Tests.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Tests.xcconfig; sourceTree = "<group>"; };
5DD755E31BE05EA1002800DA /* Tests iOS static.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Tests iOS static.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -740,6 +747,7 @@
02D9AFB61B22487E00A1BD87 /* ObjectStore */ = {
isa = PBXGroup;
children = (
5DB591A51D063DE5001D8F93 /* util */,
3FF0B0A31BA861F200E74157 /* impl */,
3F62BA9E1BA0AB9000A4CEB2 /* binding_context.hpp */,
3F9801A91C8E4F6B000A8B07 /* collection_notifications.cpp */,
Expand Down Expand Up @@ -902,6 +910,16 @@
name = "Supporting Files";
sourceTree = "<group>";
};
5DB591A51D063DE5001D8F93 /* util */ = {
isa = PBXGroup;
children = (
5DB591A61D063DF8001D8F93 /* atomic_shared_ptr.hpp */,
5DB591A71D063DF8001D8F93 /* format.cpp */,
5DB591A81D063DF8001D8F93 /* format.hpp */,
);
name = util;
sourceTree = "<group>";
};
E81A1FC81955FE0100FDED82 /* Swift */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1139,6 +1157,7 @@
3F0543EB1C56F71500AA5322 /* realm_coordinator.hpp in Headers */,
3F75566C1BE94CCC0058BC7E /* results.hpp in Headers */,
3F9801AF1C90FD2D000A8B07 /* results_notifier.hpp in Headers */,
5DB591A91D063DF8001D8F93 /* atomic_shared_ptr.hpp in Headers */,
5D659EA71BE04556006515A0 /* RLMAccessor.h in Headers */,
5D659EA81BE04556006515A0 /* RLMAnalytics.hpp in Headers */,
5D659EA91BE04556006515A0 /* RLMArray.h in Headers */,
Expand Down Expand Up @@ -1181,6 +1200,7 @@
5D659ECC1BE04556006515A0 /* schema.hpp in Headers */,
5D659ECD1BE04556006515A0 /* shared_realm.hpp in Headers */,
3F9801A31C8E4F55000A8B07 /* weak_realm_notifier.hpp in Headers */,
5DB591AB1D063DF8001D8F93 /* format.hpp in Headers */,
3F9801971C8E4F3F000A8B07 /* weak_realm_notifier.hpp in Headers */,
3F9801A21C8E4F55000A8B07 /* weak_realm_notifier_base.hpp in Headers */,
);
Expand Down Expand Up @@ -1740,6 +1760,7 @@
5D659E861BE04556006515A0 /* RLMAnalytics.mm in Sources */,
5D659E871BE04556006515A0 /* RLMArray.mm in Sources */,
5D659E881BE04556006515A0 /* RLMArrayLinkView.mm in Sources */,
5DB591AA1D063DF8001D8F93 /* format.cpp in Sources */,
3FBEF67B1C63D66100F6935B /* RLMCollection.mm in Sources */,
5D659E891BE04556006515A0 /* RLMConstants.m in Sources */,
5D659E8A1BE04556006515A0 /* RLMListBase.mm in Sources */,
Expand Down Expand Up @@ -1839,6 +1860,7 @@
5DD755841BE056DE002800DA /* RLMAnalytics.mm in Sources */,
5DD755851BE056DE002800DA /* RLMArray.mm in Sources */,
5DD755861BE056DE002800DA /* RLMArrayLinkView.mm in Sources */,
5DB591AC1D0775D2001D8F93 /* format.cpp in Sources */,
3FBEF67C1C63D66400F6935B /* RLMCollection.mm in Sources */,
5DD755871BE056DE002800DA /* RLMConstants.m in Sources */,
5DD755881BE056DE002800DA /* RLMListBase.mm in Sources */,
Expand Down
8 changes: 5 additions & 3 deletions Realm/ObjectStore/impl/collection_change_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include <realm/util/assert.hpp>

#include <algorithm>

using namespace realm;
using namespace realm::_impl;

Expand Down Expand Up @@ -49,7 +51,7 @@ void CollectionChangeBuilder::merge(CollectionChangeBuilder&& c)

// First update any old moves
if (!c.moves.empty() || !c.deletions.empty() || !c.insertions.empty()) {
auto it = remove_if(begin(moves), end(moves), [&](auto& old) {
auto it = std::remove_if(begin(moves), end(moves), [&](auto& old) {
// Check if the moved row was moved again, and if so just update the destination
auto it = find_if(begin(c.moves), end(c.moves), [&](auto const& m) {
return old.to == m.from;
Expand Down Expand Up @@ -79,7 +81,7 @@ void CollectionChangeBuilder::merge(CollectionChangeBuilder&& c)
// Ignore new moves of rows which were previously inserted (the implicit
// delete from the move will remove the insert)
if (!insertions.empty() && !c.moves.empty()) {
c.moves.erase(remove_if(begin(c.moves), end(c.moves),
c.moves.erase(std::remove_if(begin(c.moves), end(c.moves),
[&](auto const& m) { return insertions.contains(m.from); }),
end(c.moves));
}
Expand Down Expand Up @@ -124,7 +126,7 @@ void CollectionChangeBuilder::clean_up_stale_moves()
// Look for moves which are now no-ops, and remove them plus the associated
// insert+delete. Note that this isn't just checking for from == to due to
// that rows can also be shifted by other inserts and deletes
moves.erase(remove_if(begin(moves), end(moves), [&](auto const& move) {
moves.erase(std::remove_if(begin(moves), end(moves), [&](auto const& move) {
if (move.from - deletions.count(0, move.from) != move.to - insertions.count(0, move.to))
return false;
deletions.remove(move.from);
Expand Down
5 changes: 5 additions & 0 deletions Realm/ObjectStore/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "impl/realm_coordinator.hpp"
#include "results.hpp"
#include "shared_realm.hpp"
#include "util/format.hpp"

#include <realm/link_view.hpp>

Expand Down Expand Up @@ -201,3 +202,7 @@ NotificationToken List::add_notification_callback(CollectionChangeCallback cb)
}
return {m_notifier, m_notifier->add_callback(std::move(cb))};
}

List::OutOfBoundsIndexException::OutOfBoundsIndexException(size_t r, size_t c)
: std::out_of_range(util::format("Requested index %1 greater than max %2", r, c))
, requested(r), valid_count(c) {}
10 changes: 5 additions & 5 deletions Realm/ObjectStore/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ class List {
// The List object has been invalidated (due to the Realm being invalidated,
// or the containing object being deleted)
// All non-noexcept functions can throw this
struct InvalidatedException {};
struct InvalidatedException : public std::runtime_error {
InvalidatedException() : std::runtime_error("Access to invalidated List object") {}
};

// The input index parameter was out of bounds
struct OutOfBoundsIndexException {
struct OutOfBoundsIndexException : public std::out_of_range {
OutOfBoundsIndexException(size_t r, size_t c);
size_t requested;
size_t valid_count;
};

// The input Row object is not attached
struct DetatchedAccessorException { };

private:
std::shared_ptr<Realm> m_realm;
LinkViewRef m_link_view;
Expand Down
Loading

0 comments on commit 4ab337f

Please sign in to comment.