mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
Improve usage of js::PropertyAttributes
This commit is contained in:
parent
f66dcf943f
commit
651449108e
@ -237,7 +237,7 @@ inline typename T::Function Realm<T>::create_constructor(ContextType ctx) {
|
|||||||
FunctionType results_constructor = ObjectWrap<T, ResultsClass<T>>::create_constructor(ctx);
|
FunctionType results_constructor = ObjectWrap<T, ResultsClass<T>>::create_constructor(ctx);
|
||||||
FunctionType realm_object_constructor = ObjectWrap<T, RealmObjectClass<T>>::create_constructor(ctx);
|
FunctionType realm_object_constructor = ObjectWrap<T, RealmObjectClass<T>>::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, "Collection", collection_constructor, attributes);
|
||||||
Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes);
|
Object::set_property(ctx, realm_constructor, "List", list_constructor, attributes);
|
||||||
Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes);
|
Object::set_property(ctx, realm_constructor, "Results", results_constructor, attributes);
|
||||||
|
@ -35,13 +35,17 @@
|
|||||||
namespace realm {
|
namespace realm {
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
enum PropertyAttributes {
|
enum PropertyAttributes : unsigned {
|
||||||
None = 0,
|
None = 0,
|
||||||
ReadOnly = 1 << 0,
|
ReadOnly = 1 << 0,
|
||||||
DontEnum = 1 << 1,
|
DontEnum = 1 << 1,
|
||||||
DontDelete = 1 << 2
|
DontDelete = 1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline PropertyAttributes operator|(PropertyAttributes a, PropertyAttributes b) {
|
||||||
|
return PropertyAttributes(static_cast<unsigned>(a) | static_cast<unsigned>(b));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct String {
|
struct String {
|
||||||
using StringType = typename T::String;
|
using StringType = typename T::String;
|
||||||
|
@ -37,7 +37,7 @@ void RJSInitializeInContext(JSContextRef ctx) {
|
|||||||
JSObjectRef global_object = JSContextGetGlobalObject(ctx);
|
JSObjectRef global_object = JSContextGetGlobalObject(ctx);
|
||||||
JSObjectRef realm_constructor = RJSConstructorCreate(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"
|
} // extern "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user