From 5e6f576e3174cfee615cb2a8f679af5b8a9aade3 Mon Sep 17 00:00:00 2001 From: blagoev Date: Thu, 17 Aug 2017 12:26:42 +0300 Subject: [PATCH] address code review for property type checks --- src/js_types.hpp | 32 ++++++++++++++++---------------- src/object-store | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/js_types.hpp b/src/js_types.hpp index 8f0ab806..f413d286 100644 --- a/src/js_types.hpp +++ b/src/js_types.hpp @@ -356,8 +356,23 @@ inline bool Value::is_valid_for_property(ContextType context, const ValueType return true; } + if (realm::is_array(prop.type)) { + if (prop.type == PropertyType::Object) { + auto object = to_object(context, value); + return Object::template is_instance>(context, object) + || Object::template is_instance>(context, object); + } else if (prop.type == PropertyType::LinkingObjects) { + return false; + } + else if (prop.type == PropertyType::Array) { + return true; + } + + return false; + } + using PropertyType = realm::PropertyType; - switch (prop.type) { + switch (prop.type & ~PropertyType::Flags) { case PropertyType::Int: case PropertyType::Float: case PropertyType::Double: @@ -372,22 +387,7 @@ inline bool Value::is_valid_for_property(ContextType context, const ValueType return is_date(context, value); case PropertyType::Object: return true; - case PropertyType::Array: - // FIXME: Do we need to validate the types of the contained objects? - if (is_array(context, value)) { - return true; - } - - if (is_object(context, value)) { - auto object = to_object(context, value); - return Object::template is_instance>(context, object) - || Object::template is_instance>(context, object); - } - - return false; - case PropertyType::Any: - case PropertyType::LinkingObjects: return false; } diff --git a/src/object-store b/src/object-store index 238c3ea3..7574b3a9 160000 --- a/src/object-store +++ b/src/object-store @@ -1 +1 @@ -Subproject commit 238c3ea3c63bbfac58360681e73886f3b5dd1d2b +Subproject commit 7574b3a9bcaa6259b25853e31cd4fd8dccf93b50