node-addon-api 1.7.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +3 -9
- package/CHANGELOG.md +154 -9
- package/README.md +58 -9
- package/benchmark/README.md +47 -0
- package/benchmark/binding.gyp +25 -0
- package/benchmark/function_args.cc +153 -0
- package/benchmark/function_args.js +52 -0
- package/benchmark/index.js +34 -0
- package/benchmark/property_descriptor.cc +60 -0
- package/benchmark/property_descriptor.js +29 -0
- package/common.gypi +21 -0
- package/doc/array_buffer.md +1 -1
- package/doc/async_context.md +10 -0
- package/doc/async_operations.md +1 -1
- package/doc/async_worker.md +56 -26
- package/doc/async_worker_variants.md +456 -0
- package/doc/basic_types.md +8 -0
- package/doc/bigint.md +2 -1
- package/doc/class_property_descriptor.md +5 -6
- package/doc/cmake-js.md +58 -9
- package/doc/creating_a_release.md +5 -5
- package/doc/date.md +68 -0
- package/doc/env.md +14 -0
- package/doc/function.md +108 -1
- package/doc/object.md +74 -1
- package/doc/object_lifetime_management.md +1 -1
- package/doc/object_wrap.md +291 -4
- package/doc/prebuild_tools.md +1 -1
- package/doc/property_descriptor.md +64 -9
- package/doc/setup.md +0 -1
- package/doc/string.md +1 -1
- package/doc/symbol.md +1 -1
- package/doc/threadsafe_function.md +18 -1
- package/doc/value.md +10 -1
- package/except.gypi +16 -0
- package/index.js +5 -42
- package/napi-inl.h +1048 -147
- package/napi.h +424 -49
- package/node_api.gyp +9 -0
- package/noexcept.gypi +16 -0
- package/{src/nothing.c → nothing.c} +0 -0
- package/package.json +244 -47
- package/tools/README.md +4 -4
- package/tools/conversion.js +0 -4
- package/external-napi/node_api.h +0 -7
- package/src/node_api.cc +0 -3655
- package/src/node_api.gyp +0 -21
- package/src/node_api.h +0 -588
- package/src/node_api_types.h +0 -115
- package/src/node_internals.cc +0 -142
- package/src/node_internals.h +0 -157
- package/src/util-inl.h +0 -38
- package/src/util.h +0 -7
package/doc/date.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Date
|
|
2
|
+
|
|
3
|
+
`Napi::Date` class is a representation of the JavaScript `Date` object. The
|
|
4
|
+
`Napi::Date` class inherits its behavior from `Napi::Value` class
|
|
5
|
+
(for more info see [`Napi::Value`](value.md))
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
### Constructor
|
|
10
|
+
|
|
11
|
+
Creates a new _empty_ instance of a `Napi::Date` object.
|
|
12
|
+
|
|
13
|
+
```cpp
|
|
14
|
+
Napi::Date::Date();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Creates a new _non-empty_ instance of a `Napi::Date` object.
|
|
18
|
+
|
|
19
|
+
```cpp
|
|
20
|
+
Napi::Date::Date(napi_env env, napi_value value);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- `[in] env`: The environment in which to construct the `Napi::Date` object.
|
|
24
|
+
- `[in] value`: The `napi_value` which is a handle for a JavaScript `Date`.
|
|
25
|
+
|
|
26
|
+
### New
|
|
27
|
+
|
|
28
|
+
Creates a new instance of a `Napi::Date` object.
|
|
29
|
+
|
|
30
|
+
```cpp
|
|
31
|
+
static Napi::Date Napi::Date::New(Napi::Env env, double value);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `[in] env`: The environment in which to construct the `Napi::Date` object.
|
|
35
|
+
- `[in] value`: The time value the JavaScript `Date` will contain represented
|
|
36
|
+
as the number of milliseconds since 1 January 1970 00:00:00 UTC.
|
|
37
|
+
|
|
38
|
+
Returns a new instance of `Napi::Date` object.
|
|
39
|
+
|
|
40
|
+
### ValueOf
|
|
41
|
+
|
|
42
|
+
```cpp
|
|
43
|
+
double Napi::Date::ValueOf() const;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Returns the time value as `double` primitive represented as the number of
|
|
47
|
+
milliseconds since 1 January 1970 00:00:00 UTC.
|
|
48
|
+
|
|
49
|
+
## Operators
|
|
50
|
+
|
|
51
|
+
### operator double
|
|
52
|
+
|
|
53
|
+
Converts a `Napi::Date` value to a `double` primitive.
|
|
54
|
+
|
|
55
|
+
```cpp
|
|
56
|
+
Napi::Date::operator double() const;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Example
|
|
60
|
+
|
|
61
|
+
The following shows an example of casting a `Napi::Date` value to a `double`
|
|
62
|
+
primitive.
|
|
63
|
+
|
|
64
|
+
```cpp
|
|
65
|
+
double operatorVal = Napi::Date::New(Env(), 0); // Napi::Date to double
|
|
66
|
+
// or
|
|
67
|
+
auto instanceVal = info[0].As<Napi::Date>().ValueOf();
|
|
68
|
+
```
|
package/doc/env.md
CHANGED
|
@@ -61,3 +61,17 @@ Napi::Error Napi::Env::GetAndClearPendingException();
|
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
Returns an `Napi::Error` object representing the environment's pending exception, if any.
|
|
64
|
+
|
|
65
|
+
### RunScript
|
|
66
|
+
|
|
67
|
+
```cpp
|
|
68
|
+
Napi::Value Napi::Env::RunScript(____ script);
|
|
69
|
+
```
|
|
70
|
+
- `[in] script`: A string containing JavaScript code to execute.
|
|
71
|
+
|
|
72
|
+
Runs JavaScript code contained in a string and returns its result.
|
|
73
|
+
|
|
74
|
+
The `script` can be any of the following types:
|
|
75
|
+
- [`Napi::String`](string.md)
|
|
76
|
+
- `const char *`
|
|
77
|
+
- `const std::string &`
|
package/doc/function.md
CHANGED
|
@@ -11,6 +11,10 @@ functions that were created in JavaScript and passed to the native add-on.
|
|
|
11
11
|
The `Napi::Function` class inherits its behavior from the `Napi::Object` class (for more info
|
|
12
12
|
see: [`Napi::Object`](object.md)).
|
|
13
13
|
|
|
14
|
+
> For callbacks that will be called with asynchronous events from a
|
|
15
|
+
> non-JavaScript thread, please refer to [`Napi::ThreadSafeFunction`][] for more
|
|
16
|
+
> examples.
|
|
17
|
+
|
|
14
18
|
## Example
|
|
15
19
|
|
|
16
20
|
```cpp
|
|
@@ -25,7 +29,7 @@ Value Fn(const CallbackInfo& info) {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
Object Init(Env env, Object exports) {
|
|
28
|
-
exports.Set(String::New(env, "fn"), Function::New(env
|
|
32
|
+
exports.Set(String::New(env, "fn"), Function::New<Fn>(env));
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)
|
|
@@ -47,6 +51,27 @@ and in general in situations which don't have an existing JavaScript function on
|
|
|
47
51
|
the stack. The `Call` method is used when there is already a JavaScript function
|
|
48
52
|
on the stack (for example when running a native method called from JavaScript).
|
|
49
53
|
|
|
54
|
+
## Type definitions
|
|
55
|
+
|
|
56
|
+
### Napi::Function::VoidCallback
|
|
57
|
+
|
|
58
|
+
This is the type describing a callback returning `void` that will be invoked
|
|
59
|
+
from JavaScript.
|
|
60
|
+
|
|
61
|
+
```cpp
|
|
62
|
+
typedef void (*VoidCallback)(const Napi::CallbackInfo& info);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Napi::Function::Callback
|
|
66
|
+
|
|
67
|
+
This is the type describing a callback returning a value that will be invoked
|
|
68
|
+
from JavaScript.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
```cpp
|
|
72
|
+
typedef Value (*Callback)(const Napi::CallbackInfo& info);
|
|
73
|
+
```
|
|
74
|
+
|
|
50
75
|
## Methods
|
|
51
76
|
|
|
52
77
|
### Constructor
|
|
@@ -74,6 +99,86 @@ Returns a non-empty `Napi::Function` instance.
|
|
|
74
99
|
|
|
75
100
|
Creates an instance of a `Napi::Function` object.
|
|
76
101
|
|
|
102
|
+
```cpp
|
|
103
|
+
template <Napi::VoidCallback cb>
|
|
104
|
+
static Napi::Function New(napi_env env,
|
|
105
|
+
const char* utf8name = nullptr,
|
|
106
|
+
void* data = nullptr);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- `[template] cb`: The native function to invoke when the JavaScript function is
|
|
110
|
+
invoked.
|
|
111
|
+
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
|
|
112
|
+
- `[in] utf8name`: Null-terminated string to be used as the name of the function.
|
|
113
|
+
- `[in] data`: User-provided data context. This will be passed back into the
|
|
114
|
+
function when invoked later.
|
|
115
|
+
|
|
116
|
+
Returns an instance of a `Napi::Function` object.
|
|
117
|
+
|
|
118
|
+
### New
|
|
119
|
+
|
|
120
|
+
Creates an instance of a `Napi::Function` object.
|
|
121
|
+
|
|
122
|
+
```cpp
|
|
123
|
+
template <Napi::Callback cb>
|
|
124
|
+
static Napi::Function New(napi_env env,
|
|
125
|
+
const char* utf8name = nullptr,
|
|
126
|
+
void* data = nullptr);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- `[template] cb`: The native function to invoke when the JavaScript function is
|
|
130
|
+
invoked.
|
|
131
|
+
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
|
|
132
|
+
- `[in] utf8name`: Null-terminated string to be used as the name of the function.
|
|
133
|
+
- `[in] data`: User-provided data context. This will be passed back into the
|
|
134
|
+
function when invoked later.
|
|
135
|
+
|
|
136
|
+
Returns an instance of a `Napi::Function` object.
|
|
137
|
+
|
|
138
|
+
### New
|
|
139
|
+
|
|
140
|
+
Creates an instance of a `Napi::Function` object.
|
|
141
|
+
|
|
142
|
+
```cpp
|
|
143
|
+
template <Napi::VoidCallback cb>
|
|
144
|
+
static Napi::Function New(napi_env env,
|
|
145
|
+
const std::string& utf8name,
|
|
146
|
+
void* data = nullptr);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- `[template] cb`: The native function to invoke when the JavaScript function is
|
|
150
|
+
invoked.
|
|
151
|
+
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
|
|
152
|
+
- `[in] utf8name`: String to be used as the name of the function.
|
|
153
|
+
- `[in] data`: User-provided data context. This will be passed back into the
|
|
154
|
+
function when invoked later.
|
|
155
|
+
|
|
156
|
+
Returns an instance of a `Napi::Function` object.
|
|
157
|
+
|
|
158
|
+
### New
|
|
159
|
+
|
|
160
|
+
Creates an instance of a `Napi::Function` object.
|
|
161
|
+
|
|
162
|
+
```cpp
|
|
163
|
+
template <Napi::Callback cb>
|
|
164
|
+
static Napi::Function New(napi_env env,
|
|
165
|
+
const std::string& utf8name,
|
|
166
|
+
void* data = nullptr);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- `[template] cb`: The native function to invoke when the JavaScript function is
|
|
170
|
+
invoked.
|
|
171
|
+
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Function` object.
|
|
172
|
+
- `[in] utf8name`: String to be used as the name of the function.
|
|
173
|
+
- `[in] data`: User-provided data context. This will be passed back into the
|
|
174
|
+
function when invoked later.
|
|
175
|
+
|
|
176
|
+
Returns an instance of a `Napi::Function` object.
|
|
177
|
+
|
|
178
|
+
### New
|
|
179
|
+
|
|
180
|
+
Creates an instance of a `Napi::Function` object.
|
|
181
|
+
|
|
77
182
|
```cpp
|
|
78
183
|
template <typename Callable>
|
|
79
184
|
static Napi::Function Napi::Function::New(napi_env env, Callable cb, const char* utf8name = nullptr, void* data = nullptr);
|
|
@@ -292,3 +397,5 @@ Napi::Value Napi::Function::operator ()(const std::initializer_list<napi_value>&
|
|
|
292
397
|
- `[in] args`: Initializer list of JavaScript values as `napi_value`.
|
|
293
398
|
|
|
294
399
|
Returns a `Napi::Value` representing the JavaScript value returned by the function.
|
|
400
|
+
|
|
401
|
+
[`Napi::ThreadSafeFunction`]: ./threadsafe_function.md
|
package/doc/object.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `Napi::Object` class corresponds to a JavaScript object. It is extended by the following node-addon-api classes that you may use when working with more specific types:
|
|
4
4
|
|
|
5
|
-
- [`Napi::Value`](value.md)
|
|
5
|
+
- [`Napi::Value`](value.md) which is extended by [`Napi::Array`](basic_types.md#array)
|
|
6
6
|
- [`Napi::ArrayBuffer`](array_buffer.md)
|
|
7
7
|
- [`Napi::Buffer<T>`](buffer.md)
|
|
8
8
|
- [`Napi::Function`](function.md)
|
|
@@ -101,6 +101,22 @@ While the value must be any of the following types:
|
|
|
101
101
|
- `bool`
|
|
102
102
|
- `double`
|
|
103
103
|
|
|
104
|
+
### Delete()
|
|
105
|
+
|
|
106
|
+
```cpp
|
|
107
|
+
bool Napi::Object::Delete(____ key);
|
|
108
|
+
```
|
|
109
|
+
- `[in] key`: The name of the property to delete.
|
|
110
|
+
|
|
111
|
+
Deletes the property associated with the given key. Returns `true` if the property was deleted.
|
|
112
|
+
|
|
113
|
+
The `key` can be any of the following types:
|
|
114
|
+
- `napi_value`
|
|
115
|
+
- [`Napi::Value`](value.md)
|
|
116
|
+
- `const char *`
|
|
117
|
+
- `const std::string &`
|
|
118
|
+
- `uint32_t`
|
|
119
|
+
|
|
104
120
|
### Get()
|
|
105
121
|
|
|
106
122
|
```cpp
|
|
@@ -137,6 +153,63 @@ Returns a `bool` that is true if the `Napi::Object` is an instance created by th
|
|
|
137
153
|
|
|
138
154
|
Note: This is equivalent to the JavaScript instanceof operator.
|
|
139
155
|
|
|
156
|
+
### AddFinalizer()
|
|
157
|
+
```cpp
|
|
158
|
+
template <typename Finalizer, typename T>
|
|
159
|
+
inline void AddFinalizer(Finalizer finalizeCallback, T* data);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- `[in] finalizeCallback`: The function to call when the object is garbage-collected.
|
|
163
|
+
- `[in] data`: The data to associate with the object.
|
|
164
|
+
|
|
165
|
+
Associates `data` with the object, calling `finalizeCallback` when the object is garbage-collected. `finalizeCallback`
|
|
166
|
+
has the signature
|
|
167
|
+
```cpp
|
|
168
|
+
void finalizeCallback(Napi::Env env, T* data);
|
|
169
|
+
```
|
|
170
|
+
where `data` is the pointer that was passed into the call to `AddFinalizer()`.
|
|
171
|
+
|
|
172
|
+
### AddFinalizer()
|
|
173
|
+
```cpp
|
|
174
|
+
template <typename Finalizer, typename T, typename Hint>
|
|
175
|
+
inline void AddFinalizer(Finalizer finalizeCallback,
|
|
176
|
+
T* data,
|
|
177
|
+
Hint* finalizeHint);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- `[in] data`: The data to associate with the object.
|
|
181
|
+
- `[in] finalizeCallback`: The function to call when the object is garbage-collected.
|
|
182
|
+
|
|
183
|
+
Associates `data` with the object, calling `finalizeCallback` when the object is garbage-collected. An additional hint
|
|
184
|
+
may be given. It will also be passed to `finalizeCallback`, which has the signature
|
|
185
|
+
```cpp
|
|
186
|
+
void finalizeCallback(Napi::Env env, T* data, Hint* hint);
|
|
187
|
+
```
|
|
188
|
+
where `data` and `hint` are the pointers that were passed into the call to `AddFinalizer()`.
|
|
189
|
+
|
|
190
|
+
### GetPropertyNames()
|
|
191
|
+
```cpp
|
|
192
|
+
Napi::Array Napi::Object::GetPropertyNames() const;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Returns the names of the enumerable properties of the object as a [`Napi::Array`](basic_types.md#array) of strings.
|
|
196
|
+
The properties whose key is a `Symbol` will not be included.
|
|
197
|
+
|
|
198
|
+
### HasOwnProperty()
|
|
199
|
+
```cpp
|
|
200
|
+
bool Napi::Object::HasOwnProperty(____ key); const
|
|
201
|
+
```
|
|
202
|
+
- `[in] key` The name of the property to check.
|
|
203
|
+
|
|
204
|
+
Returns a `bool` that is *true* if the object has an own property named `key` and *false* otherwise.
|
|
205
|
+
|
|
206
|
+
The key can be any of the following types:
|
|
207
|
+
- `napi_value`
|
|
208
|
+
- [`Napi::Value`](value.md)
|
|
209
|
+
- `const char*`
|
|
210
|
+
- `const std::string&`
|
|
211
|
+
- `uint32_t`
|
|
212
|
+
|
|
140
213
|
### DefineProperty()
|
|
141
214
|
|
|
142
215
|
```cpp
|
|
@@ -69,7 +69,7 @@ for (int i = 0; i < LOOP_MAX; i++) {
|
|
|
69
69
|
Napi::HandleScope scope(info.Env());
|
|
70
70
|
std::string name = std::string("inner-scope") + std::to_string(i);
|
|
71
71
|
Napi::Value newValue = Napi::String::New(info.Env(), name.c_str());
|
|
72
|
-
// do something with
|
|
72
|
+
// do something with newValue
|
|
73
73
|
};
|
|
74
74
|
```
|
|
75
75
|
|
package/doc/object_wrap.md
CHANGED
|
@@ -34,8 +34,8 @@ class Example : public Napi::ObjectWrap<Example> {
|
|
|
34
34
|
Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
|
|
35
35
|
// This method is used to hook the accessor and method callbacks
|
|
36
36
|
Napi::Function func = DefineClass(env, "Example", {
|
|
37
|
-
InstanceMethod("GetValue"
|
|
38
|
-
InstanceMethod("SetValue"
|
|
37
|
+
InstanceMethod<&Example::GetValue>("GetValue"),
|
|
38
|
+
InstanceMethod<&Example::SetValue>("SetValue")
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
// Create a peristent reference to the class constructor. This will allow
|
|
@@ -161,7 +161,7 @@ static Napi::Function Napi::ObjectWrap::DefineClass(Napi::Env env,
|
|
|
161
161
|
JavaScript constructor function.
|
|
162
162
|
* `[in] properties`: Initializer list of class property descriptor describing
|
|
163
163
|
static and instance properties and methods of the class.
|
|
164
|
-
See: [`Class
|
|
164
|
+
See: [`Class property and descriptor`](class_property_descriptor.md).
|
|
165
165
|
* `[in] data`: User-provided data passed to the constructor callback as `data`
|
|
166
166
|
property of the `Napi::CallbackInfo`.
|
|
167
167
|
|
|
@@ -184,12 +184,23 @@ static Napi::Function Napi::ObjectWrap::DefineClass(Napi::Env env,
|
|
|
184
184
|
JavaScript constructor function.
|
|
185
185
|
* `[in] properties`: Vector of class property descriptor describing static and
|
|
186
186
|
instance properties and methods of the class.
|
|
187
|
-
See: [`Class
|
|
187
|
+
See: [`Class property and descriptor`](class_property_descriptor.md).
|
|
188
188
|
* `[in] data`: User-provided data passed to the constructor callback as `data`
|
|
189
189
|
property of the `Napi::CallbackInfo`.
|
|
190
190
|
|
|
191
191
|
Returns a `Napi::Function` representing the constructor function for the class.
|
|
192
192
|
|
|
193
|
+
### Finalize
|
|
194
|
+
|
|
195
|
+
Provides an opportunity to run cleanup code that requires access to the `Napi::Env`
|
|
196
|
+
before the wrapped native object instance is freed. Override to implement.
|
|
197
|
+
|
|
198
|
+
```cpp
|
|
199
|
+
virtual void Finalize(Napi::Env env);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- `[in] env`: `Napi::Env`.
|
|
203
|
+
|
|
193
204
|
### StaticMethod
|
|
194
205
|
|
|
195
206
|
Creates property descriptor that represents a static method of a JavaScript class.
|
|
@@ -278,6 +289,93 @@ One or more of `napi_property_attributes`.
|
|
|
278
289
|
Returns `Napi::PropertyDescriptor` object that represents a static method of a
|
|
279
290
|
JavaScript class.
|
|
280
291
|
|
|
292
|
+
### StaticMethod
|
|
293
|
+
|
|
294
|
+
Creates property descriptor that represents a static method of a JavaScript class.
|
|
295
|
+
|
|
296
|
+
```cpp
|
|
297
|
+
template <StaticVoidMethodCallback method>
|
|
298
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
|
|
299
|
+
napi_property_attributes attributes = napi_default,
|
|
300
|
+
void* data = nullptr);
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
- `[in] method`: The native function that represents a static method of a
|
|
304
|
+
JavaScript class. This function returns nothing.
|
|
305
|
+
- `[in] utf8name`: Null-terminated string that represents the name of a static
|
|
306
|
+
method for the class.
|
|
307
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
308
|
+
One or more of `napi_property_attributes`.
|
|
309
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
310
|
+
|
|
311
|
+
Returns `Napi::PropertyDescriptor` object that represents the static method of a
|
|
312
|
+
JavaScript class.
|
|
313
|
+
|
|
314
|
+
### StaticMethod
|
|
315
|
+
|
|
316
|
+
Creates property descriptor that represents a static method of a JavaScript class.
|
|
317
|
+
|
|
318
|
+
```cpp
|
|
319
|
+
template <StaticMethodCallback method>
|
|
320
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(const char* utf8name,
|
|
321
|
+
napi_property_attributes attributes = napi_default,
|
|
322
|
+
void* data = nullptr);
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
- `[in] method`: The native function that represents a static method of a
|
|
326
|
+
JavaScript class.
|
|
327
|
+
- `[in] utf8name`: Null-terminated string that represents the name of a static
|
|
328
|
+
method for the class.
|
|
329
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
330
|
+
One or more of `napi_property_attributes`.
|
|
331
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
332
|
+
|
|
333
|
+
Returns `Napi::PropertyDescriptor` object that represents a static method of a
|
|
334
|
+
JavaScript class.
|
|
335
|
+
|
|
336
|
+
### StaticMethod
|
|
337
|
+
|
|
338
|
+
Creates property descriptor that represents a static method of a JavaScript class.
|
|
339
|
+
|
|
340
|
+
```cpp
|
|
341
|
+
template <StaticVoidMethodCallback method>
|
|
342
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
|
|
343
|
+
napi_property_attributes attributes = napi_default,
|
|
344
|
+
void* data = nullptr);
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
- `[in] method`: The native function that represents a static method of a
|
|
348
|
+
JavaScript class.
|
|
349
|
+
- `[in] name`: Napi:Symbol that represents the name of a static
|
|
350
|
+
method for the class.
|
|
351
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
352
|
+
One or more of `napi_property_attributes`.
|
|
353
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
354
|
+
|
|
355
|
+
Returns `Napi::PropertyDescriptor` object that represents the static method of a
|
|
356
|
+
JavaScript class.
|
|
357
|
+
|
|
358
|
+
### StaticMethod
|
|
359
|
+
|
|
360
|
+
Creates property descriptor that represents a static method of a JavaScript class.
|
|
361
|
+
|
|
362
|
+
```cpp
|
|
363
|
+
template <StaticMethodCallback method>
|
|
364
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticMethod(Symbol name,
|
|
365
|
+
napi_property_attributes attributes = napi_default,
|
|
366
|
+
void* data = nullptr);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
- `[in] method`: The native function that represents a static method of a
|
|
370
|
+
JavaScript class.
|
|
371
|
+
- `[in] name`: Napi:Symbol that represents the name of a static.
|
|
372
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
373
|
+
One or more of `napi_property_attributes`.
|
|
374
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
375
|
+
|
|
376
|
+
Returns `Napi::PropertyDescriptor` object that represents a static method of a
|
|
377
|
+
JavaScript class.
|
|
378
|
+
|
|
281
379
|
### StaticAccessor
|
|
282
380
|
|
|
283
381
|
Creates property descriptor that represents a static accessor property of a
|
|
@@ -331,6 +429,57 @@ is invoked.
|
|
|
331
429
|
Returns `Napi::PropertyDescriptor` object that represents a static accessor
|
|
332
430
|
property of a JavaScript class.
|
|
333
431
|
|
|
432
|
+
### StaticAccessor
|
|
433
|
+
|
|
434
|
+
Creates property descriptor that represents a static accessor property of a
|
|
435
|
+
JavaScript class.
|
|
436
|
+
|
|
437
|
+
```cpp
|
|
438
|
+
template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
|
|
439
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(const char* utf8name,
|
|
440
|
+
napi_property_attributes attributes = napi_default,
|
|
441
|
+
void* data = nullptr);
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
- `[in] getter`: The native function to call when a get access to the property of
|
|
445
|
+
a JavaScript class is performed.
|
|
446
|
+
- `[in] setter`: The native function to call when a set access to the property of
|
|
447
|
+
a JavaScript class is performed.
|
|
448
|
+
- `[in] utf8name`: Null-terminated string that represents the name of a static
|
|
449
|
+
accessor property for the class.
|
|
450
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
451
|
+
One or more of `napi_property_attributes`.
|
|
452
|
+
- `[in] data`: User-provided data passed into getter or setter when
|
|
453
|
+
is invoked.
|
|
454
|
+
|
|
455
|
+
Returns `Napi::PropertyDescriptor` object that represents a static accessor
|
|
456
|
+
property of a JavaScript class.
|
|
457
|
+
|
|
458
|
+
### StaticAccessor
|
|
459
|
+
|
|
460
|
+
Creates property descriptor that represents a static accessor property of a
|
|
461
|
+
JavaScript class.
|
|
462
|
+
|
|
463
|
+
```cpp
|
|
464
|
+
template <StaticGetterCallback getter, StaticSetterCallback setter=nullptr>
|
|
465
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::StaticAccessor(Symbol name,
|
|
466
|
+
napi_property_attributes attributes = napi_default,
|
|
467
|
+
void* data = nullptr);
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
- `[in] getter`: The native function to call when a get access to the property of
|
|
471
|
+
a JavaScript class is performed.
|
|
472
|
+
- `[in] setter`: The native function to call when a set access to the property of
|
|
473
|
+
a JavaScript class is performed.
|
|
474
|
+
- `[in] name`: Napi:Symbol that represents the name of a static accessor.
|
|
475
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
476
|
+
One or more of `napi_property_attributes`.
|
|
477
|
+
- `[in] data`: User-provided data passed into getter or setter when
|
|
478
|
+
is invoked.
|
|
479
|
+
|
|
480
|
+
Returns `Napi::PropertyDescriptor` object that represents a static accessor
|
|
481
|
+
property of a JavaScript class.
|
|
482
|
+
|
|
334
483
|
### InstanceMethod
|
|
335
484
|
|
|
336
485
|
Creates property descriptor that represents an instance method of a JavaScript class.
|
|
@@ -419,6 +568,94 @@ One or more of `napi_property_attributes`.
|
|
|
419
568
|
Returns `Napi::PropertyDescriptor` object that represents an instance method of a
|
|
420
569
|
JavaScript class.
|
|
421
570
|
|
|
571
|
+
### InstanceMethod
|
|
572
|
+
|
|
573
|
+
Creates property descriptor that represents an instance method of a JavaScript class.
|
|
574
|
+
|
|
575
|
+
```cpp
|
|
576
|
+
template <InstanceVoidMethodCallback method>
|
|
577
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
|
|
578
|
+
napi_property_attributes attributes = napi_default,
|
|
579
|
+
void* data = nullptr);
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
- `[in] method`: The native function that represents an instance method of a
|
|
583
|
+
JavaScript class.
|
|
584
|
+
- `[in] utf8name`: Null-terminated string that represents the name of an instance
|
|
585
|
+
method for the class.
|
|
586
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
587
|
+
One or more of `napi_property_attributes`.
|
|
588
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
589
|
+
|
|
590
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance method of a
|
|
591
|
+
JavaScript class.
|
|
592
|
+
|
|
593
|
+
### InstanceMethod
|
|
594
|
+
|
|
595
|
+
Creates property descriptor that represents an instance method of a JavaScript class.
|
|
596
|
+
|
|
597
|
+
```cpp
|
|
598
|
+
template <InstanceMethodCallback method>
|
|
599
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(const char* utf8name,
|
|
600
|
+
napi_property_attributes attributes = napi_default,
|
|
601
|
+
void* data = nullptr);
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
- `[in] method`: The native function that represents an instance method of a
|
|
605
|
+
JavaScript class.
|
|
606
|
+
- `[in] utf8name`: Null-terminated string that represents the name of an instance
|
|
607
|
+
method for the class.
|
|
608
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
609
|
+
One or more of `napi_property_attributes`.
|
|
610
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
611
|
+
|
|
612
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance method of a
|
|
613
|
+
JavaScript class.
|
|
614
|
+
|
|
615
|
+
### InstanceMethod
|
|
616
|
+
|
|
617
|
+
Creates property descriptor that represents an instance method of a JavaScript class.
|
|
618
|
+
|
|
619
|
+
```cpp
|
|
620
|
+
template <InstanceVoidMethodCallback method>
|
|
621
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
|
|
622
|
+
napi_property_attributes attributes = napi_default,
|
|
623
|
+
void* data = nullptr);
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
- `[in] method`: The native function that represents an instance method of a
|
|
627
|
+
JavaScript class.
|
|
628
|
+
- `[in] name`: The `Napi::Symbol` object whose value is used to identify the
|
|
629
|
+
instance method for the class.
|
|
630
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
631
|
+
One or more of `napi_property_attributes`.
|
|
632
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
633
|
+
|
|
634
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance method of a
|
|
635
|
+
JavaScript class.
|
|
636
|
+
|
|
637
|
+
### InstanceMethod
|
|
638
|
+
|
|
639
|
+
Creates property descriptor that represents an instance method of a JavaScript class.
|
|
640
|
+
|
|
641
|
+
```cpp
|
|
642
|
+
template <InstanceMethodCallback method>
|
|
643
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceMethod(Napi::Symbol name,
|
|
644
|
+
napi_property_attributes attributes = napi_default,
|
|
645
|
+
void* data = nullptr);
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
- `[in] method`: The native function that represents an instance method of a
|
|
649
|
+
JavaScript class.
|
|
650
|
+
- `[in] name`: The `Napi::Symbol` object whose value is used to identify the
|
|
651
|
+
instance method for the class.
|
|
652
|
+
- `[in] attributes`: The attributes associated with a particular property.
|
|
653
|
+
One or more of `napi_property_attributes`.
|
|
654
|
+
- `[in] data`: User-provided data passed into method when it is invoked.
|
|
655
|
+
|
|
656
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance method of a
|
|
657
|
+
JavaScript class.
|
|
658
|
+
|
|
422
659
|
### InstanceAccessor
|
|
423
660
|
|
|
424
661
|
Creates property descriptor that represents an instance accessor property of a
|
|
@@ -471,6 +708,56 @@ One or more of `napi_property_attributes`.
|
|
|
471
708
|
Returns `Napi::PropertyDescriptor` object that represents an instance accessor
|
|
472
709
|
property of a JavaScript class.
|
|
473
710
|
|
|
711
|
+
### InstanceAccessor
|
|
712
|
+
|
|
713
|
+
Creates property descriptor that represents an instance accessor property of a
|
|
714
|
+
JavaScript class.
|
|
715
|
+
|
|
716
|
+
```cpp
|
|
717
|
+
template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
|
|
718
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(const char* utf8name,
|
|
719
|
+
napi_property_attributes attributes = napi_default,
|
|
720
|
+
void* data = nullptr);
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
- `[in] getter`: The native function to call when a get access to the property of
|
|
724
|
+
a JavaScript class is performed.
|
|
725
|
+
- `[in] setter`: The native function to call when a set access to the property of
|
|
726
|
+
a JavaScript class is performed.
|
|
727
|
+
- `[in] utf8name`: Null-terminated string that represents the name of an instance
|
|
728
|
+
accessor property for the class.
|
|
729
|
+
- `[in] attributes`: The attributes associated with the particular property.
|
|
730
|
+
One or more of `napi_property_attributes`.
|
|
731
|
+
- `[in] data`: User-provided data passed into getter or setter when this is invoked.
|
|
732
|
+
|
|
733
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance accessor
|
|
734
|
+
property of a JavaScript class.
|
|
735
|
+
|
|
736
|
+
### InstanceAccessor
|
|
737
|
+
|
|
738
|
+
Creates property descriptor that represents an instance accessor property of a
|
|
739
|
+
JavaScript class.
|
|
740
|
+
|
|
741
|
+
```cpp
|
|
742
|
+
template <InstanceGetterCallback getter, InstanceSetterCallback setter=nullptr>
|
|
743
|
+
static Napi::PropertyDescriptor Napi::ObjectWrap::InstanceAccessor(Symbol name,
|
|
744
|
+
napi_property_attributes attributes = napi_default,
|
|
745
|
+
void* data = nullptr);
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
- `[in] getter`: The native function to call when a get access to the property of
|
|
749
|
+
a JavaScript class is performed.
|
|
750
|
+
- `[in] setter`: The native function to call when a set access to the property of
|
|
751
|
+
a JavaScript class is performed.
|
|
752
|
+
- `[in] name`: The `Napi::Symbol` object whose value is used to identify the
|
|
753
|
+
instance accessor.
|
|
754
|
+
- `[in] attributes`: The attributes associated with the particular property.
|
|
755
|
+
One or more of `napi_property_attributes`.
|
|
756
|
+
- `[in] data`: User-provided data passed into getter or setter when this is invoked.
|
|
757
|
+
|
|
758
|
+
Returns `Napi::PropertyDescriptor` object that represents an instance accessor
|
|
759
|
+
property of a JavaScript class.
|
|
760
|
+
|
|
474
761
|
### StaticValue
|
|
475
762
|
|
|
476
763
|
Creates property descriptor that represents an static value property of a
|
package/doc/prebuild_tools.md
CHANGED
|
@@ -9,7 +9,7 @@ possible to ditribute the native add-on in pre-built form for different platform
|
|
|
9
9
|
and architectures. The prebuild tools help to create and distrubute the pre-built
|
|
10
10
|
form of a native add-on.
|
|
11
11
|
|
|
12
|
-
The following list report
|
|
12
|
+
The following list report known tools that are compatible with **N-API**:
|
|
13
13
|
|
|
14
14
|
- **[node-pre-gyp](https://www.npmjs.com/package/node-pre-gyp)**
|
|
15
15
|
- **[prebuild](https://www.npmjs.com/package/prebuild)**
|