@lynx-js/lynx-library-headers 0.0.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +53 -0
  2. package/include/base/include/value/lynx_api_types.h +57 -0
  3. package/include/base/include/value/lynx_value_api.h +204 -0
  4. package/include/base/include/value/lynx_value_types.h +73 -0
  5. package/include/capi/lynx_env_capi.h +47 -0
  6. package/include/capi/lynx_event_reporter_service_capi.h +67 -0
  7. package/include/capi/lynx_export.h +27 -0
  8. package/include/capi/lynx_extension_module_capi.h +148 -0
  9. package/include/capi/lynx_extension_module_types_capi.h +17 -0
  10. package/include/capi/lynx_generic_resource_fetcher_capi.h +124 -0
  11. package/include/capi/lynx_group_capi.h +42 -0
  12. package/include/capi/lynx_http_service_capi.h +113 -0
  13. package/include/capi/lynx_load_meta_capi.h +52 -0
  14. package/include/capi/lynx_log_capi.h +69 -0
  15. package/include/capi/lynx_memory_capi.h +28 -0
  16. package/include/capi/lynx_native_module_capi.h +51 -0
  17. package/include/capi/lynx_native_view_capi.h +163 -0
  18. package/include/capi/lynx_resource_request_capi.h +71 -0
  19. package/include/capi/lynx_resource_response_capi.h +92 -0
  20. package/include/capi/lynx_runtime_lifecycle_observer_capi.h +62 -0
  21. package/include/capi/lynx_security_service_capi.h +52 -0
  22. package/include/capi/lynx_service_center_capi.h +50 -0
  23. package/include/capi/lynx_template_bundle_capi.h +39 -0
  24. package/include/capi/lynx_template_data_capi.h +33 -0
  25. package/include/capi/lynx_trace_capi.h +62 -0
  26. package/include/capi/lynx_trail_service_capi.h +35 -0
  27. package/include/capi/lynx_types.h +750 -0
  28. package/include/capi/lynx_update_meta_capi.h +33 -0
  29. package/include/capi/lynx_view_builder_capi.h +113 -0
  30. package/include/capi/lynx_view_capi.h +174 -0
  31. package/include/capi/lynx_view_client_capi.h +81 -0
  32. package/include/capi/lynx_vsync_monitor_capi.h +38 -0
  33. package/include/capi/lynx_windowless_renderer_capi.h +213 -0
  34. package/include/js_native_api.h +608 -0
  35. package/include/js_native_api_types.h +202 -0
  36. package/include/lynx/base/include/value/lynx_api_types.h +57 -0
  37. package/include/lynx/base/include/value/lynx_value_api.h +204 -0
  38. package/include/lynx/base/include/value/lynx_value_types.h +73 -0
  39. package/include/lynx/extension.h +6 -0
  40. package/include/lynx/platform/embedder/public/capi/lynx_env_capi.h +47 -0
  41. package/include/lynx/platform/embedder/public/capi/lynx_event_reporter_service_capi.h +67 -0
  42. package/include/lynx/platform/embedder/public/capi/lynx_export.h +27 -0
  43. package/include/lynx/platform/embedder/public/capi/lynx_extension_module_capi.h +148 -0
  44. package/include/lynx/platform/embedder/public/capi/lynx_extension_module_types_capi.h +17 -0
  45. package/include/lynx/platform/embedder/public/capi/lynx_generic_resource_fetcher_capi.h +124 -0
  46. package/include/lynx/platform/embedder/public/capi/lynx_group_capi.h +42 -0
  47. package/include/lynx/platform/embedder/public/capi/lynx_http_service_capi.h +113 -0
  48. package/include/lynx/platform/embedder/public/capi/lynx_load_meta_capi.h +52 -0
  49. package/include/lynx/platform/embedder/public/capi/lynx_log_capi.h +69 -0
  50. package/include/lynx/platform/embedder/public/capi/lynx_memory_capi.h +28 -0
  51. package/include/lynx/platform/embedder/public/capi/lynx_native_module_capi.h +51 -0
  52. package/include/lynx/platform/embedder/public/capi/lynx_native_view_capi.h +163 -0
  53. package/include/lynx/platform/embedder/public/capi/lynx_resource_request_capi.h +71 -0
  54. package/include/lynx/platform/embedder/public/capi/lynx_resource_response_capi.h +92 -0
  55. package/include/lynx/platform/embedder/public/capi/lynx_runtime_lifecycle_observer_capi.h +62 -0
  56. package/include/lynx/platform/embedder/public/capi/lynx_security_service_capi.h +52 -0
  57. package/include/lynx/platform/embedder/public/capi/lynx_service_center_capi.h +50 -0
  58. package/include/lynx/platform/embedder/public/capi/lynx_template_bundle_capi.h +39 -0
  59. package/include/lynx/platform/embedder/public/capi/lynx_template_data_capi.h +33 -0
  60. package/include/lynx/platform/embedder/public/capi/lynx_trace_capi.h +62 -0
  61. package/include/lynx/platform/embedder/public/capi/lynx_trail_service_capi.h +35 -0
  62. package/include/lynx/platform/embedder/public/capi/lynx_types.h +750 -0
  63. package/include/lynx/platform/embedder/public/capi/lynx_update_meta_capi.h +33 -0
  64. package/include/lynx/platform/embedder/public/capi/lynx_view_builder_capi.h +113 -0
  65. package/include/lynx/platform/embedder/public/capi/lynx_view_capi.h +174 -0
  66. package/include/lynx/platform/embedder/public/capi/lynx_view_client_capi.h +81 -0
  67. package/include/lynx/platform/embedder/public/capi/lynx_vsync_monitor_capi.h +38 -0
  68. package/include/lynx/platform/embedder/public/capi/lynx_windowless_renderer_capi.h +213 -0
  69. package/include/lynx/platform/embedder/public/lynx_env.h +104 -0
  70. package/include/lynx/platform/embedder/public/lynx_event_reporter_service.h +96 -0
  71. package/include/lynx/platform/embedder/public/lynx_event_simulation_proxy.h +31 -0
  72. package/include/lynx/platform/embedder/public/lynx_extension_module.h +521 -0
  73. package/include/lynx/platform/embedder/public/lynx_generic_resource_fetcher.h +178 -0
  74. package/include/lynx/platform/embedder/public/lynx_group.h +70 -0
  75. package/include/lynx/platform/embedder/public/lynx_http_service.h +211 -0
  76. package/include/lynx/platform/embedder/public/lynx_load_meta.h +120 -0
  77. package/include/lynx/platform/embedder/public/lynx_native_module.h +9 -0
  78. package/include/lynx/platform/embedder/public/lynx_native_view.h +201 -0
  79. package/include/lynx/platform/embedder/public/lynx_resource_request.h +56 -0
  80. package/include/lynx/platform/embedder/public/lynx_resource_response.h +63 -0
  81. package/include/lynx/platform/embedder/public/lynx_runtime_lifecycle_observer.h +102 -0
  82. package/include/lynx/platform/embedder/public/lynx_security_service.h +78 -0
  83. package/include/lynx/platform/embedder/public/lynx_service_center.h +64 -0
  84. package/include/lynx/platform/embedder/public/lynx_template_bundle.h +65 -0
  85. package/include/lynx/platform/embedder/public/lynx_template_data.h +104 -0
  86. package/include/lynx/platform/embedder/public/lynx_trail_service.h +81 -0
  87. package/include/lynx/platform/embedder/public/lynx_update_meta.h +56 -0
  88. package/include/lynx/platform/embedder/public/lynx_value.h +270 -0
  89. package/include/lynx/platform/embedder/public/lynx_view.h +364 -0
  90. package/include/lynx/platform/embedder/public/lynx_view_client.h +226 -0
  91. package/include/lynx/platform/embedder/public/lynx_vsync_monitor.h +70 -0
  92. package/include/lynx/platform/embedder/public/lynx_windowless_renderer.h +302 -0
  93. package/include/lynx/registration.h +178 -0
  94. package/include/lynx_env.h +104 -0
  95. package/include/lynx_event_reporter_service.h +96 -0
  96. package/include/lynx_event_simulation_proxy.h +31 -0
  97. package/include/lynx_extension.h +10 -0
  98. package/include/lynx_extension_module.h +521 -0
  99. package/include/lynx_generic_resource_fetcher.h +178 -0
  100. package/include/lynx_group.h +70 -0
  101. package/include/lynx_http_service.h +211 -0
  102. package/include/lynx_load_meta.h +120 -0
  103. package/include/lynx_native_module.h +9 -0
  104. package/include/lynx_native_view.h +201 -0
  105. package/include/lynx_resource_request.h +56 -0
  106. package/include/lynx_resource_response.h +63 -0
  107. package/include/lynx_runtime_lifecycle_observer.h +102 -0
  108. package/include/lynx_security_service.h +78 -0
  109. package/include/lynx_service_center.h +64 -0
  110. package/include/lynx_template_bundle.h +65 -0
  111. package/include/lynx_template_data.h +104 -0
  112. package/include/lynx_trail_service.h +81 -0
  113. package/include/lynx_update_meta.h +56 -0
  114. package/include/lynx_value.h +270 -0
  115. package/include/lynx_view.h +364 -0
  116. package/include/lynx_view_client.h +226 -0
  117. package/include/lynx_vsync_monitor.h +70 -0
  118. package/include/lynx_windowless_renderer.h +302 -0
  119. package/include/napi-inl.deprecated.h +186 -0
  120. package/include/napi-inl.h +6607 -0
  121. package/include/napi.h +3208 -0
  122. package/include/node_api.h +276 -0
  123. package/include/node_api_types.h +59 -0
  124. package/include/third_party/weak-node-api/headers/js_native_api.h +608 -0
  125. package/include/third_party/weak-node-api/headers/js_native_api_types.h +202 -0
  126. package/include/third_party/weak-node-api/headers/napi-inl.deprecated.h +186 -0
  127. package/include/third_party/weak-node-api/headers/napi-inl.h +6607 -0
  128. package/include/third_party/weak-node-api/headers/napi.h +3208 -0
  129. package/include/third_party/weak-node-api/headers/node_api.h +276 -0
  130. package/include/third_party/weak-node-api/headers/node_api_types.h +59 -0
  131. package/include/third_party/weak-node-api/headers/weak_napi_defines.h +331 -0
  132. package/include/third_party/weak-node-api/headers/weak_napi_undefs.h +282 -0
  133. package/include/weak_napi_defines.h +331 -0
  134. package/include/weak_napi_undefs.h +282 -0
  135. package/package.json +29 -0
