コード例 #1
0
void RealmCache::cache_realm(SharedRealm &realm, std::thread::id thread_id)
{
    std::lock_guard<std::mutex> lock(m_mutex);

    auto path_iter = m_cache.find(realm->config().path);
    if (path_iter == m_cache.end()) {
        m_cache.emplace(realm->config().path, std::map<std::thread::id, WeakRealm>{{thread_id, realm}});
    }
    else {
        path_iter->second.emplace(thread_id, realm);
    }
}
コード例 #2
0
ファイル: js_object.cpp プロジェクト: Aneeskhan/realm-js
template<> size_t RJSAccessor::to_object_index(JSContextRef ctx, SharedRealm realm, JSValueRef &val, const std::string &type, bool try_update) {
    JSObjectRef object = RJSValidatedValueToObject(ctx, val);
    if (JSValueIsObjectOfClass(ctx, val, RJSObjectClass())) {
        return RJSGetInternal<Object *>(object)->row().get_index();
    }

    auto object_schema = realm->config().schema->find(type);
    if (RJSIsValueArray(ctx, object)) {
        object = RJSDictForPropertyArray(ctx, *object_schema, object);
    }

    Object child = Object::create<JSValueRef>(ctx, realm, *object_schema, (JSValueRef)object, try_update);
    return child.row().get_index();
}
コード例 #3
0
    static size_t to_object_index(ContextType ctx, SharedRealm realm, ValueType &value, const std::string &type, bool try_update) {
        ObjectType object = Value::validated_to_object(ctx, value);
        if (Object::template is_instance<RealmObjectClass<T>>(ctx, object)) {
            return get_internal<T, RealmObjectClass<T>>(object)->row().get_index();
        }

        auto object_schema = realm->config().schema->find(type);
        if (Value::is_array(ctx, object)) {
            object = Schema<T>::dict_for_property_array(ctx, *object_schema, object);
        }

        auto child = realm::Object::create<ValueType>(ctx, realm, *object_schema, static_cast<ValueType>(object), try_update);
        return child.row().get_index();
    }