mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 07:14:23 +00:00
Fix compilation with GCC 4.9
This commit is contained in:
parent
784c34e052
commit
dd336120b2
@ -21,7 +21,7 @@ struct RealmState {
|
||||
|
||||
realm::Table& table;
|
||||
realm::LinkViewRef lv;
|
||||
int64_t uid = 0;
|
||||
int64_t uid;
|
||||
std::vector<int64_t> modified;
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,8 @@ static void verify(CollectionChangeIndices const& changes, std::vector<int64_t>
|
||||
// Apply the changes from the transaction log to our copy of the
|
||||
// initial, using UITableView's batching rules (i.e. delete, then
|
||||
// insert, then update)
|
||||
auto it = std::make_reverse_iterator(changes.deletions.end()), end = std::make_reverse_iterator(changes.deletions.begin());
|
||||
auto it = util::make_reverse_iterator(changes.deletions.end());
|
||||
auto end = util::make_reverse_iterator(changes.deletions.begin());
|
||||
for (; it != end; ++it) {
|
||||
values.erase(values.begin() + it->first, values.begin() + it->second);
|
||||
}
|
||||
@ -207,7 +208,7 @@ int main(int argc, char** argv) {
|
||||
config.in_memory = true;
|
||||
config.automatic_change_notifications = false;
|
||||
|
||||
Schema schema = {
|
||||
Schema schema{
|
||||
{"object", "", {
|
||||
{"id", PropertyTypeInt},
|
||||
{"value", PropertyTypeInt}
|
||||
|
@ -601,8 +601,8 @@ CollectionChangeBuilder CollectionChangeBuilder::calculate(std::vector<size_t> c
|
||||
#ifdef REALM_DEBUG
|
||||
{ // Verify that applying the calculated change to prev_rows actually produces next_rows
|
||||
auto rows = prev_rows;
|
||||
auto it = std::make_reverse_iterator(ret.deletions.end());
|
||||
auto end = std::make_reverse_iterator(ret.deletions.begin());
|
||||
auto it = util::make_reverse_iterator(ret.deletions.end());
|
||||
auto end = util::make_reverse_iterator(ret.deletions.begin());
|
||||
for (; it != end; ++it) {
|
||||
rows.erase(rows.begin() + it->first, rows.begin() + it->second);
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include <realm/util/assert.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace realm;
|
||||
|
||||
const size_t IndexSet::npos;
|
||||
@ -138,7 +140,7 @@ void IndexSet::add_shifted_by(IndexSet const& shifted_by, IndexSet const& values
|
||||
copy(old_it, old_end, back_inserter(m_ranges));
|
||||
}
|
||||
|
||||
REALM_ASSERT_DEBUG(std::distance(as_indexes().begin(), as_indexes().end()) == expected);
|
||||
REALM_ASSERT_DEBUG((size_t)std::distance(as_indexes().begin(), as_indexes().end()) == expected);
|
||||
}
|
||||
|
||||
void IndexSet::set(size_t len)
|
||||
|
@ -155,6 +155,16 @@ private:
|
||||
// Add an index which must be greater than the largest index in the set
|
||||
void add_back(size_t index);
|
||||
};
|
||||
|
||||
namespace util {
|
||||
// This was added in C++14 but is missing from libstdc++ 4.9
|
||||
template<typename Iterator>
|
||||
std::reverse_iterator<Iterator> make_reverse_iterator(Iterator it)
|
||||
{
|
||||
return std::reverse_iterator<Iterator>(it);
|
||||
}
|
||||
} // namespace util
|
||||
|
||||
} // namespace realm
|
||||
|
||||
#endif // REALM_INDEX_SET_HPP
|
||||
|
@ -52,6 +52,20 @@ namespace realm {
|
||||
|| type == PropertyTypeDate
|
||||
|| type == PropertyTypeString;
|
||||
}
|
||||
|
||||
#if __GNUC__ < 5
|
||||
// GCC 4.9 does not support C++14 braced-init with NSDMIs
|
||||
Property(std::string name="", PropertyType type=PropertyTypeInt, std::string object_type="",
|
||||
bool is_primary=false, bool is_indexed=false, bool is_nullable=false)
|
||||
: name(std::move(name))
|
||||
, type(type)
|
||||
, object_type(std::move(object_type))
|
||||
, is_primary(is_primary)
|
||||
, is_indexed(is_indexed)
|
||||
, is_nullable(is_nullable)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline const char *string_for_property_type(PropertyType type) {
|
||||
@ -76,6 +90,10 @@ namespace realm {
|
||||
return "object";
|
||||
case PropertyTypeArray:
|
||||
return "array";
|
||||
#if __GNUC__
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ util::Optional<Mixed> Results::aggregate(size_t column, bool return_none_for_emp
|
||||
return none;
|
||||
return util::Optional<Mixed>(getter(*m_table));
|
||||
case Mode::LinkView:
|
||||
m_query = get_query();
|
||||
m_query = this->get_query();
|
||||
m_mode = Mode::Query;
|
||||
REALM_FALLTHROUGH;
|
||||
case Mode::Query:
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "util/index_helpers.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
using namespace realm;
|
||||
|
||||
TEST_CASE("[collection_change] insert()") {
|
||||
@ -230,10 +232,10 @@ TEST_CASE("[collection_change] clear()") {
|
||||
|
||||
SECTION("sets deletions SIZE_T_MAX if that if the given previous size") {
|
||||
c.insertions = {1, 2, 3};
|
||||
c.clear(SIZE_T_MAX);
|
||||
c.clear(std::numeric_limits<size_t>::max());
|
||||
REQUIRE(c.deletions.size() == 1);
|
||||
REQUIRE(c.deletions.begin()->first == 0);
|
||||
REQUIRE(c.deletions.begin()->second == SIZE_T_MAX);
|
||||
REQUIRE(c.deletions.begin()->second == std::numeric_limits<size_t>::max());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,8 @@ private:
|
||||
// Apply the changes from the transaction log to our copy of the
|
||||
// initial, using UITableView's batching rules (i.e. delete, then
|
||||
// insert, then update)
|
||||
auto it = std::make_reverse_iterator(info.deletions.end()), end = std::make_reverse_iterator(info.deletions.begin());
|
||||
auto it = util::make_reverse_iterator(info.deletions.end());
|
||||
auto end = util::make_reverse_iterator(info.deletions.begin());
|
||||
for (; it != end; ++it) {
|
||||
m_initial.erase(m_initial.begin() + it->first, m_initial.begin() + it->second);
|
||||
}
|
||||
@ -92,7 +93,7 @@ private:
|
||||
|
||||
// and make sure we end up with the same end result
|
||||
REQUIRE(m_initial.size() == m_linkview->size());
|
||||
for (auto i = 0; i < m_initial.size(); ++i)
|
||||
for (size_t i = 0; i < m_initial.size(); ++i)
|
||||
CHECK(m_initial[i] == m_linkview->get(i).get_int(0));
|
||||
|
||||
// Verify that everything marked as a move actually is one
|
||||
|
@ -4,7 +4,7 @@
|
||||
auto actual = index_set.as_indexes(); \
|
||||
INFO("Checking " #index_set); \
|
||||
REQUIRE(expected.size() == std::distance(actual.begin(), actual.end())); \
|
||||
auto begin = actual.begin(), end = actual.end(); \
|
||||
auto begin = actual.begin(); \
|
||||
for (auto index : expected) { \
|
||||
REQUIRE(*begin++ == index); \
|
||||
} \
|
||||
@ -14,7 +14,7 @@
|
||||
auto actual = (c); \
|
||||
std::initializer_list<CollectionChangeIndices::Move> expected = {__VA_ARGS__}; \
|
||||
REQUIRE(expected.size() == actual.moves.size()); \
|
||||
auto begin = actual.moves.begin(), end = actual.moves.end(); \
|
||||
auto begin = actual.moves.begin(); \
|
||||
for (auto move : expected) { \
|
||||
CHECK(begin->from == move.from); \
|
||||
CHECK(begin->to == move.to); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user