• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / 2084

01 Mar 2024 10:58AM UTC coverage: 90.927% (+0.003%) from 90.924%
2084

push

Evergreen

web-flow
[bindgen] Enable support for collections in the `Mixed` data type (#7392)

* Adapt to breaking change.

* Expose APIs for flat collections in Mixed and add preparation for nested.

* Add and expose helper for getting the data type.

* Expose a data type enum that includes non-primitives.

The JS SDK needs this for checking types of Mixed.

* Update casting of enum constants.

* Replace access of 'm_type' with use of the 'int()' operator overload.

* Expose APIs for setting nested lists in Mixed.

* Expose APIs for setting nested dictionaries in Mixed.

* Expose APIs for getting nested lists in Mixed.

* Expose APIs for getting nested dictionaries in Mixed.

* Expose get_obj() on List and Set.

* Expose method for getting element type in List.

* Remove the need for element type helpers.

The JS SDK has managed to use sentinel values in the generated bindings instead.

* Remove unused header.

93968 of 173134 branches covered (54.27%)

238435 of 262226 relevant lines covered (90.93%)

5859224.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.0
/src/realm/link_translator.cpp
1
/*************************************************************************
2
 *
3
 * Copyright 2022 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#include "realm/link_translator.hpp"
20

21
#include <realm/dictionary.hpp>
22
#include <realm/list.hpp>
23
#include <realm/set.hpp>
24

25
namespace realm {
26

27
LinkTranslator::LinkTranslator(Obj origin, ColKey origin_col_key)
28
    : m_origin_obj(origin)
29
    , m_origin_col_key(origin_col_key)
30
{
101,655✔
31
}
101,655✔
32

33
void LinkTranslator::run()
34
{
101,655✔
35
    ColumnAttrMask attr = m_origin_col_key.get_attrs();
101,655✔
36
    if (attr.test(col_attr_List)) {
101,655✔
37
        if (m_origin_col_key.get_type() == col_type_Link) {
30,510✔
38
            LnkLst link_list = m_origin_obj.get_linklist(m_origin_col_key);
29,922✔
39
            on_list_of_links(link_list);
29,922✔
40
        }
29,922✔
41
        else if (m_origin_col_key.get_type() == col_type_Mixed) {
588✔
42
            Lst<Mixed> list = m_origin_obj.get_list<Mixed>(m_origin_col_key);
588✔
43
            on_list_of_mixed(list);
588✔
44
        }
588✔
45
        else {
×
46
            throw std::runtime_error(
×
47
                util::format("LinkTranslator unhandled list type: %1", m_origin_col_key.get_type()));
×
48
        }
×
49
    }
71,145✔
50
    else if (attr.test(col_attr_Set)) {
71,145✔
51
        if (m_origin_col_key.get_type() == col_type_Link) {
2,850✔
52
            LnkSet set = m_origin_obj.get_linkset(m_origin_col_key);
2,400✔
53
            on_set_of_links(set);
2,400✔
54
        }
2,400✔
55
        else if (m_origin_col_key.get_type() == col_type_Mixed) {
450✔
56
            Set<Mixed> set = m_origin_obj.get_set<Mixed>(m_origin_col_key);
450✔
57
            on_set_of_mixed(set);
450✔
58
        }
450✔
59
        else {
×
60
            throw std::runtime_error(
×
61
                util::format("LinkTranslator unhandled set type: %1", m_origin_col_key.get_type()));
×
62
        }
×
63
    }
68,295✔
64
    else if (attr.test(col_attr_Dictionary)) {
68,295✔
65
        auto dict = m_origin_obj.get_dictionary(m_origin_col_key);
1,038✔
66
        on_dictionary(dict);
1,038✔
67
    }
1,038✔
68
    else {
67,257✔
69
        REALM_ASSERT_EX(!m_origin_col_key.is_collection(), m_origin_col_key);
67,257✔
70
        if (m_origin_col_key.get_type() == col_type_Link) {
67,257✔
71
            on_link_property(m_origin_col_key);
67,173✔
72
        }
67,173✔
73
        else if (m_origin_col_key.get_type() == col_type_Mixed) {
84✔
74
            on_mixed_property(m_origin_col_key);
84✔
75
        }
84✔
76
        else {
×
77
            throw std::runtime_error(
×
78
                util::format("LinkTranslator unhandled property type: %1", m_origin_col_key.get_type()));
×
79
        }
×
80
    }
67,257✔
81
}
101,655✔
82

83
} // namespace realm
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc