-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: first pass on objectwrap documentation
PR-URL: #321 Reviewed-By: Michael Dawson <[email protected]>
- Loading branch information
Showing
2 changed files
with
448 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
# Class propertry and descriptior | ||
# Class propertry and descriptor | ||
|
||
You are reading a draft of the next documentation and it's in continuous update so | ||
if you don't find what you need please refer to: | ||
[C++ wrapper classes for the ABI-stable C APIs for Node.js](https://nodejs.github.io/node-addon-api/) | ||
Property descriptor for use with `Napi::ObjectWrap::DefineClass()`. | ||
This is different from the standalone `Napi::PropertyDescriptor` because it is | ||
specific to each `Napi::ObjectWrap<T>` subclass. | ||
This prevents using descriptors from a different class when defining a new class | ||
(preventing the callbacks from having incorrect `this` pointers). | ||
|
||
## Methods | ||
|
||
### Contructor | ||
|
||
Creates new instance of `Napi::ClassPropertyDescriptor` descriptor object. | ||
|
||
```cpp | ||
Napi::ClassPropertyDescriptor(napi_property_descriptor desc) : _desc(desc) {} | ||
``` | ||
- `[in] desc`: The `napi_property_descriptor` | ||
Returns new instance of `Napi::ClassPropertyDescriptor` that is used as property descriptor | ||
inside the `Napi::ObjectWrap<T>` class. | ||
### Operator | ||
```cpp | ||
operator napi_property_descriptor&() { return _desc; } | ||
``` | ||
|
||
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor` | ||
|
||
```cpp | ||
operator const napi_property_descriptor&() const { return _desc; } | ||
``` | ||
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor` |
Oops, something went wrong.