File: nan_define_own_property_helper.h

package info (click to toggle)
node-nan 2.14.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,396 kB
  • sloc: cpp: 7,564; python: 3,408; ansic: 1,548; javascript: 1,535; makefile: 114; sh: 34
file content (29 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*********************************************************************
 * NAN - Native Abstractions for Node.js
 *
 * Copyright (c) 2018 NAN contributors
 *
 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
 ********************************************************************/

#ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
#define NAN_DEFINE_OWN_PROPERTY_HELPER_H_

namespace imp {

inline Maybe<bool> DefineOwnPropertyHelper(
    v8::PropertyAttribute current
  , v8::Handle<v8::Object> obj
  , v8::Handle<v8::String> key
  , v8::Handle<v8::Value> value
  , v8::PropertyAttribute attribs = v8::None) {
  return !(current & v8::DontDelete) ||                     // configurable OR
                  (!(current & v8::ReadOnly) &&             // writable AND
                   !((attribs ^ current) & ~v8::ReadOnly))  // same excluding RO
             ? Just<bool>(obj->ForceSet(key, value, attribs))
             : Nothing<bool>();
}

}  // end of namespace imp

#endif  // NAN_DEFINE_OWN_PROPERTY_HELPER_H_