Skip to content

Commit 100d0a7

Browse files
NickNasomhdawson
authored andcommitted
doc: first pass on objectwrap documentation
PR-URL: #321 Reviewed-By: Michael Dawson <[email protected]>
1 parent c7d5418 commit 100d0a7

File tree

2 files changed

+448
-17
lines changed

2 files changed

+448
-17
lines changed

doc/class_property_descriptor.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
1-
# Class propertry and descriptior
1+
# Class propertry and descriptor
22

3-
You are reading a draft of the next documentation and it's in continuous update so
4-
if you don't find what you need please refer to:
5-
[C++ wrapper classes for the ABI-stable C APIs for Node.js](https://nodejs.github.io/node-addon-api/)
3+
Property descriptor for use with `Napi::ObjectWrap::DefineClass()`.
4+
This is different from the standalone `Napi::PropertyDescriptor` because it is
5+
specific to each `Napi::ObjectWrap<T>` subclass.
6+
This prevents using descriptors from a different class when defining a new class
7+
(preventing the callbacks from having incorrect `this` pointers).
8+
9+
## Methods
10+
11+
### Contructor
12+
13+
Creates new instance of `Napi::ClassPropertyDescriptor` descriptor object.
14+
15+
```cpp
16+
Napi::ClassPropertyDescriptor(napi_property_descriptor desc) : _desc(desc) {}
17+
```
18+
19+
- `[in] desc`: The `napi_property_descriptor`
20+
21+
Returns new instance of `Napi::ClassPropertyDescriptor` that is used as property descriptor
22+
inside the `Napi::ObjectWrap<T>` class.
23+
24+
### Operator
25+
26+
```cpp
27+
operator napi_property_descriptor&() { return _desc; }
28+
```
29+
30+
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
31+
32+
```cpp
33+
operator const napi_property_descriptor&() const { return _desc; }
34+
```
35+
36+
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`

0 commit comments

Comments
 (0)