installed pty
[VSoRC/.git] / node_modules / node-pty / node_modules / nan / nan_define_own_property_helper.h
1 /*********************************************************************
2  * NAN - Native Abstractions for Node.js
3  *
4  * Copyright (c) 2018 NAN contributors
5  *
6  * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7  ********************************************************************/
8
9 #ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
10 #define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
11
12 namespace imp {
13
14 inline Maybe<bool> DefineOwnPropertyHelper(
15     v8::PropertyAttribute current
16   , v8::Handle<v8::Object> obj
17   , v8::Handle<v8::String> key
18   , v8::Handle<v8::Value> value
19   , v8::PropertyAttribute attribs = v8::None) {
20   return !(current & v8::DontDelete) ||                     // configurable OR
21                   (!(current & v8::ReadOnly) &&             // writable AND
22                    !((attribs ^ current) & ~v8::ReadOnly))  // same excluding RO
23              ? Just<bool>(obj->ForceSet(key, value, attribs))
24              : Nothing<bool>();
25 }
26
27 }  // end of namespace imp
28
29 #endif  // NAN_DEFINE_OWN_PROPERTY_HELPER_H_