From 651449108efbc44814b66aefec8432d88920de56 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 9 May 2016 16:08:04 -0700 Subject: [PATCH] Improve usage of js::PropertyAttributes --- src/js_realm.hpp | 2 +- src/js_types.hpp | 6 +++++- src/jsc/jsc_init.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 45b6b8c3..bb0d75e5 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -237,7 +237,7 @@ inline typename T::Function Realm::create_constructor(ContextType ctx) { FunctionType results_constructor = ObjectWrap>::create_constructor(ctx); FunctionType realm_object_constructor = ObjectWrap>::create_constructor(ctx); - PropertyAttributes attributes = PropertyAttributes(ReadOnly | DontEnum | DontDelete); + PropertyAttributes attributes = ReadOnly | DontEnum | DontDelete; Object::set_property(ctx, realm_constructor, "Collection", collection_constructor, attributes); Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes); Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes); diff --git a/src/js_types.hpp b/src/js_types.hpp index 79b6486d..2b1f1fbc 100644 --- a/src/js_types.hpp +++ b/src/js_types.hpp @@ -35,13 +35,17 @@ namespace realm { namespace js { -enum PropertyAttributes { +enum PropertyAttributes : unsigned { None = 0, ReadOnly = 1 << 0, DontEnum = 1 << 1, DontDelete = 1 << 2 }; +inline PropertyAttributes operator|(PropertyAttributes a, PropertyAttributes b) { + return PropertyAttributes(static_cast(a) | static_cast(b)); +} + template struct String { using StringType = typename T::String; diff --git a/src/jsc/jsc_init.cpp b/src/jsc/jsc_init.cpp index cb78f7c7..a1ba8a9e 100644 --- a/src/jsc/jsc_init.cpp +++ b/src/jsc/jsc_init.cpp @@ -37,7 +37,7 @@ void RJSInitializeInContext(JSContextRef ctx) { JSObjectRef global_object = JSContextGetGlobalObject(ctx); JSObjectRef realm_constructor = RJSConstructorCreate(ctx); - jsc::Object::set_property(ctx, global_object, realm_string, realm_constructor, js::PropertyAttributes(js::ReadOnly | js::DontEnum | js::DontDelete)); + jsc::Object::set_property(ctx, global_object, realm_string, realm_constructor, js::ReadOnly | js::DontEnum | js::DontDelete); } } // extern "C"