Skip to content

Commit 51ffe45

Browse files
NickNasomhdawson
authored andcommitted
doc: doc cleanup
- Some fix on bigint and dataview. - Add section dedicated to prebuild tools. PR-URL: #353 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 211ed38 commit 51ffe45

File tree

5 files changed

+62
-45
lines changed

5 files changed

+62
-45
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ to ideas specified in the **ECMA262 Language Specification**.
5959
- [Conversion tool](doc/conversion-tool.md)
6060
- [Checker tool](doc/checker-tool.md)
6161
- [Generator](doc/generator.md)
62+
- [Prebuild tools](doc/prebuild_tools.md)
6263

6364
<a name="api"></a>
6465

@@ -72,6 +73,7 @@ The following is the documentation for node-addon-api.
7273
- [String](doc/string.md)
7374
- [Name](doc/basic_types.md#name)
7475
- [Number](doc/number.md)
76+
- [BigInt](doc/bigint.md)
7577
- [Boolean](doc/boolean.md)
7678
- [Env](doc/env.md)
7779
- [Value](doc/value.md)

doc/bigint.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@ A JavaScript BigInt value.
77
### New
88

99
```cpp
10-
static BigInt New(Napi::Env env, int64_t value);
11-
static BigInt New(Napi::Env env, uint64_t value);
10+
static Napi::BigInt Napi::BigInt::New(Napi::Env env, int64_t value);
1211
```
1312
14-
- `[in] env`: The environment in which to construct the `BigInt` object.
13+
- `[in] env`: The environment in which to construct the `Napi::BigInt` object.
1514
- `[in] value`: The value the JavaScript `BigInt` will contain
1615
1716
These APIs convert the C `int64_t` and `uint64_t` types to the JavaScript
1817
`BigInt` type.
1918
2019
```cpp
21-
static BigInt New(Napi::Env env,
20+
static Napi::BigInt Napi::BigInt::New(Napi::Env env,
2221
int sign_bit,
2322
size_t word_count,
2423
const uint64_t* words);
2524
```
2625

27-
- `[in] env`: The environment in which to construct the `BigInt` object.
26+
- `[in] env`: The environment in which to construct the `Napi::BigInt` object.
2827
- `[in] sign_bit`: Determines if the resulting `BigInt` will be positive or negative.
2928
- `[in] word_count`: The length of the words array.
3029
- `[in] words`: An array of `uint64_t` little-endian 64-bit words.
@@ -43,24 +42,23 @@ Returns a new JavaScript `BigInt`.
4342
Napi::BigInt();
4443
```
4544

46-
Returns a new empty JavaScript `BigInt`.
45+
Returns a new empty JavaScript `Napi::BigInt`.
4746

4847
### Int64Value
4948

5049
```cpp
51-
int64_t Int64Value(bool* lossless) const;
50+
int64_t Napi::BitInt::Int64Value(bool* lossless) const;
5251
```
5352
54-
- `[out] lossless`: Indicates whether the `BigInt` value was converted
55-
losslessly.
53+
- `[out] lossless`: Indicates whether the `BigInt` value was converted losslessly.
5654
5755
Returns the C `int64_t` primitive equivalent of the given JavaScript
5856
`BigInt`. If needed it will truncate the value, setting lossless to false.
5957
6058
### Uint64Value
6159
6260
```cpp
63-
uint64_t Uint64Value(bool* lossless) const;
61+
uint64_t Napi::BigInt::Uint64Value(bool* lossless) const;
6462
```
6563

6664
- `[out] lossless`: Indicates whether the `BigInt` value was converted
@@ -72,15 +70,15 @@ Returns the C `uint64_t` primitive equivalent of the given JavaScript
7270
### WordCount
7371

7472
```cpp
75-
size_t WordCount() const;
73+
size_t Napi::BigInt::WordCount() const;
7674
```
7775

7876
Returns the number of words needed to store this `BigInt` value.
7977

8078
### ToWords
8179

8280
```cpp
83-
void ToWords(size_t* word_count, int* sign_bit, uint64_t* words);
81+
void Napi::BigInt::ToWords(size_t* word_count, int* sign_bit, uint64_t* words);
8482
```
8583
8684
- `[out] sign_bit`: Integer representing if the JavaScript `BigInt` is positive

doc/dataview.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class.
1111
Allocates a new `Napi::DataView` instance with a given `Napi::ArrayBuffer`.
1212

1313
```cpp
14-
static Napi::DataView New(napi_env env, Napi::ArrayBuffer arrayBuffer);
14+
static Napi::DataView Napi::DataView::New(napi_env env, Napi::ArrayBuffer arrayBuffer);
1515
```
1616
1717
- `[in] env`: The environment in which to create the `Napi::DataView` instance.
@@ -24,7 +24,7 @@ Returns a new `Napi::DataView` instance.
2424
Allocates a new `Napi::DataView` instance with a given `Napi::ArrayBuffer`.
2525
2626
```cpp
27-
static Napi::DataView New(napi_env env, Napi::ArrayBuffer arrayBuffer, size_t byteOffset);
27+
static Napi::DataView Napi::DataView::New(napi_env env, Napi::ArrayBuffer arrayBuffer, size_t byteOffset);
2828
```
2929

3030
- `[in] env`: The environment in which to create the `Napi::DataView` instance.
@@ -38,7 +38,7 @@ Returns a new `Napi::DataView` instance.
3838
Allocates a new `Napi::DataView` instance with a given `Napi::ArrayBuffer`.
3939

4040
```cpp
41-
static Napi::DataView New(napi_env env, Napi::ArrayBuffer arrayBuffer, size_t byteOffset, size_t byteLength);
41+
static Napi::DataView Napi::DataView::New(napi_env env, Napi::ArrayBuffer arrayBuffer, size_t byteOffset, size_t byteLength);
4242
```
4343
4444
- `[in] env`: The environment in which to create the `Napi::DataView` instance.
@@ -53,15 +53,15 @@ Returns a new `Napi::DataView` instance.
5353
Initializes an empty instance of the `Napi::DataView` class.
5454
5555
```cpp
56-
DataView();
56+
Napi::DataView();
5757
```
5858

5959
### Constructor
6060

6161
Initializes a wrapper instance of an existing `Napi::DataView` instance.
6262

6363
```cpp
64-
DataView(napi_env env, napi_value value);
64+
Napi::DataView(napi_env env, napi_value value);
6565
```
6666
6767
- `[in] env`: The environment in which to create the `Napi::DataView` instance.
@@ -70,41 +70,41 @@ DataView(napi_env env, napi_value value);
7070
### ArrayBuffer
7171
7272
```cpp
73-
Napi::ArrayBuffer ArrayBuffer() const;
73+
Napi::ArrayBuffer Napi::DataView::ArrayBuffer() const;
7474
```
7575

7676
Returns the backing array buffer.
7777

7878
### ByteOffset
7979

8080
```cpp
81-
size_t ByteOffset() const;
81+
size_t Napi::DataView::ByteOffset() const;
8282
```
8383

8484
Returns the offset into the `Napi::DataView` where the array starts, in bytes.
8585

8686
### ByteLength
8787

8888
```cpp
89-
size_t ByteLength() const;
89+
size_t Napi::DataView::ByteLength() const;
9090
```
9191

9292
Returns the length of the array, in bytes.
9393

9494
### GetFloat32
9595

9696
```cpp
97-
float GetFloat32(size_t byteOffset) const;
97+
float Napi::DataView::GetFloat32(size_t byteOffset) const;
9898
```
9999
100100
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
101101
102-
Returns a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`.
102+
Returns a signed 32-bit float (float) at the specified byte offset from the start of the `Napi::DataView`.
103103
104104
### GetFloat64
105105
106106
```cpp
107-
double GetFloat64(size_t byteOffset) const;
107+
double Napi::DataView::GetFloat64(size_t byteOffset) const;
108108
```
109109

110110
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -114,7 +114,7 @@ Returns a signed 64-bit float (double) at the specified byte offset from the sta
114114
### GetInt8
115115

116116
```cpp
117-
int8_t GetInt8(size_t byteOffset) const;
117+
int8_t Napi::DataView::GetInt8(size_t byteOffset) const;
118118
```
119119
120120
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -124,7 +124,7 @@ Returns a signed 8-bit integer (byte) at the specified byte offset from the star
124124
### GetInt16
125125
126126
```cpp
127-
int16_t GetInt16(size_t byteOffset) const;
127+
int16_t Napi::DataView::GetInt16(size_t byteOffset) const;
128128
```
129129

130130
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -134,7 +134,7 @@ Returns a signed 16-bit integer (short) at the specified byte offset from the st
134134
### GetInt32
135135

136136
```cpp
137-
int32_t GetInt32(size_t byteOffset) const;
137+
int32_t Napi::DataView::GetInt32(size_t byteOffset) const;
138138
```
139139
140140
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -144,7 +144,7 @@ Returns a signed 32-bit integer (long) at the specified byte offset from the sta
144144
### GetUint8
145145
146146
```cpp
147-
uint8_t GetUint8(size_t byteOffset) const;
147+
uint8_t Napi::DataView::GetUint8(size_t byteOffset) const;
148148
```
149149

150150
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -154,7 +154,7 @@ Returns a unsigned 8-bit integer (unsigned byte) at the specified byte offset fr
154154
### GetUint16
155155

156156
```cpp
157-
uint16_t GetUint16(size_t byteOffset) const;
157+
uint16_t Napi::DataView::GetUint16(size_t byteOffset) const;
158158
```
159159
160160
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -164,7 +164,7 @@ Returns a unsigned 16-bit integer (unsigned short) at the specified byte offset
164164
### GetUint32
165165
166166
```cpp
167-
uint32_t GetUint32(size_t byteOffset) const;
167+
uint32_t Napi::DataView::GetUint32(size_t byteOffset) const;
168168
```
169169

170170
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -174,7 +174,7 @@ Returns a unsigned 32-bit integer (unsigned long) at the specified byte offset f
174174
### SetFloat32
175175

176176
```cpp
177-
void SetFloat32(size_t byteOffset, float value) const;
177+
void Napi::DataView::SetFloat32(size_t byteOffset, float value) const;
178178
```
179179
180180
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -183,7 +183,7 @@ void SetFloat32(size_t byteOffset, float value) const;
183183
### SetFloat64
184184
185185
```cpp
186-
void SetFloat64(size_t byteOffset, double value) const;
186+
void Napi::DataView::SetFloat64(size_t byteOffset, double value) const;
187187
```
188188

189189
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -192,7 +192,7 @@ void SetFloat64(size_t byteOffset, double value) const;
192192
### SetInt8
193193

194194
```cpp
195-
void SetInt8(size_t byteOffset, int8_t value) const;
195+
void Napi::DataView::SetInt8(size_t byteOffset, int8_t value) const;
196196
```
197197
198198
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -201,7 +201,7 @@ void SetInt8(size_t byteOffset, int8_t value) const;
201201
### SetInt16
202202
203203
```cpp
204-
void SetInt16(size_t byteOffset, int16_t value) const;
204+
void Napi::DataView::SetInt16(size_t byteOffset, int16_t value) const;
205205
```
206206

207207
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -210,7 +210,7 @@ void SetInt16(size_t byteOffset, int16_t value) const;
210210
### SetInt32
211211

212212
```cpp
213-
void SetInt32(size_t byteOffset, int32_t value) const;
213+
void Napi::DataView::SetInt32(size_t byteOffset, int32_t value) const;
214214
```
215215
216216
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -219,7 +219,7 @@ void SetInt32(size_t byteOffset, int32_t value) const;
219219
### SetUint8
220220
221221
```cpp
222-
void SetUint8(size_t byteOffset, uint8_t value) const;
222+
void Napi::DataView::SetUint8(size_t byteOffset, uint8_t value) const;
223223
```
224224

225225
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -228,7 +228,7 @@ void SetUint8(size_t byteOffset, uint8_t value) const;
228228
### SetUint16
229229

230230
```cpp
231-
void SetUint16(size_t byteOffset, uint16_t value) const;
231+
void Napi::DataView::SetUint16(size_t byteOffset, uint16_t value) const;
232232
```
233233
234234
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.
@@ -237,7 +237,7 @@ void SetUint16(size_t byteOffset, uint16_t value) const;
237237
### SetUint32
238238
239239
```cpp
240-
void SetUint32(size_t byteOffset, uint32_t value) const;
240+
void Napi::DataView::SetUint32(size_t byteOffset, uint32_t value) const;
241241
```
242242

243243
- `[in] byteOffset`: The offset, in byte, from the start of the view where to read the data.

doc/prebuild_tools.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Prebuild tools
2+
3+
The distribution of a native add-on is just as important as its implementation.
4+
In order to install a native add-on it's important to have all the necessary
5+
dependencies installed and well configured (see the [setup](doc/setum.md) section).
6+
The end-user will need to compile the add-on when they will do an `npm install`
7+
and in some cases this could create problems. To avoid the compilation process it's
8+
possible to ditribute the native add-on in pre-built form for different platform
9+
and architectures. The prebuild tools help to create and distrubute the pre-built
10+
form of a native add-on.
11+
12+
The following list report two of the tools that are compatible with **N-API**:
13+
14+
- **[node-pre-gyp](https://www.npmjs.com/package/node-pre-gyp)**
15+
- **[prebuild](https://www.npmjs.com/package/prebuild)**
16+
- **[prebuildify](https://www.npmjs.com/package/prebuildify)**

doc/working_with_javascript_values.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
`node-addon-api` provides a set of classes that allow to create and manage
44
JavaScript object:
55

6-
- [Function](doc/function.md)
7-
- [FunctionReference](doc/function_reference.md)
8-
- [ObjectWrap](doc/object_wrap.md)
9-
- [ClassPropertyDescriptor](doc/class_property_descriptor.md)
10-
- [Buffer](doc/buffer.md)
11-
- [ArrayBuffer](doc/array_buffer.md)
12-
- [TypedArray](doc/typed_array.md)
13-
- [TypedArrayOf](doc/typed_array_of.md)
6+
- [Function](function.md)
7+
- [FunctionReference](function_reference.md)
8+
- [ObjectWrap](object_wrap.md)
9+
- [ClassPropertyDescriptor](class_property_descriptor.md)
10+
- [Buffer](buffer.md)
11+
- [ArrayBuffer](array_buffer.md)
12+
- [TypedArray](typed_array.md)
13+
- [TypedArrayOf](typed_array_of.md)
14+
- [DataView](dataview.md)

0 commit comments

Comments
 (0)