-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleaning the documentation. * Remove comments about things under development. * Include Napi namespace consistently. PR-URL: nodejs/node-addon-api#335 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
- Loading branch information
Showing
33 changed files
with
754 additions
and
763 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,129 @@ | ||
# ArrayBuffer | ||
|
||
The `ArrayBuffer` class corresponds to the | ||
The `Napi::ArrayBuffer` class corresponds to the | ||
[JavaScript `ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) | ||
class. | ||
|
||
## Methods | ||
|
||
### New | ||
|
||
Allocates a new `ArrayBuffer` instance with a given length. | ||
Allocates a new `Napi::ArrayBuffer` instance with a given length. | ||
|
||
```cpp | ||
static ArrayBuffer New(napi_env env, size_t byteLength); | ||
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, size_t byteLength); | ||
``` | ||
- `[in] env`: The environment in which to create the `ArrayBuffer` instance. | ||
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance. | ||
- `[in] byteLength`: The length to be allocated, in bytes. | ||
Returns a new `ArrayBuffer` instance. | ||
Returns a new `Napi::ArrayBuffer` instance. | ||
### New | ||
Wraps the provided external data into a new `ArrayBuffer` instance. | ||
Wraps the provided external data into a new `Napi::ArrayBuffer` instance. | ||
The `ArrayBuffer` instance does not assume ownership for the data and expects it | ||
to be valid for the lifetime of the instance. Since the `ArrayBuffer` is subject | ||
to garbage collection this overload is only suitable for data which is static | ||
and never needs to be freed. | ||
The `Napi::ArrayBuffer` instance does not assume ownership for the data and | ||
expects it to be valid for the lifetime of the instance. Since the | ||
`Napi::ArrayBuffer` is subject to garbage collection this overload is only | ||
suitable for data which is static and never needs to be freed. | ||
```cpp | ||
static ArrayBuffer New(napi_env env, void* externalData, size_t byteLength); | ||
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, void* externalData, size_t byteLength); | ||
``` | ||
|
||
- `[in] env`: The environment in which to create the `ArrayBuffer` instance. | ||
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance. | ||
- `[in] externalData`: The pointer to the external data to wrap. | ||
- `[in] byteLength`: The length of the `externalData`, in bytes. | ||
|
||
Returns a new `ArrayBuffer` instance. | ||
Returns a new `Napi::ArrayBuffer` instance. | ||
|
||
### New | ||
|
||
Wraps the provided external data into a new `ArrayBuffer` instance. | ||
Wraps the provided external data into a new `Napi::ArrayBuffer` instance. | ||
|
||
The `ArrayBuffer` instance does not assume ownership for the data and expects it | ||
to be valid for the lifetime of the instance. The data can only be freed once | ||
the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been | ||
released. | ||
The `Napi::ArrayBuffer` instance does not assume ownership for the data and | ||
expects it to be valid for the lifetime of the instance. The data can only be | ||
freed once the `finalizeCallback` is invoked to indicate that the | ||
`Napi::ArrayBuffer` has been released. | ||
|
||
```cpp | ||
template <typename Finalizer> | ||
static ArrayBuffer New(napi_env env, | ||
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, | ||
void* externalData, | ||
size_t byteLength, | ||
Finalizer finalizeCallback); | ||
``` | ||
- `[in] env`: The environment in which to create the `ArrayBuffer` instance. | ||
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance. | ||
- `[in] externalData`: The pointer to the external data to wrap. | ||
- `[in] byteLength`: The length of the `externalData`, in bytes. | ||
- `[in] finalizeCallback`: A function to be called when the `ArrayBuffer` is | ||
- `[in] finalizeCallback`: A function to be called when the `Napi::ArrayBuffer` is | ||
destroyed. It must implement `operator()`, accept a `void*` (which is the | ||
`externalData` pointer), and return `void`. | ||
Returns a new `ArrayBuffer` instance. | ||
Returns a new `Napi::ArrayBuffer` instance. | ||
### New | ||
Wraps the provided external data into a new `ArrayBuffer` instance. | ||
Wraps the provided external data into a new `Napi::ArrayBuffer` instance. | ||
The `ArrayBuffer` instance does not assume ownership for the data and expects it | ||
The `Napi::ArrayBuffer` instance does not assume ownership for the data and expects it | ||
to be valid for the lifetime of the instance. The data can only be freed once | ||
the `finalizeCallback` is invoked to indicate that the `ArrayBuffer` has been | ||
the `finalizeCallback` is invoked to indicate that the `Napi::ArrayBuffer` has been | ||
released. | ||
```cpp | ||
template <typename Finalizer, typename Hint> | ||
static ArrayBuffer New(napi_env env, | ||
static Napi::ArrayBuffer Napi::ArrayBuffer::New(napi_env env, | ||
void* externalData, | ||
size_t byteLength, | ||
Finalizer finalizeCallback, | ||
Hint* finalizeHint); | ||
``` | ||
|
||
- `[in] env`: The environment in which to create the `ArrayBuffer` instance. | ||
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance. | ||
- `[in] externalData`: The pointer to the external data to wrap. | ||
- `[in] byteLength`: The length of the `externalData`, in bytes. | ||
- `[in] finalizeCallback`: The function to be called when the `ArrayBuffer` is | ||
- `[in] finalizeCallback`: The function to be called when the `Napi::ArrayBuffer` is | ||
destroyed. It must implement `operator()`, accept a `void*` (which is the | ||
`externalData` pointer) and `Hint*`, and return `void`. | ||
- `[in] finalizeHint`: The hint to be passed as the second parameter of the | ||
finalize callback. | ||
|
||
Returns a new `ArrayBuffer` instance. | ||
Returns a new `Napi::ArrayBuffer` instance. | ||
|
||
### Constructor | ||
|
||
Initializes an empty instance of the `ArrayBuffer` class. | ||
Initializes an empty instance of the `Napi::ArrayBuffer` class. | ||
|
||
```cpp | ||
ArrayBuffer(); | ||
Napi::ArrayBuffer::ArrayBuffer(); | ||
``` | ||
|
||
### Constructor | ||
|
||
Initializes a wrapper instance of an existing `ArrayBuffer` object. | ||
Initializes a wrapper instance of an existing `Napi::ArrayBuffer` object. | ||
|
||
```cpp | ||
ArrayBuffer(napi_env env, napi_value value); | ||
Napi::ArrayBuffer::ArrayBuffer(napi_env env, napi_value value); | ||
``` | ||
- `[in] env`: The environment in which to create the `ArrayBuffer` instance. | ||
- `[in] value`: The `ArrayBuffer` reference to wrap. | ||
- `[in] env`: The environment in which to create the `Napi::ArrayBuffer` instance. | ||
- `[in] value`: The `Napi::ArrayBuffer` reference to wrap. | ||
### ByteLength | ||
```cpp | ||
size_t ByteLength() const; | ||
size_t Napi::ArrayBuffer::ByteLength() const; | ||
``` | ||
|
||
Returns the length of the wrapped data, in bytes. | ||
|
||
### Data | ||
|
||
```cpp | ||
T* Data() const; | ||
T* Napi::ArrayBuffer::Data() const; | ||
``` | ||
|
||
Returns a pointer the wrapped data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.