@@ -0,0 +1,202 @@
1
+ #ifndef WEAK_NODE_API_SRC_JS_NATIVE_API_TYPES_H_
2
+ #define WEAK_NODE_API_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
+ #if defined(USE_WEAK_SUFFIX_NAPI) || defined(OS_HARMONY)
10
+ #include "weak_napi_defines.h"
11
+ #endif
12
+
13
+ #if !defined __cplusplus || (defined(_MSC_VER) && _MSC_VER < 1900)
14
+ typedef uint16_t char16_t;
15
+ #endif
16
+
17
+ #ifndef NAPI_CDECL
18
+ #ifdef _WIN32
19
+ #define NAPI_CDECL __cdecl
20
+ #else
21
+ #define NAPI_CDECL
22
+ #endif
23
+ #endif
24
+
25
+ // JSVM API types are all opaque pointers for ABI stability
26
+ // typedef undefined structs instead of void* for compile time type safety
27
+ typedef struct napi_env__* napi_env;
28
+
29
+ // We need to mark APIs which can be called during garbage collection (GC),
30
+ // meaning that they do not affect the state of the JS engine, and can
31
+ // therefore be called synchronously from a finalizer that itself runs
32
+ // synchronously during GC. Such APIs can receive either a `napi_env` or a
33
+ // `node_api_basic_env` as their first parameter, because we should be able to
34
+ // also call them during normal, non-garbage-collecting operations, whereas
35
+ // APIs that affect the state of the JS engine can only receive a `napi_env` as
36
+ // their first parameter, because we must not call them during GC. In lieu of
37
+ // inheritance, we use the properties of the const qualifier to accomplish
38
+ // this, because both a const and a non-const value can be passed to an API
39
+ // expecting a const value, but only a non-const value can be passed to an API
40
+ // expecting a non-const value.
41
+ //
42
+ // In conjunction with appropriate CFLAGS to warn us if we're passing a const
43
+ // (basic) environment into an API that expects a non-const environment, and
44
+ // the definition of basic finalizer function pointer types below, which
45
+ // receive a basic environment as their first parameter, and can thus only call
46
+ // basic APIs (unless the user explicitly casts the environment), we achieve
47
+ // the ability to ensure at compile time that we do not call APIs that affect
48
+ // the state of the JS engine from a synchronous (basic) finalizer.
49
+ typedef struct napi_env__* node_api_nogc_env;
50
+ typedef node_api_nogc_env node_api_basic_env;
51
+
52
+ typedef struct napi_value__* napi_value;
53
+ typedef struct napi_ref__* napi_ref;
54
+ typedef struct napi_handle_scope__* napi_handle_scope;
55
+ typedef struct napi_escapable_handle_scope__* napi_escapable_handle_scope;
56
+ typedef struct napi_callback_info__* napi_callback_info;
57
+ typedef struct napi_deferred__* napi_deferred;
58
+
59
+ typedef enum {
60
+ napi_default = 0,
61
+ napi_writable = 1 << 0,
62
+ napi_enumerable = 1 << 1,
63
+ napi_configurable = 1 << 2,
64
+
65
+ // Used with napi_define_class to distinguish static properties
66
+ // from instance properties. Ignored by napi_define_properties.
67
+ napi_static = 1 << 10,
68
+
69
+ #if NAPI_VERSION >= 8
70
+ // Default for class methods.
71
+ napi_default_method = napi_writable | napi_configurable,
72
+
73
+ // Default for object properties, like in JS obj[prop].
74
+ napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable,
75
+ #endif // NAPI_VERSION >= 8
76
+ } napi_property_attributes;
77
+
78
+ typedef enum {
79
+ // ES6 types (corresponds to typeof)
80
+ napi_undefined,
81
+ napi_null,
82
+ napi_boolean,
83
+ napi_number,
84
+ napi_string,
85
+ napi_symbol,
86
+ napi_object,
87
+ napi_function,
88
+ napi_external,
89
+ napi_bigint,
90
+ } napi_valuetype;
91
+
92
+ typedef enum {
93
+ napi_int8_array,
94
+ napi_uint8_array,
95
+ napi_uint8_clamped_array,
96
+ napi_int16_array,
97
+ napi_uint16_array,
98
+ napi_int32_array,
99
+ napi_uint32_array,
100
+ napi_float32_array,
101
+ napi_float64_array,
102
+ napi_bigint64_array,
103
+ napi_biguint64_array,
104
+ } napi_typedarray_type;
105
+
106
+ typedef enum {
107
+ napi_ok,
108
+ napi_invalid_arg,
109
+ napi_object_expected,
110
+ napi_string_expected,
111
+ napi_name_expected,
112
+ napi_function_expected,
113
+ napi_number_expected,
114
+ napi_boolean_expected,
115
+ napi_array_expected,
116
+ napi_generic_failure,
117
+ napi_pending_exception,
118
+ napi_cancelled,
119
+ napi_escape_called_twice,
120
+ napi_handle_scope_mismatch,
121
+ napi_callback_scope_mismatch,
122
+ napi_queue_full,
123
+ napi_closing,
124
+ napi_bigint_expected,
125
+ napi_date_expected,
126
+ napi_arraybuffer_expected,
127
+ napi_detachable_arraybuffer_expected,
128
+ napi_would_deadlock, // unused
129
+ napi_no_external_buffers_allowed,
130
+ napi_cannot_run_js,
131
+ } napi_status;
132
+ // Note: when adding a new enum value to `napi_status`, please also update
133
+ // * `const int last_status` in the definition of `napi_get_last_error_info()'
134
+ // in file js_native_api_v8.cc.
135
+ // * `const char* error_messages[]` in file js_native_api_v8.cc with a brief
136
+ // message explaining the error.
137
+ // * the definition of `napi_status` in doc/api/n-api.md to reflect the newly
138
+ // added value(s).
139
+
140
+ typedef napi_value(NAPI_CDECL* napi_callback)(napi_env env,
141
+ napi_callback_info info);
142
+ typedef void(NAPI_CDECL* napi_finalize)(napi_env env,
143
+ void* finalize_data,
144
+ void* finalize_hint);
145
+
146
+ typedef napi_finalize node_api_nogc_finalize;
147
+ typedef node_api_nogc_finalize node_api_basic_finalize;
148
+
149
+ typedef struct {
150
+ // One of utf8name or name should be NULL.
151
+ const char* utf8name;
152
+ napi_value name;
153
+
154
+ napi_callback method;
155
+ napi_callback getter;
156
+ napi_callback setter;
157
+ napi_value value;
158
+
159
+ napi_property_attributes attributes;
160
+ void* data;
161
+ } napi_property_descriptor;
162
+
163
+ typedef struct {
164
+ const char* error_message;
165
+ void* engine_reserved;
166
+ uint32_t engine_error_code;
167
+ napi_status error_code;
168
+ } napi_extended_error_info;
169
+
170
+ #if NAPI_VERSION >= 6
171
+ typedef enum {
172
+ napi_key_include_prototypes,
173
+ napi_key_own_only
174
+ } napi_key_collection_mode;
175
+
176
+ typedef enum {
177
+ napi_key_all_properties = 0,
178
+ napi_key_writable = 1,
179
+ napi_key_enumerable = 1 << 1,
180
+ napi_key_configurable = 1 << 2,
181
+ napi_key_skip_strings = 1 << 3,
182
+ napi_key_skip_symbols = 1 << 4
183
+ } napi_key_filter;
184
+
185
+ typedef enum {
186
+ napi_key_keep_numbers,
187
+ napi_key_numbers_to_strings
188
+ } napi_key_conversion;
189
+ #endif // NAPI_VERSION >= 6
190
+
191
+ #if NAPI_VERSION >= 8
192
+ typedef struct {
193
+ uint64_t lower;
194
+ uint64_t upper;
195
+ } napi_type_tag;
196
+ #endif // NAPI_VERSION >= 8
197
+
198
+ #endif // SRC_JS_NATIVE_API_TYPES_H_
199
+
200
+ #if defined(USE_WEAK_SUFFIX_NAPI) || defined(OS_HARMONY)
201
+ #include "weak_napi_undefs.h"
202
+ #endif
@@ -0,0 +1,186 @@
1
+ #ifndef WEAK_NODE_API_SRC_NAPI_INL_DEPRECATED_H_
2
+ #define WEAK_NODE_API_SRC_NAPI_INL_DEPRECATED_H_
3
+
4
+ ////////////////////////////////////////////////////////////////////////////////
5
+ // PropertyDescriptor class
6
+ ////////////////////////////////////////////////////////////////////////////////
7
+
8
+ template <typename Getter>
9
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
10
+ const char* utf8name,
11
+ Getter getter,
12
+ napi_property_attributes attributes,
13
+ void* /*data*/) {
14
+ using CbData = details::CallbackData<Getter, Napi::Value>;
15
+ // TODO: Delete when the function is destroyed
16
+ auto callbackData = new CbData({getter, nullptr});
17
+
18
+ return PropertyDescriptor({utf8name,
19
+ nullptr,
20
+ nullptr,
21
+ CbData::Wrapper,
22
+ nullptr,
23
+ nullptr,
24
+ attributes,
25
+ callbackData});
26
+ }
27
+
28
+ template <typename Getter>
29
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
30
+ const std::string& utf8name,
31
+ Getter getter,
32
+ napi_property_attributes attributes,
33
+ void* data) {
34
+ return Accessor(utf8name.c_str(), getter, attributes, data);
35
+ }
36
+
37
+ template <typename Getter>
38
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
39
+ napi_value name,
40
+ Getter getter,
41
+ napi_property_attributes attributes,
42
+ void* /*data*/) {
43
+ using CbData = details::CallbackData<Getter, Napi::Value>;
44
+ // TODO: Delete when the function is destroyed
45
+ auto callbackData = new CbData({getter, nullptr});
46
+
47
+ return PropertyDescriptor({nullptr,
48
+ name,
49
+ nullptr,
50
+ CbData::Wrapper,
51
+ nullptr,
52
+ nullptr,
53
+ attributes,
54
+ callbackData});
55
+ }
56
+
57
+ template <typename Getter>
58
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
59
+ Name name, Getter getter, napi_property_attributes attributes, void* data) {
60
+ napi_value nameValue = name;
61
+ return PropertyDescriptor::Accessor(nameValue, getter, attributes, data);
62
+ }
63
+
64
+ template <typename Getter, typename Setter>
65
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
66
+ const char* utf8name,
67
+ Getter getter,
68
+ Setter setter,
69
+ napi_property_attributes attributes,
70
+ void* /*data*/) {
71
+ using CbData = details::AccessorCallbackData<Getter, Setter>;
72
+ // TODO: Delete when the function is destroyed
73
+ auto callbackData = new CbData({getter, setter, nullptr});
74
+
75
+ return PropertyDescriptor({utf8name,
76
+ nullptr,
77
+ nullptr,
78
+ CbData::GetterWrapper,
79
+ CbData::SetterWrapper,
80
+ nullptr,
81
+ attributes,
82
+ callbackData});
83
+ }
84
+
85
+ template <typename Getter, typename Setter>
86
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
87
+ const std::string& utf8name,
88
+ Getter getter,
89
+ Setter setter,
90
+ napi_property_attributes attributes,
91
+ void* data) {
92
+ return Accessor(utf8name.c_str(), getter, setter, attributes, data);
93
+ }
94
+
95
+ template <typename Getter, typename Setter>
96
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
97
+ napi_value name,
98
+ Getter getter,
99
+ Setter setter,
100
+ napi_property_attributes attributes,
101
+ void* /*data*/) {
102
+ using CbData = details::AccessorCallbackData<Getter, Setter>;
103
+ // TODO: Delete when the function is destroyed
104
+ auto callbackData = new CbData({getter, setter, nullptr});
105
+
106
+ return PropertyDescriptor({nullptr,
107
+ name,
108
+ nullptr,
109
+ CbData::GetterWrapper,
110
+ CbData::SetterWrapper,
111
+ nullptr,
112
+ attributes,
113
+ callbackData});
114
+ }
115
+
116
+ template <typename Getter, typename Setter>
117
+ inline PropertyDescriptor PropertyDescriptor::Accessor(
118
+ Name name,
119
+ Getter getter,
120
+ Setter setter,
121
+ napi_property_attributes attributes,
122
+ void* data) {
123
+ napi_value nameValue = name;
124
+ return PropertyDescriptor::Accessor(
125
+ nameValue, getter, setter, attributes, data);
126
+ }
127
+
128
+ template <typename Callable>
129
+ inline PropertyDescriptor PropertyDescriptor::Function(
130
+ const char* utf8name,
131
+ Callable cb,
132
+ napi_property_attributes attributes,
133
+ void* /*data*/) {
134
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
135
+ using CbData = details::CallbackData<Callable, ReturnType>;
136
+ // TODO: Delete when the function is destroyed
137
+ auto callbackData = new CbData({cb, nullptr});
138
+
139
+ return PropertyDescriptor({utf8name,
140
+ nullptr,
141
+ CbData::Wrapper,
142
+ nullptr,
143
+ nullptr,
144
+ nullptr,
145
+ attributes,
146
+ callbackData});
147
+ }
148
+
149
+ template <typename Callable>
150
+ inline PropertyDescriptor PropertyDescriptor::Function(
151
+ const std::string& utf8name,
152
+ Callable cb,
153
+ napi_property_attributes attributes,
154
+ void* data) {
155
+ return Function(utf8name.c_str(), cb, attributes, data);
156
+ }
157
+
158
+ template <typename Callable>
159
+ inline PropertyDescriptor PropertyDescriptor::Function(
160
+ napi_value name,
161
+ Callable cb,
162
+ napi_property_attributes attributes,
163
+ void* /*data*/) {
164
+ using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
165
+ using CbData = details::CallbackData<Callable, ReturnType>;
166
+ // TODO: Delete when the function is destroyed
167
+ auto callbackData = new CbData({cb, nullptr});
168
+
169
+ return PropertyDescriptor({nullptr,
170
+ name,
171
+ CbData::Wrapper,
172
+ nullptr,
173
+ nullptr,
174
+ nullptr,
175
+ attributes,
176
+ callbackData});
177
+ }
178
+
179
+ template <typename Callable>
180
+ inline PropertyDescriptor PropertyDescriptor::Function(
181
+ Name name, Callable cb, napi_property_attributes attributes, void* data) {
182
+ napi_value nameValue = name;
183
+ return PropertyDescriptor::Function(nameValue, cb, attributes, data);
184
+ }
185
+
186
+ #endif // !SRC_NAPI_INL_DEPRECATED_H_