remove FunctionComparator
This commit is contained in:
parent
eb1d870993
commit
583affbef7
|
@ -98,7 +98,6 @@
|
|||
02414B9F1CE6AAEF00A8669F /* results_notifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = results_notifier.cpp; path = src/impl/results_notifier.cpp; sourceTree = "<group>"; };
|
||||
02414BA01CE6AAEF00A8669F /* results_notifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = results_notifier.hpp; path = src/impl/results_notifier.hpp; sourceTree = "<group>"; };
|
||||
025678951CAB392000FB8501 /* jsc_types.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsc_types.hpp; sourceTree = "<group>"; };
|
||||
026D72111CF8B23C00EF1DCC /* jsc_notification_map.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsc_notification_map.hpp; sourceTree = "<group>"; };
|
||||
0270BC5A1B7CFC1300010E03 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
0270BC781B7D020100010E03 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ios/Info.plist; sourceTree = "<group>"; };
|
||||
0270BC7A1B7D020100010E03 /* RealmJSTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmJSTests.h; path = ios/RealmJSTests.h; sourceTree = "<group>"; };
|
||||
|
@ -508,7 +507,6 @@
|
|||
F60103081CC4B4F900EC01BA /* jsc_protected.hpp */,
|
||||
F60103141CC4CC8C00EC01BA /* jsc_return_value.hpp */,
|
||||
F60102E71CBBB36500EC01BA /* jsc_object_accessor.hpp */,
|
||||
026D72111CF8B23C00EF1DCC /* jsc_notification_map.hpp */,
|
||||
);
|
||||
name = JSC;
|
||||
path = jsc;
|
||||
|
|
|
@ -38,7 +38,7 @@ class List : public realm::List {
|
|||
List(std::shared_ptr<Realm> r, const ObjectSchema& s, LinkViewRef l) noexcept : realm::List(r, s, l) {}
|
||||
List(const realm::List &l) : realm::List(l) {}
|
||||
|
||||
std::map<typename FunctionComparator<T>::ComparableFunction, NotificationToken, FunctionComparator<T>> m_notification_tokens;
|
||||
std::map<Protected<typename T::Function>, NotificationToken, Protected<typename T::Function>> m_notification_tokens;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace js {
|
|||
template<typename T>
|
||||
class Results : public realm::Results {
|
||||
public:
|
||||
Results(Results const&) : realm::Results(*this) {};
|
||||
Results(Results const& r) : realm::Results(r) {};
|
||||
Results(Results&&) = default;
|
||||
Results& operator=(Results&&) = default;
|
||||
Results& operator=(Results const&) = default;
|
||||
|
@ -43,7 +43,7 @@ class Results : public realm::Results {
|
|||
Results(SharedRealm r, const ObjectSchema& o, TableView tv, SortOrder s) : realm::Results(r, o, tv, s) {}
|
||||
Results(SharedRealm r, const ObjectSchema& o, LinkViewRef lv, util::Optional<Query> q = {}, SortOrder s = {}) : realm::Results(r, o, lv, q, s) {}
|
||||
|
||||
std::map<typename FunctionComparator<T>::ComparableFunction, NotificationToken, FunctionComparator<T>> m_notification_tokens;
|
||||
std::map<Protected<typename T::Function>, NotificationToken, Protected<typename T::Function>> m_notification_tokens;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -282,7 +282,7 @@ void ResultsClass<T>::add_listener(ContextType ctx, ObjectType this_object, size
|
|||
arguments[1] = CollectionClass<T>::create_collection_change_set(protected_ctx, change_set);
|
||||
Function<T>::call(protected_ctx, protected_callback, protected_this, 2, arguments);
|
||||
});
|
||||
results->m_notification_tokens.emplace(std::make_pair(protected_ctx, protected_callback), std::move(token));
|
||||
results->m_notification_tokens.emplace(protected_callback, std::move(token));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -247,6 +247,7 @@ class Protected {
|
|||
bool operator!=(const ValueType &) const;
|
||||
bool operator==(const Protected<ValueType> &) const;
|
||||
bool operator!=(const Protected<ValueType> &) const;
|
||||
bool operator()(const Protected<ValueType>& a, const Protected<ValueType>& b) const;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -289,12 +290,6 @@ struct ReturnValue {
|
|||
void set_undefined();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct FunctionComparator {
|
||||
using ComparableFunction = std::pair<Protected<typename T::GlobalContext>, Protected<typename T::Function>>;
|
||||
bool operator()(const ComparableFunction& a, const ComparableFunction& b) const;
|
||||
};
|
||||
|
||||
template<typename T, typename ClassType>
|
||||
REALM_JS_INLINE typename T::Object create_object(typename T::Context ctx, typename ClassType::Internal* internal = nullptr) {
|
||||
return Object<T>::template create_instance<ClassType>(ctx, internal);
|
||||
|
|
|
@ -28,6 +28,5 @@
|
|||
#include "jsc_exception.hpp"
|
||||
#include "jsc_return_value.hpp"
|
||||
#include "jsc_object_accessor.hpp"
|
||||
#include "jsc_notification_map.hpp"
|
||||
|
||||
#include "js_realm.hpp"
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "jsc_types.hpp"
|
||||
|
||||
namespace realm {
|
||||
namespace js {
|
||||
|
||||
template<>
|
||||
bool FunctionComparator<jsc::Types>::operator()(const ComparableFunction& a, const ComparableFunction& b) const {
|
||||
if ((JSGlobalContextRef)a.first != (JSGlobalContextRef)b.first) {
|
||||
return false;
|
||||
}
|
||||
return JSValueIsStrictEqual(a.first, a.second, b.second);
|
||||
}
|
||||
|
||||
}}
|
|
@ -47,6 +47,10 @@ class Protected<JSGlobalContextRef> {
|
|||
operator bool() const {
|
||||
return m_context != nullptr;
|
||||
}
|
||||
|
||||
bool operator() (const Protected<JSGlobalContextRef>& a, const Protected<JSGlobalContextRef>& b) const {
|
||||
return a.m_context == b.m_context;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -75,6 +79,12 @@ class Protected<JSValueRef> {
|
|||
operator bool() const {
|
||||
return m_value != nullptr;
|
||||
}
|
||||
bool operator() (const Protected<JSValueRef>& a, const Protected<JSValueRef>& b) const {
|
||||
if (a.m_context != b.m_context) {
|
||||
return false;
|
||||
}
|
||||
return JSValueIsStrictEqual(a.m_context, a.m_value, b.m_value);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Reference in New Issue