Skip to content

Commit

Permalink
doc: first pass on objectwrap documentation
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node-addon-api#321
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
kevindavies8 committed Sep 18, 2018
1 parent 285e4ff commit 6fea53b
Show file tree
Hide file tree
Showing 2 changed files with 448 additions and 17 deletions.
39 changes: 35 additions & 4 deletions doc/class_property_descriptor.md
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`
Loading

0 comments on commit 6fea53b

Please sign in to comment.