mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-10 14:25:58 +00:00
move comparator to separate class
This commit is contained in:
parent
583affbef7
commit
1e662f86e2
@ -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<Protected<typename T::Function>, NotificationToken, Protected<typename T::Function>> m_notification_tokens;
|
||||
std::map<Protected<typename T::Function>, NotificationToken, typename Protected<typename T::Function>::Comparator> m_notification_tokens;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -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<Protected<typename T::Function>, NotificationToken, Protected<typename T::Function>> m_notification_tokens;
|
||||
std::map<Protected<typename T::Function>, NotificationToken, typename Protected<typename T::Function>::Comparator> m_notification_tokens;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -247,9 +247,12 @@ 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;
|
||||
|
||||
struct Comparator {
|
||||
bool operator()(const Protected<ValueType>& a, const Protected<ValueType>& b) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct Exception : public std::runtime_error {
|
||||
using ContextType = typename T::Context;
|
||||
|
@ -48,9 +48,11 @@ class Protected<JSGlobalContextRef> {
|
||||
return m_context != nullptr;
|
||||
}
|
||||
|
||||
bool operator() (const Protected<JSGlobalContextRef>& a, const Protected<JSGlobalContextRef>& b) const {
|
||||
return a.m_context == b.m_context;
|
||||
}
|
||||
struct Comparator {
|
||||
bool operator() (const Protected<JSGlobalContextRef>& a, const Protected<JSGlobalContextRef>& b) const {
|
||||
return a.m_context == b.m_context;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
@ -79,12 +81,15 @@ 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;
|
||||
|
||||
struct Comparator {
|
||||
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);
|
||||
}
|
||||
return JSValueIsStrictEqual(a.m_context, a.m_value, b.m_value);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
|
Loading…
x
Reference in New Issue
Block a user