Skip to content

Commit 15b9d14

Browse files
authored
Merge pull request #1 from NickNaso/main
Initial scaffolding for the project.
2 parents 0403e62 + 1847e4f commit 15b9d14

File tree

11 files changed

+1397
-0
lines changed

11 files changed

+1397
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# node-api-headers Changelog

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Code of Conduct
2+
3+
The Node.js Code of Conduct, which applies to this project, can be found at
4+
https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md.

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Developer's Certificate of Origin 1.1
2+
3+
By making a contribution to this project, I certify that:
4+
5+
* (a) The contribution was created in whole or in part by me and I
6+
have the right to submit it under the open source license
7+
indicated in the file; or
8+
9+
* (b) The contribution is based upon previous work that, to the best
10+
of my knowledge, is covered under an appropriate open source
11+
license and I have the right under that license to submit that
12+
work with modifications, whether created in whole or in part
13+
by me, under the same open source license (unless I am
14+
permitted to submit under a different license), as indicated
15+
in the file; or
16+
17+
* (c) The contribution was provided directly to me by some other
18+
person who certified (a), (b) or (c) and I have not modified
19+
it.
20+
21+
* (d) I understand and agree that this project and the contribution
22+
are public and that a record of the contribution (including all
23+
personal information I submit with it, including my sign-off) is
24+
maintained indefinitely and may be redistributed consistent with
25+
this project or the open source license(s) involved.
26+
27+
## Moderation Policy
28+
29+
The [Node.js Moderation Policy] applies to this project.
30+
31+
[Node.js Moderation Policy]:
32+
https://github.com/nodejs/admin/blob/master/Moderation-Policy.md

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# node-api-headers
2+
3+
- **[Introduction](#introduction)**
4+
- **[Contributing](CONTRIBUTING.md)**
5+
- **[Code of Conduct](CODE_OF_CONDUCT.md)**
6+
- **[Team](#team)**
7+
- **[License](#license)**
8+
9+
<a name="introduction"></a>
10+
11+
## Introduction
12+
13+
The **node-api-headers** moldule contains the header files for the C based
14+
Node-API provided by Node.js.
15+
16+
<a name="team"></a>
17+
18+
## Team members
19+
20+
### Active
21+
| Name | GitHub Link |
22+
| ------------------- | ----------------------------------------------------- |
23+
| Anna Henningsen | [addaleax](https://github.com/addaleax) |
24+
| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
25+
| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
26+
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
27+
| Jim Schlight | [jschlight](https://github.com/jschlight) |
28+
| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
29+
| Kevin Eady | [KevinEady](https://github.com/KevinEady)
30+
| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
31+
32+
<a name="license"></a>
33+
34+
Licensed under [MIT](./LICENSE.md)

include/js_native_api.h

Lines changed: 555 additions & 0 deletions
Large diffs are not rendered by default.

include/js_native_api_types.h

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#ifndef SRC_JS_NATIVE_API_TYPES_H_
2+
#define SRC_JS_NATIVE_API_TYPES_H_
3+
4+
// This file needs to be compatible with C compilers.
5+
// This is a public include file, and these includes have essentially
6+
// became part of it's API.
7+
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
8+
#include <stdint.h> // NOLINT(modernize-deprecated-headers)
9+
10+
#if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
11+
typedef uint16_t char16_t;
12+
#endif
13+
14+
// JSVM API types are all opaque pointers for ABI stability
15+
// typedef undefined structs instead of void* for compile time type safety
16+
typedef struct napi_env__* napi_env;
17+
typedef struct napi_value__* napi_value;
18+
typedef struct napi_ref__* napi_ref;
19+
typedef struct napi_handle_scope__* napi_handle_scope;
20+
typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
21+
typedef struct napi_callback_info__* napi_callback_info;
22+
typedef struct napi_deferred__* napi_deferred;
23+
24+
typedef enum {
25+
napi_default = 0,
26+
napi_writable = 1 << 0,
27+
napi_enumerable = 1 << 1,
28+
napi_configurable = 1 << 2,
29+
30+
// Used with napi_define_class to distinguish static properties
31+
// from instance properties. Ignored by napi_define_properties.
32+
napi_static = 1 << 10,
33+
34+
#if NAPI_VERSION >= 8
35+
// Default for class methods.
36+
napi_default_method = napi_writable | napi_configurable,
37+
38+
// Default for object properties, like in JS obj[prop].
39+
napi_default_jsproperty = napi_writable |
40+
napi_enumerable |
41+
napi_configurable,
42+
#endif // NAPI_VERSION >= 8
43+
} napi_property_attributes;
44+
45+
typedef enum {
46+
// ES6 types (corresponds to typeof)
47+
napi_undefined,
48+
napi_null,
49+
napi_boolean,
50+
napi_number,
51+
napi_string,
52+
napi_symbol,
53+
napi_object,
54+
napi_function,
55+
napi_external,
56+
napi_bigint,
57+
} napi_valuetype;
58+
59+
typedef enum {
60+
napi_int8_array,
61+
napi_uint8_array,
62+
napi_uint8_clamped_array,
63+
napi_int16_array,
64+
napi_uint16_array,
65+
napi_int32_array,
66+
napi_uint32_array,
67+
napi_float32_array,
68+
napi_float64_array,
69+
napi_bigint64_array,
70+
napi_biguint64_array,
71+
} napi_typedarray_type;
72+
73+
typedef enum {
74+
napi_ok,
75+
napi_invalid_arg,
76+
napi_object_expected,
77+
napi_string_expected,
78+
napi_name_expected,
79+
napi_function_expected,
80+
napi_number_expected,
81+
napi_boolean_expected,
82+
napi_array_expected,
83+
napi_generic_failure,
84+
napi_pending_exception,
85+
napi_cancelled,
86+
napi_escape_called_twice,
87+
napi_handle_scope_mismatch,
88+
napi_callback_scope_mismatch,
89+
napi_queue_full,
90+
napi_closing,
91+
napi_bigint_expected,
92+
napi_date_expected,
93+
napi_arraybuffer_expected,
94+
napi_detachable_arraybuffer_expected,
95+
napi_would_deadlock // unused
96+
} napi_status;
97+
// Note: when adding a new enum value to `napi_status`, please also update
98+
// * `const int last_status` in the definition of `napi_get_last_error_info()'
99+
// in file js_native_api_v8.cc.
100+
// * `const char* error_messages[]` in file js_native_api_v8.cc with a brief
101+
// message explaining the error.
102+
// * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
103+
// added value(s).
104+
105+
typedef napi_value (*napi_callback)(napi_env env,
106+
napi_callback_info info);
107+
typedef void (*napi_finalize)(napi_env env,
108+
void* finalize_data,
109+
void* finalize_hint);
110+
111+
typedef struct {
112+
// One of utf8name or name should be NULL.
113+
const char* utf8name;
114+
napi_value name;
115+
116+
napi_callback method;
117+
napi_callback getter;
118+
napi_callback setter;
119+
napi_value value;
120+
121+
napi_property_attributes attributes;
122+
void* data;
123+
} napi_property_descriptor;
124+
125+
typedef struct {
126+
const char* error_message;
127+
void* engine_reserved;
128+
uint32_t engine_error_code;
129+
napi_status error_code;
130+
} napi_extended_error_info;
131+
132+
#if NAPI_VERSION >= 6
133+
typedef enum {
134+
napi_key_include_prototypes,
135+
napi_key_own_only
136+
} napi_key_collection_mode;
137+
138+
typedef enum {
139+
napi_key_all_properties = 0,
140+
napi_key_writable = 1,
141+
napi_key_enumerable = 1 << 1,
142+
napi_key_configurable = 1 << 2,
143+
napi_key_skip_strings = 1 << 3,
144+
napi_key_skip_symbols = 1 << 4
145+
} napi_key_filter;
146+
147+
typedef enum {
148+
napi_key_keep_numbers,
149+
napi_key_numbers_to_strings
150+
} napi_key_conversion;
151+
#endif // NAPI_VERSION >= 6
152+
153+
#if NAPI_VERSION >= 8
154+
typedef struct {
155+
uint64_t lower;
156+
uint64_t upper;
157+
} napi_type_tag;
158+
#endif // NAPI_VERSION >= 8
159+
160+
#endif // SRC_JS_NATIVE_API_TYPES_H_

0 commit comments

Comments
 (0)