node-addon-api 1.7.2 → 2.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 +4 -7
- package/CHANGELOG.md +54 -3
- package/README.md +6 -3
- package/doc/array_buffer.md +1 -1
- package/doc/async_context.md +10 -0
- package/doc/async_operations.md +1 -1
- package/doc/async_progress_worker.md +344 -0
- package/doc/async_worker.md +23 -22
- package/doc/basic_types.md +8 -0
- package/doc/class_property_descriptor.md +2 -3
- package/doc/cmake-js.md +58 -9
- package/doc/date.md +68 -0
- package/doc/object.md +34 -0
- package/doc/object_wrap.md +13 -2
- package/doc/prebuild_tools.md +1 -1
- package/doc/threadsafe_function.md +18 -1
- package/doc/value.md +9 -0
- package/napi-inl.h +346 -76
- package/napi.h +136 -18
- package/package.json +212 -47
- package/src/node_api.cc +3 -9
package/napi.h
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include <functional>
|
|
6
6
|
#include <initializer_list>
|
|
7
7
|
#include <memory>
|
|
8
|
+
#include <mutex>
|
|
8
9
|
#include <string>
|
|
9
10
|
#include <vector>
|
|
10
11
|
|
|
@@ -111,11 +112,15 @@ namespace Napi {
|
|
|
111
112
|
class Value;
|
|
112
113
|
class Boolean;
|
|
113
114
|
class Number;
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
|
|
115
|
+
// Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
|
|
116
|
+
// Once it is no longer experimental guard with the NAPI_VERSION in which it is
|
|
117
|
+
// released instead.
|
|
118
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
117
119
|
class BigInt;
|
|
118
120
|
#endif // NAPI_EXPERIMENTAL
|
|
121
|
+
#if (NAPI_VERSION > 4)
|
|
122
|
+
class Date;
|
|
123
|
+
#endif
|
|
119
124
|
class String;
|
|
120
125
|
class Object;
|
|
121
126
|
class Array;
|
|
@@ -136,9 +141,10 @@ namespace Napi {
|
|
|
136
141
|
typedef TypedArrayOf<uint32_t> Uint32Array; ///< Typed-array of unsigned 32-bit integers
|
|
137
142
|
typedef TypedArrayOf<float> Float32Array; ///< Typed-array of 32-bit floating-point values
|
|
138
143
|
typedef TypedArrayOf<double> Float64Array; ///< Typed-array of 64-bit floating-point values
|
|
139
|
-
//
|
|
140
|
-
//
|
|
141
|
-
|
|
144
|
+
// Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
|
|
145
|
+
// Once it is no longer experimental guard with the NAPI_VERSION in which it is
|
|
146
|
+
// released instead.
|
|
147
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
142
148
|
typedef TypedArrayOf<int64_t> BigInt64Array; ///< Typed array of signed 64-bit integers
|
|
143
149
|
typedef TypedArrayOf<uint64_t> BigUint64Array; ///< Typed array of unsigned 64-bit integers
|
|
144
150
|
#endif // NAPI_EXPERIMENTAL
|
|
@@ -241,11 +247,15 @@ namespace Napi {
|
|
|
241
247
|
bool IsNull() const; ///< Tests if a value is a null JavaScript value.
|
|
242
248
|
bool IsBoolean() const; ///< Tests if a value is a JavaScript boolean.
|
|
243
249
|
bool IsNumber() const; ///< Tests if a value is a JavaScript number.
|
|
244
|
-
//
|
|
245
|
-
//
|
|
246
|
-
|
|
250
|
+
// Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
|
|
251
|
+
// Once it is no longer experimental guard with the NAPI_VERSION in which it is
|
|
252
|
+
// released instead.
|
|
253
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
247
254
|
bool IsBigInt() const; ///< Tests if a value is a JavaScript bigint.
|
|
248
255
|
#endif // NAPI_EXPERIMENTAL
|
|
256
|
+
#if (NAPI_VERSION > 4)
|
|
257
|
+
bool IsDate() const; ///< Tests if a value is a JavaScript date.
|
|
258
|
+
#endif
|
|
249
259
|
bool IsString() const; ///< Tests if a value is a JavaScript string.
|
|
250
260
|
bool IsSymbol() const; ///< Tests if a value is a JavaScript symbol.
|
|
251
261
|
bool IsArray() const; ///< Tests if a value is a JavaScript array.
|
|
@@ -315,9 +325,10 @@ namespace Napi {
|
|
|
315
325
|
double DoubleValue() const; ///< Converts a Number value to a 64-bit floating-point value.
|
|
316
326
|
};
|
|
317
327
|
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
|
|
328
|
+
// Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
|
|
329
|
+
// Once it is no longer experimental guard with the NAPI_VERSION in which it is
|
|
330
|
+
// released instead.
|
|
331
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
321
332
|
/// A JavaScript bigint value.
|
|
322
333
|
class BigInt : public Value {
|
|
323
334
|
public:
|
|
@@ -358,6 +369,24 @@ namespace Napi {
|
|
|
358
369
|
};
|
|
359
370
|
#endif // NAPI_EXPERIMENTAL
|
|
360
371
|
|
|
372
|
+
#if (NAPI_VERSION > 4)
|
|
373
|
+
/// A JavaScript date value.
|
|
374
|
+
class Date : public Value {
|
|
375
|
+
public:
|
|
376
|
+
/// Creates a new Date value from a double primitive.
|
|
377
|
+
static Date New(
|
|
378
|
+
napi_env env, ///< N-API environment
|
|
379
|
+
double value ///< Number value
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
Date(); ///< Creates a new _empty_ Date instance.
|
|
383
|
+
Date(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
|
|
384
|
+
operator double() const; ///< Converts a Date value to double primitive
|
|
385
|
+
|
|
386
|
+
double ValueOf() const; ///< Converts a Date value to a double primitive.
|
|
387
|
+
};
|
|
388
|
+
#endif
|
|
389
|
+
|
|
361
390
|
/// A JavaScript string or symbol value (that can be used as a property name).
|
|
362
391
|
class Name : public Value {
|
|
363
392
|
public:
|
|
@@ -685,6 +714,14 @@ namespace Napi {
|
|
|
685
714
|
bool InstanceOf(
|
|
686
715
|
const Function& constructor ///< Constructor function
|
|
687
716
|
) const;
|
|
717
|
+
|
|
718
|
+
template <typename Finalizer, typename T>
|
|
719
|
+
inline void AddFinalizer(Finalizer finalizeCallback, T* data);
|
|
720
|
+
|
|
721
|
+
template <typename Finalizer, typename T, typename Hint>
|
|
722
|
+
inline void AddFinalizer(Finalizer finalizeCallback,
|
|
723
|
+
T* data,
|
|
724
|
+
Hint* finalizeHint);
|
|
688
725
|
};
|
|
689
726
|
|
|
690
727
|
template <typename T>
|
|
@@ -819,9 +856,10 @@ namespace Napi {
|
|
|
819
856
|
: std::is_same<T, uint32_t>::value ? napi_uint32_array
|
|
820
857
|
: std::is_same<T, float>::value ? napi_float32_array
|
|
821
858
|
: std::is_same<T, double>::value ? napi_float64_array
|
|
822
|
-
//
|
|
823
|
-
//
|
|
824
|
-
|
|
859
|
+
// Currently experimental guard with the definition of NAPI_EXPERIMENTAL.
|
|
860
|
+
// Once it is no longer experimental guard with the NAPI_VERSION in which it is
|
|
861
|
+
// released instead.
|
|
862
|
+
#ifdef NAPI_EXPERIMENTAL
|
|
825
863
|
: std::is_same<T, int64_t>::value ? napi_bigint64_array
|
|
826
864
|
: std::is_same<T, uint64_t>::value ? napi_biguint64_array
|
|
827
865
|
#endif // NAPI_EXPERIMENTAL
|
|
@@ -1570,6 +1608,7 @@ namespace Napi {
|
|
|
1570
1608
|
class ObjectWrap : public Reference<Object> {
|
|
1571
1609
|
public:
|
|
1572
1610
|
ObjectWrap(const CallbackInfo& callbackInfo);
|
|
1611
|
+
virtual ~ObjectWrap();
|
|
1573
1612
|
|
|
1574
1613
|
static T* Unwrap(Object wrapper);
|
|
1575
1614
|
|
|
@@ -1657,6 +1696,7 @@ namespace Napi {
|
|
|
1657
1696
|
static PropertyDescriptor InstanceValue(Symbol name,
|
|
1658
1697
|
Napi::Value value,
|
|
1659
1698
|
napi_property_attributes attributes = napi_default);
|
|
1699
|
+
virtual void Finalize(Napi::Env env);
|
|
1660
1700
|
|
|
1661
1701
|
private:
|
|
1662
1702
|
static napi_value ConstructorCallbackWrapper(napi_env env, napi_callback_info info);
|
|
@@ -1703,6 +1743,10 @@ namespace Napi {
|
|
|
1703
1743
|
explicit HandleScope(Napi::Env env);
|
|
1704
1744
|
~HandleScope();
|
|
1705
1745
|
|
|
1746
|
+
// Disallow copying to prevent double close of napi_handle_scope
|
|
1747
|
+
HandleScope(HandleScope const &) = delete;
|
|
1748
|
+
void operator=(HandleScope const &) = delete;
|
|
1749
|
+
|
|
1706
1750
|
operator napi_handle_scope() const;
|
|
1707
1751
|
|
|
1708
1752
|
Napi::Env Env() const;
|
|
@@ -1718,6 +1762,10 @@ namespace Napi {
|
|
|
1718
1762
|
explicit EscapableHandleScope(Napi::Env env);
|
|
1719
1763
|
~EscapableHandleScope();
|
|
1720
1764
|
|
|
1765
|
+
// Disallow copying to prevent double close of napi_escapable_handle_scope
|
|
1766
|
+
EscapableHandleScope(EscapableHandleScope const &) = delete;
|
|
1767
|
+
void operator=(EscapableHandleScope const &) = delete;
|
|
1768
|
+
|
|
1721
1769
|
operator napi_escapable_handle_scope() const;
|
|
1722
1770
|
|
|
1723
1771
|
Napi::Env Env() const;
|
|
@@ -1735,6 +1783,10 @@ namespace Napi {
|
|
|
1735
1783
|
CallbackScope(napi_env env, napi_async_context context);
|
|
1736
1784
|
virtual ~CallbackScope();
|
|
1737
1785
|
|
|
1786
|
+
// Disallow copying to prevent double close of napi_callback_scope
|
|
1787
|
+
CallbackScope(CallbackScope const &) = delete;
|
|
1788
|
+
void operator=(CallbackScope const &) = delete;
|
|
1789
|
+
|
|
1738
1790
|
operator napi_callback_scope() const;
|
|
1739
1791
|
|
|
1740
1792
|
Napi::Env Env() const;
|
|
@@ -1758,6 +1810,8 @@ namespace Napi {
|
|
|
1758
1810
|
|
|
1759
1811
|
operator napi_async_context() const;
|
|
1760
1812
|
|
|
1813
|
+
Napi::Env Env() const;
|
|
1814
|
+
|
|
1761
1815
|
private:
|
|
1762
1816
|
napi_env _env;
|
|
1763
1817
|
napi_async_context _context;
|
|
@@ -1960,8 +2014,7 @@ namespace Napi {
|
|
|
1960
2014
|
ThreadSafeFunction();
|
|
1961
2015
|
ThreadSafeFunction(napi_threadsafe_function tsFunctionValue);
|
|
1962
2016
|
|
|
1963
|
-
|
|
1964
|
-
ThreadSafeFunction& operator=(ThreadSafeFunction&& other);
|
|
2017
|
+
operator napi_threadsafe_function() const;
|
|
1965
2018
|
|
|
1966
2019
|
// This API may be called from any thread.
|
|
1967
2020
|
napi_status BlockingCall() const;
|
|
@@ -1985,6 +2038,12 @@ namespace Napi {
|
|
|
1985
2038
|
template <typename DataType, typename Callback>
|
|
1986
2039
|
napi_status NonBlockingCall(DataType* data, Callback callback) const;
|
|
1987
2040
|
|
|
2041
|
+
// This API may only be called from the main thread.
|
|
2042
|
+
void Ref(napi_env env) const;
|
|
2043
|
+
|
|
2044
|
+
// This API may only be called from the main thread.
|
|
2045
|
+
void Unref(napi_env env) const;
|
|
2046
|
+
|
|
1988
2047
|
// This API may be called from any thread.
|
|
1989
2048
|
napi_status Acquire() const;
|
|
1990
2049
|
|
|
@@ -2028,7 +2087,66 @@ namespace Napi {
|
|
|
2028
2087
|
void* context,
|
|
2029
2088
|
void* data);
|
|
2030
2089
|
|
|
2031
|
-
|
|
2090
|
+
napi_threadsafe_function _tsfn;
|
|
2091
|
+
};
|
|
2092
|
+
|
|
2093
|
+
template<class T>
|
|
2094
|
+
class AsyncProgressWorker : public AsyncWorker {
|
|
2095
|
+
public:
|
|
2096
|
+
virtual ~AsyncProgressWorker();
|
|
2097
|
+
|
|
2098
|
+
class ExecutionProgress {
|
|
2099
|
+
friend class AsyncProgressWorker;
|
|
2100
|
+
public:
|
|
2101
|
+
void Signal() const;
|
|
2102
|
+
void Send(const T* data, size_t count) const;
|
|
2103
|
+
private:
|
|
2104
|
+
explicit ExecutionProgress(AsyncProgressWorker* worker) : _worker(worker) {}
|
|
2105
|
+
AsyncProgressWorker* const _worker;
|
|
2106
|
+
};
|
|
2107
|
+
|
|
2108
|
+
protected:
|
|
2109
|
+
explicit AsyncProgressWorker(const Function& callback);
|
|
2110
|
+
explicit AsyncProgressWorker(const Function& callback,
|
|
2111
|
+
const char* resource_name);
|
|
2112
|
+
explicit AsyncProgressWorker(const Function& callback,
|
|
2113
|
+
const char* resource_name,
|
|
2114
|
+
const Object& resource);
|
|
2115
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2116
|
+
const Function& callback);
|
|
2117
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2118
|
+
const Function& callback,
|
|
2119
|
+
const char* resource_name);
|
|
2120
|
+
explicit AsyncProgressWorker(const Object& receiver,
|
|
2121
|
+
const Function& callback,
|
|
2122
|
+
const char* resource_name,
|
|
2123
|
+
const Object& resource);
|
|
2124
|
+
|
|
2125
|
+
// Optional callback of Napi::ThreadSafeFunction only available after NAPI_VERSION 4.
|
|
2126
|
+
// Refs: https://github.com/nodejs/node/pull/27791
|
|
2127
|
+
#if NAPI_VERSION > 4
|
|
2128
|
+
explicit AsyncProgressWorker(Napi::Env env);
|
|
2129
|
+
explicit AsyncProgressWorker(Napi::Env env,
|
|
2130
|
+
const char* resource_name);
|
|
2131
|
+
explicit AsyncProgressWorker(Napi::Env env,
|
|
2132
|
+
const char* resource_name,
|
|
2133
|
+
const Object& resource);
|
|
2134
|
+
#endif
|
|
2135
|
+
|
|
2136
|
+
virtual void Execute(const ExecutionProgress& progress) = 0;
|
|
2137
|
+
virtual void OnProgress(const T* data, size_t count) = 0;
|
|
2138
|
+
|
|
2139
|
+
private:
|
|
2140
|
+
static void WorkProgress_(Napi::Env env, Napi::Function jsCallback, void* data);
|
|
2141
|
+
|
|
2142
|
+
void Execute() override;
|
|
2143
|
+
void Signal() const;
|
|
2144
|
+
void SendProgress_(const T* data, size_t count);
|
|
2145
|
+
|
|
2146
|
+
std::mutex _mutex;
|
|
2147
|
+
T* _asyncdata;
|
|
2148
|
+
size_t _asyncsize;
|
|
2149
|
+
ThreadSafeFunction _tsfn;
|
|
2032
2150
|
};
|
|
2033
2151
|
#endif
|
|
2034
2152
|
|
package/package.json
CHANGED
|
@@ -3,51 +3,206 @@
|
|
|
3
3
|
"url": "https://github.com/nodejs/node-addon-api/issues"
|
|
4
4
|
},
|
|
5
5
|
"contributors": [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
6
|
+
{
|
|
7
|
+
"name": "Abhishek Kumar Singh",
|
|
8
|
+
"url": "https://github.com/abhi11210646"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Alba Mendez",
|
|
12
|
+
"url": "https://github.com/jmendeth"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "Andrew Petersen",
|
|
16
|
+
"url": "https://github.com/kirbysayshi"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "Anisha Rohra",
|
|
20
|
+
"url": "https://github.com/anisha-rohra"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Anna Henningsen",
|
|
24
|
+
"url": "https://github.com/addaleax"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Arnaud Botella",
|
|
28
|
+
"url": "https://github.com/BotellaA"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Arunesh Chandra",
|
|
32
|
+
"url": "https://github.com/aruneshchandra"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Ben Berman",
|
|
36
|
+
"url": "https://github.com/rivertam"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "Benjamin Byholm",
|
|
40
|
+
"url": "https://github.com/kkoopa"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Bill Gallafent",
|
|
44
|
+
"url": "https://github.com/gallafent"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "Bruce A. MacNaughton",
|
|
48
|
+
"url": "https://github.com/bmacnaughton"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "Cory Mickelson",
|
|
52
|
+
"url": "https://github.com/corymickelson"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "David Halls",
|
|
56
|
+
"url": "https://github.com/davedoesdev"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "Dongjin Na",
|
|
60
|
+
"url": "https://github.com/nadongguri"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "Eric Bickle",
|
|
64
|
+
"url": "https://github.com/ebickle"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "Gabriel Schulhof",
|
|
68
|
+
"url": "https://github.com/gabrielschulhof"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "Gus Caplan",
|
|
72
|
+
"url": "https://github.com/devsnek"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "Hitesh Kanwathirtha",
|
|
76
|
+
"url": "https://github.com/digitalinfinity"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "Jake Barnes",
|
|
80
|
+
"url": "https://github.com/DuBistKomisch"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "Jake Yoon",
|
|
84
|
+
"url": "https://github.com/yjaeseok"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "Jason Ginchereau",
|
|
88
|
+
"url": "https://github.com/jasongin"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"name": "Jim Schlight",
|
|
92
|
+
"url": "https://github.com/jschlight"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "Jinho Bang",
|
|
96
|
+
"url": "https://github.com/romandev"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "joshgarde",
|
|
100
|
+
"url": "https://github.com/joshgarde"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "Kevin Eady",
|
|
104
|
+
"url": "https://github.com/KevinEady"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "Konstantin Tarkus",
|
|
108
|
+
"url": "https://github.com/koistya"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"name": "Kyle Farnung",
|
|
112
|
+
"url": "https://github.com/kfarnung"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"name": "legendecas",
|
|
116
|
+
"url": "https://github.com/legendecas"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "Luciano Martorella",
|
|
120
|
+
"url": "https://github.com/lmartorella"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "Mathias Küsel",
|
|
124
|
+
"url": "https://github.com/mathiask88"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "Matteo Collina",
|
|
128
|
+
"url": "https://github.com/mcollina"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "Michael Dawson",
|
|
132
|
+
"url": "https://github.com/mhdawson"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "Michael Price",
|
|
136
|
+
"url": "https://github.com/mikepricedev"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "Michele Campus",
|
|
140
|
+
"url": "https://github.com/kYroL01"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "Mikhail Cheshkov",
|
|
144
|
+
"url": "https://github.com/mcheshkov"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "Nicola Del Gobbo",
|
|
148
|
+
"url": "https://github.com/NickNaso"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "Nick Soggin",
|
|
152
|
+
"url": "https://github.com/iSkore"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "Nurbol Alpysbayev",
|
|
156
|
+
"url": "https://github.com/anurbol"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "Philipp Renoth",
|
|
160
|
+
"url": "https://github.com/DaAitch"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "Rolf Timmermans",
|
|
164
|
+
"url": "https://github.com/rolftimmermans"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"name": "Ross Weir",
|
|
168
|
+
"url": "https://github.com/ross-weir"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "Ryuichi Okumura",
|
|
172
|
+
"url": "https://github.com/okuryu"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "Sampson Gao",
|
|
176
|
+
"url": "https://github.com/sampsongao"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "Sam Roberts",
|
|
180
|
+
"url": "https://github.com/sam-github"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "Taylor Woll",
|
|
184
|
+
"url": "https://github.com/boingoing"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"name": "Thomas Gentilhomme",
|
|
188
|
+
"url": "https://github.com/fraxken"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "Tim Rach",
|
|
192
|
+
"url": "https://github.com/timrach"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "Tobias Nießen",
|
|
196
|
+
"url": "https://github.com/tniessen"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"name": "Tux3",
|
|
200
|
+
"url": "https://github.com/tux3"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "Yohei Kishimoto",
|
|
204
|
+
"url": "https://github.com/morokosi"
|
|
205
|
+
}
|
|
51
206
|
],
|
|
52
207
|
"dependencies": {},
|
|
53
208
|
"description": "Node.js API (N-API)",
|
|
@@ -56,7 +211,17 @@
|
|
|
56
211
|
},
|
|
57
212
|
"directories": {},
|
|
58
213
|
"homepage": "https://github.com/nodejs/node-addon-api",
|
|
59
|
-
"keywords": [
|
|
214
|
+
"keywords": [
|
|
215
|
+
"n-api",
|
|
216
|
+
"napi",
|
|
217
|
+
"addon",
|
|
218
|
+
"native",
|
|
219
|
+
"bindings",
|
|
220
|
+
"c",
|
|
221
|
+
"c++",
|
|
222
|
+
"nan",
|
|
223
|
+
"node-addon-api"
|
|
224
|
+
],
|
|
60
225
|
"license": "MIT",
|
|
61
226
|
"main": "index.js",
|
|
62
227
|
"name": "node-addon-api",
|
|
@@ -75,5 +240,5 @@
|
|
|
75
240
|
"dev:incremental": "node test",
|
|
76
241
|
"doc": "doxygen doc/Doxyfile"
|
|
77
242
|
},
|
|
78
|
-
"version": "
|
|
243
|
+
"version": "2.0.0"
|
|
79
244
|
}
|
package/src/node_api.cc
CHANGED
|
@@ -2238,7 +2238,7 @@ napi_status napi_get_value_string_latin1(napi_env env,
|
|
|
2238
2238
|
if (!buf) {
|
|
2239
2239
|
CHECK_ARG(env, result);
|
|
2240
2240
|
*result = val.As<v8::String>()->Length();
|
|
2241
|
-
} else
|
|
2241
|
+
} else {
|
|
2242
2242
|
int copied = val.As<v8::String>()->WriteOneByte(
|
|
2243
2243
|
reinterpret_cast<uint8_t*>(buf), 0, bufsize - 1,
|
|
2244
2244
|
v8::String::NO_NULL_TERMINATION);
|
|
@@ -2247,8 +2247,6 @@ napi_status napi_get_value_string_latin1(napi_env env,
|
|
|
2247
2247
|
if (result != nullptr) {
|
|
2248
2248
|
*result = copied;
|
|
2249
2249
|
}
|
|
2250
|
-
} else if (result != nullptr) {
|
|
2251
|
-
*result = 0;
|
|
2252
2250
|
}
|
|
2253
2251
|
|
|
2254
2252
|
return napi_clear_last_error(env);
|
|
@@ -2276,7 +2274,7 @@ napi_status napi_get_value_string_utf8(napi_env env,
|
|
|
2276
2274
|
if (!buf) {
|
|
2277
2275
|
CHECK_ARG(env, result);
|
|
2278
2276
|
*result = val.As<v8::String>()->Utf8Length();
|
|
2279
|
-
} else
|
|
2277
|
+
} else {
|
|
2280
2278
|
int copied = val.As<v8::String>()->WriteUtf8(
|
|
2281
2279
|
buf, bufsize - 1, nullptr, v8::String::REPLACE_INVALID_UTF8 |
|
|
2282
2280
|
v8::String::NO_NULL_TERMINATION);
|
|
@@ -2285,8 +2283,6 @@ napi_status napi_get_value_string_utf8(napi_env env,
|
|
|
2285
2283
|
if (result != nullptr) {
|
|
2286
2284
|
*result = copied;
|
|
2287
2285
|
}
|
|
2288
|
-
} else if (result != nullptr) {
|
|
2289
|
-
*result = 0;
|
|
2290
2286
|
}
|
|
2291
2287
|
|
|
2292
2288
|
return napi_clear_last_error(env);
|
|
@@ -2315,7 +2311,7 @@ napi_status napi_get_value_string_utf16(napi_env env,
|
|
|
2315
2311
|
CHECK_ARG(env, result);
|
|
2316
2312
|
// V8 assumes UTF-16 length is the same as the number of characters.
|
|
2317
2313
|
*result = val.As<v8::String>()->Length();
|
|
2318
|
-
} else
|
|
2314
|
+
} else {
|
|
2319
2315
|
int copied = val.As<v8::String>()->Write(
|
|
2320
2316
|
reinterpret_cast<uint16_t*>(buf), 0, bufsize - 1,
|
|
2321
2317
|
v8::String::NO_NULL_TERMINATION);
|
|
@@ -2324,8 +2320,6 @@ napi_status napi_get_value_string_utf16(napi_env env,
|
|
|
2324
2320
|
if (result != nullptr) {
|
|
2325
2321
|
*result = copied;
|
|
2326
2322
|
}
|
|
2327
|
-
} else if (result != nullptr) {
|
|
2328
|
-
*result = 0;
|
|
2329
2323
|
}
|
|
2330
2324
|
|
|
2331
2325
|
return napi_clear_last_error(env);
|