negate if statements
This commit is contained in:
parent
cd20d870dd
commit
2b48ebb30a
|
@ -122,15 +122,17 @@ struct NativeAccessor {
|
||||||
}
|
}
|
||||||
static size_t to_existing_object_index(ContextType ctx, SharedRealm realm, ValueType &value) {
|
static size_t to_existing_object_index(ContextType ctx, SharedRealm realm, ValueType &value) {
|
||||||
ObjectType object = Value::validated_to_object(ctx, value);
|
ObjectType object = Value::validated_to_object(ctx, value);
|
||||||
if (Object::template is_instance<RealmObjectClass<T>>(ctx, object)) {
|
if (!Object::template is_instance<RealmObjectClass<T>>(ctx, object)) {
|
||||||
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
|
||||||
if (realm_object->realm() == realm) {
|
|
||||||
return realm_object->row().get_index();
|
|
||||||
}
|
|
||||||
throw std::runtime_error("Realm object is from another Realm");
|
|
||||||
}
|
|
||||||
throw std::runtime_error("object is not a Realm Object");
|
throw std::runtime_error("object is not a Realm Object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto realm_object = get_internal<T, RealmObjectClass<T>>(object);
|
||||||
|
if (realm_object->realm() != realm) {
|
||||||
|
throw std::runtime_error("Realm object is from another Realm");
|
||||||
|
|
||||||
|
}
|
||||||
|
return realm_object->row().get_index();
|
||||||
|
}
|
||||||
static ValueType from_object(ContextType ctx, realm::Object realm_object) {
|
static ValueType from_object(ContextType ctx, realm::Object realm_object) {
|
||||||
return RealmObjectClass<T>::create_instance(ctx, std::move(realm_object));
|
return RealmObjectClass<T>::create_instance(ctx, std::move(realm_object));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue