@fugood/llama.node 0.6.0 → 0.6.2

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.
@@ -0,0 +1,2102 @@
1
+ #ifdef _WIN32
2
+
3
+ #include <windows.h>
4
+ #include <stdio.h>
5
+ #include <string.h>
6
+ #include <node_api.h>
7
+
8
+ #undef NAPI_EXTERN
9
+
10
+ static napi_status (*napi_adjust_external_memory_ptr)(napi_env, int64_t, int64_t*) = NULL;
11
+ static napi_status (*napi_call_function_ptr)(napi_env, napi_value, napi_value, size_t, const napi_value*, napi_value*) = NULL;
12
+ static napi_status (*napi_close_escapable_handle_scope_ptr)(napi_env, napi_escapable_handle_scope) = NULL;
13
+ static napi_status (*napi_close_handle_scope_ptr)(napi_env, napi_handle_scope) = NULL;
14
+ static napi_status (*napi_coerce_to_bool_ptr)(napi_env, napi_value, napi_value*) = NULL;
15
+ static napi_status (*napi_coerce_to_number_ptr)(napi_env, napi_value, napi_value*) = NULL;
16
+ static napi_status (*napi_coerce_to_object_ptr)(napi_env, napi_value, napi_value*) = NULL;
17
+ static napi_status (*napi_coerce_to_string_ptr)(napi_env, napi_value, napi_value*) = NULL;
18
+ static napi_status (*napi_create_array_ptr)(napi_env, napi_value*) = NULL;
19
+ static napi_status (*napi_create_array_with_length_ptr)(napi_env, size_t, napi_value*) = NULL;
20
+ static napi_status (*napi_create_arraybuffer_ptr)(napi_env, size_t, void**, napi_value*) = NULL;
21
+ static napi_status (*napi_create_dataview_ptr)(napi_env, size_t, napi_value, size_t, napi_value*) = NULL;
22
+ static napi_status (*napi_create_double_ptr)(napi_env, double, napi_value*) = NULL;
23
+ static napi_status (*napi_create_error_ptr)(napi_env, napi_value, napi_value, napi_value*) = NULL;
24
+ static napi_status (*napi_create_external_ptr)(napi_env, void*, napi_finalize, void*, napi_value*) = NULL;
25
+ static napi_status (*napi_create_external_arraybuffer_ptr)(napi_env, void*, size_t, napi_finalize, void*, napi_value*) = NULL;
26
+ static napi_status (*napi_create_function_ptr)(napi_env, const char*, size_t, napi_callback, void*, napi_value*) = NULL;
27
+ static napi_status (*napi_create_int32_ptr)(napi_env, int32_t, napi_value*) = NULL;
28
+ static napi_status (*napi_create_int64_ptr)(napi_env, int64_t, napi_value*) = NULL;
29
+ static napi_status (*napi_create_object_ptr)(napi_env, napi_value*) = NULL;
30
+ static napi_status (*napi_create_promise_ptr)(napi_env, napi_deferred*, napi_value*) = NULL;
31
+ static napi_status (*napi_create_range_error_ptr)(napi_env, napi_value, napi_value, napi_value*) = NULL;
32
+ static napi_status (*napi_create_reference_ptr)(napi_env, napi_value, uint32_t, napi_ref*) = NULL;
33
+ static napi_status (*napi_create_string_latin1_ptr)(napi_env, const char*, size_t, napi_value*) = NULL;
34
+ static napi_status (*napi_create_string_utf16_ptr)(napi_env, const char16_t*, size_t, napi_value*) = NULL;
35
+ static napi_status (*napi_create_string_utf8_ptr)(napi_env, const char*, size_t, napi_value*) = NULL;
36
+ static napi_status (*napi_create_symbol_ptr)(napi_env, napi_value, napi_value*) = NULL;
37
+ static napi_status (*napi_create_type_error_ptr)(napi_env, napi_value, napi_value, napi_value*) = NULL;
38
+ static napi_status (*napi_create_typedarray_ptr)(napi_env, napi_typedarray_type, size_t, napi_value, size_t, napi_value*) = NULL;
39
+ static napi_status (*napi_create_uint32_ptr)(napi_env, uint32_t, napi_value*) = NULL;
40
+ static napi_status (*napi_define_class_ptr)(napi_env, const char*, size_t, napi_callback, void*, size_t, const napi_property_descriptor*, napi_value*) = NULL;
41
+ static napi_status (*napi_define_properties_ptr)(napi_env, napi_value, size_t, const napi_property_descriptor*) = NULL;
42
+ static napi_status (*napi_delete_element_ptr)(napi_env, napi_value, uint32_t, bool*) = NULL;
43
+ static napi_status (*napi_delete_property_ptr)(napi_env, napi_value, napi_value, bool*) = NULL;
44
+ static napi_status (*napi_delete_reference_ptr)(napi_env, napi_ref) = NULL;
45
+ static napi_status (*napi_escape_handle_ptr)(napi_env, napi_escapable_handle_scope, napi_value, napi_value*) = NULL;
46
+ static napi_status (*napi_get_and_clear_last_exception_ptr)(napi_env, napi_value*) = NULL;
47
+ static napi_status (*napi_get_array_length_ptr)(napi_env, napi_value, uint32_t*) = NULL;
48
+ static napi_status (*napi_get_arraybuffer_info_ptr)(napi_env, napi_value, void**, size_t*) = NULL;
49
+ static napi_status (*napi_get_boolean_ptr)(napi_env, bool, napi_value*) = NULL;
50
+ static napi_status (*napi_get_cb_info_ptr)(napi_env, napi_callback_info, size_t*, napi_value*, napi_value*, void**) = NULL;
51
+ static napi_status (*napi_get_dataview_info_ptr)(napi_env, napi_value, size_t*, void**, napi_value*, size_t*) = NULL;
52
+ static napi_status (*napi_get_element_ptr)(napi_env, napi_value, uint32_t, napi_value*) = NULL;
53
+ static napi_status (*napi_get_global_ptr)(napi_env, napi_value*) = NULL;
54
+ static napi_status (*napi_get_last_error_info_ptr)(napi_env, const napi_extended_error_info**) = NULL;
55
+ static napi_status (*napi_get_named_property_ptr)(napi_env, napi_value, const char*, napi_value*) = NULL;
56
+ static napi_status (*napi_get_new_target_ptr)(napi_env, napi_callback_info, napi_value*) = NULL;
57
+ static napi_status (*napi_get_null_ptr)(napi_env, napi_value*) = NULL;
58
+ static napi_status (*napi_get_property_ptr)(napi_env, napi_value, napi_value, napi_value*) = NULL;
59
+ static napi_status (*napi_get_property_names_ptr)(napi_env, napi_value, napi_value*) = NULL;
60
+ static napi_status (*napi_get_prototype_ptr)(napi_env, napi_value, napi_value*) = NULL;
61
+ static napi_status (*napi_get_reference_value_ptr)(napi_env, napi_ref, napi_value*) = NULL;
62
+ static napi_status (*napi_get_typedarray_info_ptr)(napi_env, napi_value, napi_typedarray_type*, size_t*, void**, napi_value*, size_t*) = NULL;
63
+ static napi_status (*napi_get_undefined_ptr)(napi_env, napi_value*) = NULL;
64
+ static napi_status (*napi_get_value_bool_ptr)(napi_env, napi_value, bool*) = NULL;
65
+ static napi_status (*napi_get_value_double_ptr)(napi_env, napi_value, double*) = NULL;
66
+ static napi_status (*napi_get_value_external_ptr)(napi_env, napi_value, void**) = NULL;
67
+ static napi_status (*napi_get_value_int32_ptr)(napi_env, napi_value, int32_t*) = NULL;
68
+ static napi_status (*napi_get_value_int64_ptr)(napi_env, napi_value, int64_t*) = NULL;
69
+ static napi_status (*napi_get_value_string_latin1_ptr)(napi_env, napi_value, char*, size_t, size_t*) = NULL;
70
+ static napi_status (*napi_get_value_string_utf16_ptr)(napi_env, napi_value, char16_t*, size_t, size_t*) = NULL;
71
+ static napi_status (*napi_get_value_string_utf8_ptr)(napi_env, napi_value, char*, size_t, size_t*) = NULL;
72
+ static napi_status (*napi_get_value_uint32_ptr)(napi_env, napi_value, uint32_t*) = NULL;
73
+ static napi_status (*napi_get_version_ptr)(napi_env, uint32_t*) = NULL;
74
+ static napi_status (*napi_has_element_ptr)(napi_env, napi_value, uint32_t, bool*) = NULL;
75
+ static napi_status (*napi_has_named_property_ptr)(napi_env, napi_value, const char*, bool*) = NULL;
76
+ static napi_status (*napi_has_own_property_ptr)(napi_env, napi_value, napi_value, bool*) = NULL;
77
+ static napi_status (*napi_has_property_ptr)(napi_env, napi_value, napi_value, bool*) = NULL;
78
+ static napi_status (*napi_instanceof_ptr)(napi_env, napi_value, napi_value, bool*) = NULL;
79
+ static napi_status (*napi_is_array_ptr)(napi_env, napi_value, bool*) = NULL;
80
+ static napi_status (*napi_is_arraybuffer_ptr)(napi_env, napi_value, bool*) = NULL;
81
+ static napi_status (*napi_is_dataview_ptr)(napi_env, napi_value, bool*) = NULL;
82
+ static napi_status (*napi_is_error_ptr)(napi_env, napi_value, bool*) = NULL;
83
+ static napi_status (*napi_is_exception_pending_ptr)(napi_env, bool*) = NULL;
84
+ static napi_status (*napi_is_promise_ptr)(napi_env, napi_value, bool*) = NULL;
85
+ static napi_status (*napi_is_typedarray_ptr)(napi_env, napi_value, bool*) = NULL;
86
+ static napi_status (*napi_new_instance_ptr)(napi_env, napi_value, size_t, const napi_value*, napi_value*) = NULL;
87
+ static napi_status (*napi_open_escapable_handle_scope_ptr)(napi_env, napi_escapable_handle_scope*) = NULL;
88
+ static napi_status (*napi_open_handle_scope_ptr)(napi_env, napi_handle_scope*) = NULL;
89
+ static napi_status (*napi_reference_ref_ptr)(napi_env, napi_ref, uint32_t*) = NULL;
90
+ static napi_status (*napi_reference_unref_ptr)(napi_env, napi_ref, uint32_t*) = NULL;
91
+ static napi_status (*napi_reject_deferred_ptr)(napi_env, napi_deferred, napi_value) = NULL;
92
+ static napi_status (*napi_remove_wrap_ptr)(napi_env, napi_value, void**) = NULL;
93
+ static napi_status (*napi_resolve_deferred_ptr)(napi_env, napi_deferred, napi_value) = NULL;
94
+ static napi_status (*napi_run_script_ptr)(napi_env, napi_value, napi_value*) = NULL;
95
+ static napi_status (*napi_set_element_ptr)(napi_env, napi_value, uint32_t, napi_value) = NULL;
96
+ static napi_status (*napi_set_named_property_ptr)(napi_env, napi_value, const char*, napi_value) = NULL;
97
+ static napi_status (*napi_set_property_ptr)(napi_env, napi_value, napi_value, napi_value) = NULL;
98
+ static napi_status (*napi_strict_equals_ptr)(napi_env, napi_value, napi_value, bool*) = NULL;
99
+ static napi_status (*napi_throw_ptr)(napi_env, napi_value) = NULL;
100
+ static napi_status (*napi_throw_error_ptr)(napi_env, const char*, const char*) = NULL;
101
+ static napi_status (*napi_throw_range_error_ptr)(napi_env, const char*, const char*) = NULL;
102
+ static napi_status (*napi_throw_type_error_ptr)(napi_env, const char*, const char*) = NULL;
103
+ static napi_status (*napi_typeof_ptr)(napi_env, napi_value, napi_valuetype*) = NULL;
104
+ static napi_status (*napi_unwrap_ptr)(napi_env, napi_value, void**) = NULL;
105
+ static napi_status (*napi_wrap_ptr)(napi_env, napi_value, void*, napi_finalize, void*, napi_ref*) = NULL;
106
+ static napi_status (*napi_async_destroy_ptr)(napi_env, napi_async_context) = NULL;
107
+ static napi_status (*napi_async_init_ptr)(napi_env, napi_value, napi_value, napi_async_context*) = NULL;
108
+ static napi_status (*napi_cancel_async_work_ptr)(napi_env, napi_async_work) = NULL;
109
+ static napi_status (*napi_create_async_work_ptr)(napi_env, napi_value, napi_value, napi_async_execute_callback, napi_async_complete_callback, void*, napi_async_work*) = NULL;
110
+ static napi_status (*napi_create_buffer_ptr)(napi_env, size_t, void**, napi_value*) = NULL;
111
+ static napi_status (*napi_create_buffer_copy_ptr)(napi_env, size_t, const void*, void**, napi_value*) = NULL;
112
+ static napi_status (*napi_create_external_buffer_ptr)(napi_env, size_t, void*, napi_finalize, void*, napi_value*) = NULL;
113
+ static napi_status (*napi_delete_async_work_ptr)(napi_env, napi_async_work) = NULL;
114
+ static void (*napi_fatal_error_ptr)(const char*, size_t, const char*, size_t) = NULL;
115
+ static napi_status (*napi_get_buffer_info_ptr)(napi_env, napi_value, void**, size_t*) = NULL;
116
+ static napi_status (*napi_get_node_version_ptr)(napi_env, const napi_node_version**) = NULL;
117
+ static napi_status (*napi_is_buffer_ptr)(napi_env, napi_value, bool*) = NULL;
118
+ static napi_status (*napi_make_callback_ptr)(napi_env, napi_async_context, napi_value, napi_value, size_t, const napi_value*, napi_value*) = NULL;
119
+ static void (*napi_module_register_ptr)(napi_module*) = NULL;
120
+ static napi_status (*napi_queue_async_work_ptr)(napi_env, napi_async_work) = NULL;
121
+ static napi_status (*napi_get_uv_event_loop_ptr)(napi_env, struct uv_loop_s**) = NULL;
122
+ static napi_status (*napi_add_env_cleanup_hook_ptr)(napi_env, napi_cleanup_hook, void*) = NULL;
123
+ static napi_status (*napi_close_callback_scope_ptr)(napi_env, napi_callback_scope) = NULL;
124
+ static napi_status (*napi_fatal_exception_ptr)(napi_env, napi_value) = NULL;
125
+ static napi_status (*napi_open_callback_scope_ptr)(napi_env, napi_value, napi_async_context, napi_callback_scope*) = NULL;
126
+ static napi_status (*napi_remove_env_cleanup_hook_ptr)(napi_env, napi_cleanup_hook, void*) = NULL;
127
+ static napi_status (*napi_acquire_threadsafe_function_ptr)(napi_threadsafe_function) = NULL;
128
+ static napi_status (*napi_call_threadsafe_function_ptr)(napi_threadsafe_function, void*, napi_threadsafe_function_call_mode) = NULL;
129
+ static napi_status (*napi_create_threadsafe_function_ptr)(napi_env, napi_value, napi_value, napi_value, size_t, size_t, void*, napi_finalize, void*, napi_threadsafe_function_call_js, napi_threadsafe_function*) = NULL;
130
+ static napi_status (*napi_get_threadsafe_function_context_ptr)(napi_threadsafe_function, void**) = NULL;
131
+ static napi_status (*napi_ref_threadsafe_function_ptr)(napi_env, napi_threadsafe_function) = NULL;
132
+ static napi_status (*napi_release_threadsafe_function_ptr)(napi_threadsafe_function, napi_threadsafe_function_release_mode) = NULL;
133
+ static napi_status (*napi_unref_threadsafe_function_ptr)(napi_env, napi_threadsafe_function) = NULL;
134
+ static napi_status (*napi_add_finalizer_ptr)(napi_env, napi_value, void*, napi_finalize, void*, napi_ref*) = NULL;
135
+ static napi_status (*napi_create_date_ptr)(napi_env, double, napi_value*) = NULL;
136
+ static napi_status (*napi_get_date_value_ptr)(napi_env, napi_value, double*) = NULL;
137
+ static napi_status (*napi_is_date_ptr)(napi_env, napi_value, bool*) = NULL;
138
+ static napi_status (*napi_create_bigint_int64_ptr)(napi_env, int64_t, napi_value*) = NULL;
139
+ static napi_status (*napi_create_bigint_uint64_ptr)(napi_env, uint64_t, napi_value*) = NULL;
140
+ static napi_status (*napi_create_bigint_words_ptr)(napi_env, int, size_t, const uint64_t*, napi_value*) = NULL;
141
+ static napi_status (*napi_get_all_property_names_ptr)(napi_env, napi_value, napi_key_collection_mode, napi_key_filter, napi_key_conversion, napi_value*) = NULL;
142
+ static napi_status (*napi_get_instance_data_ptr)(napi_env, void**) = NULL;
143
+ static napi_status (*napi_get_value_bigint_int64_ptr)(napi_env, napi_value, int64_t*, bool*) = NULL;
144
+ static napi_status (*napi_get_value_bigint_uint64_ptr)(napi_env, napi_value, uint64_t*, bool*) = NULL;
145
+ static napi_status (*napi_get_value_bigint_words_ptr)(napi_env, napi_value, int*, size_t*, uint64_t*) = NULL;
146
+ static napi_status (*napi_set_instance_data_ptr)(napi_env, void*, napi_finalize, void*) = NULL;
147
+
148
+ static HMODULE napi_module_handle = NULL;
149
+ static int napi_functions_loaded = 0;
150
+
151
+ typedef struct {
152
+ const char* name;
153
+ void** func_ptr;
154
+ } napi_function_entry;
155
+
156
+ static napi_function_entry napi_functions[] = {
157
+ {"napi_adjust_external_memory", (void**)&napi_adjust_external_memory_ptr},
158
+ {"napi_call_function", (void**)&napi_call_function_ptr},
159
+ {"napi_close_escapable_handle_scope", (void**)&napi_close_escapable_handle_scope_ptr},
160
+ {"napi_close_handle_scope", (void**)&napi_close_handle_scope_ptr},
161
+ {"napi_coerce_to_bool", (void**)&napi_coerce_to_bool_ptr},
162
+ {"napi_coerce_to_number", (void**)&napi_coerce_to_number_ptr},
163
+ {"napi_coerce_to_object", (void**)&napi_coerce_to_object_ptr},
164
+ {"napi_coerce_to_string", (void**)&napi_coerce_to_string_ptr},
165
+ {"napi_create_array", (void**)&napi_create_array_ptr},
166
+ {"napi_create_array_with_length", (void**)&napi_create_array_with_length_ptr},
167
+ {"napi_create_arraybuffer", (void**)&napi_create_arraybuffer_ptr},
168
+ {"napi_create_dataview", (void**)&napi_create_dataview_ptr},
169
+ {"napi_create_double", (void**)&napi_create_double_ptr},
170
+ {"napi_create_error", (void**)&napi_create_error_ptr},
171
+ {"napi_create_external", (void**)&napi_create_external_ptr},
172
+ {"napi_create_external_arraybuffer", (void**)&napi_create_external_arraybuffer_ptr},
173
+ {"napi_create_function", (void**)&napi_create_function_ptr},
174
+ {"napi_create_int32", (void**)&napi_create_int32_ptr},
175
+ {"napi_create_int64", (void**)&napi_create_int64_ptr},
176
+ {"napi_create_object", (void**)&napi_create_object_ptr},
177
+ {"napi_create_promise", (void**)&napi_create_promise_ptr},
178
+ {"napi_create_range_error", (void**)&napi_create_range_error_ptr},
179
+ {"napi_create_reference", (void**)&napi_create_reference_ptr},
180
+ {"napi_create_string_latin1", (void**)&napi_create_string_latin1_ptr},
181
+ {"napi_create_string_utf16", (void**)&napi_create_string_utf16_ptr},
182
+ {"napi_create_string_utf8", (void**)&napi_create_string_utf8_ptr},
183
+ {"napi_create_symbol", (void**)&napi_create_symbol_ptr},
184
+ {"napi_create_type_error", (void**)&napi_create_type_error_ptr},
185
+ {"napi_create_typedarray", (void**)&napi_create_typedarray_ptr},
186
+ {"napi_create_uint32", (void**)&napi_create_uint32_ptr},
187
+ {"napi_define_class", (void**)&napi_define_class_ptr},
188
+ {"napi_define_properties", (void**)&napi_define_properties_ptr},
189
+ {"napi_delete_element", (void**)&napi_delete_element_ptr},
190
+ {"napi_delete_property", (void**)&napi_delete_property_ptr},
191
+ {"napi_delete_reference", (void**)&napi_delete_reference_ptr},
192
+ {"napi_escape_handle", (void**)&napi_escape_handle_ptr},
193
+ {"napi_get_and_clear_last_exception", (void**)&napi_get_and_clear_last_exception_ptr},
194
+ {"napi_get_array_length", (void**)&napi_get_array_length_ptr},
195
+ {"napi_get_arraybuffer_info", (void**)&napi_get_arraybuffer_info_ptr},
196
+ {"napi_get_boolean", (void**)&napi_get_boolean_ptr},
197
+ {"napi_get_cb_info", (void**)&napi_get_cb_info_ptr},
198
+ {"napi_get_dataview_info", (void**)&napi_get_dataview_info_ptr},
199
+ {"napi_get_element", (void**)&napi_get_element_ptr},
200
+ {"napi_get_global", (void**)&napi_get_global_ptr},
201
+ {"napi_get_last_error_info", (void**)&napi_get_last_error_info_ptr},
202
+ {"napi_get_named_property", (void**)&napi_get_named_property_ptr},
203
+ {"napi_get_new_target", (void**)&napi_get_new_target_ptr},
204
+ {"napi_get_null", (void**)&napi_get_null_ptr},
205
+ {"napi_get_property", (void**)&napi_get_property_ptr},
206
+ {"napi_get_property_names", (void**)&napi_get_property_names_ptr},
207
+ {"napi_get_prototype", (void**)&napi_get_prototype_ptr},
208
+ {"napi_get_reference_value", (void**)&napi_get_reference_value_ptr},
209
+ {"napi_get_typedarray_info", (void**)&napi_get_typedarray_info_ptr},
210
+ {"napi_get_undefined", (void**)&napi_get_undefined_ptr},
211
+ {"napi_get_value_bool", (void**)&napi_get_value_bool_ptr},
212
+ {"napi_get_value_double", (void**)&napi_get_value_double_ptr},
213
+ {"napi_get_value_external", (void**)&napi_get_value_external_ptr},
214
+ {"napi_get_value_int32", (void**)&napi_get_value_int32_ptr},
215
+ {"napi_get_value_int64", (void**)&napi_get_value_int64_ptr},
216
+ {"napi_get_value_string_latin1", (void**)&napi_get_value_string_latin1_ptr},
217
+ {"napi_get_value_string_utf16", (void**)&napi_get_value_string_utf16_ptr},
218
+ {"napi_get_value_string_utf8", (void**)&napi_get_value_string_utf8_ptr},
219
+ {"napi_get_value_uint32", (void**)&napi_get_value_uint32_ptr},
220
+ {"napi_get_version", (void**)&napi_get_version_ptr},
221
+ {"napi_has_element", (void**)&napi_has_element_ptr},
222
+ {"napi_has_named_property", (void**)&napi_has_named_property_ptr},
223
+ {"napi_has_own_property", (void**)&napi_has_own_property_ptr},
224
+ {"napi_has_property", (void**)&napi_has_property_ptr},
225
+ {"napi_instanceof", (void**)&napi_instanceof_ptr},
226
+ {"napi_is_array", (void**)&napi_is_array_ptr},
227
+ {"napi_is_arraybuffer", (void**)&napi_is_arraybuffer_ptr},
228
+ {"napi_is_dataview", (void**)&napi_is_dataview_ptr},
229
+ {"napi_is_error", (void**)&napi_is_error_ptr},
230
+ {"napi_is_exception_pending", (void**)&napi_is_exception_pending_ptr},
231
+ {"napi_is_promise", (void**)&napi_is_promise_ptr},
232
+ {"napi_is_typedarray", (void**)&napi_is_typedarray_ptr},
233
+ {"napi_new_instance", (void**)&napi_new_instance_ptr},
234
+ {"napi_open_escapable_handle_scope", (void**)&napi_open_escapable_handle_scope_ptr},
235
+ {"napi_open_handle_scope", (void**)&napi_open_handle_scope_ptr},
236
+ {"napi_reference_ref", (void**)&napi_reference_ref_ptr},
237
+ {"napi_reference_unref", (void**)&napi_reference_unref_ptr},
238
+ {"napi_reject_deferred", (void**)&napi_reject_deferred_ptr},
239
+ {"napi_remove_wrap", (void**)&napi_remove_wrap_ptr},
240
+ {"napi_resolve_deferred", (void**)&napi_resolve_deferred_ptr},
241
+ {"napi_run_script", (void**)&napi_run_script_ptr},
242
+ {"napi_set_element", (void**)&napi_set_element_ptr},
243
+ {"napi_set_named_property", (void**)&napi_set_named_property_ptr},
244
+ {"napi_set_property", (void**)&napi_set_property_ptr},
245
+ {"napi_strict_equals", (void**)&napi_strict_equals_ptr},
246
+ {"napi_throw", (void**)&napi_throw_ptr},
247
+ {"napi_throw_error", (void**)&napi_throw_error_ptr},
248
+ {"napi_throw_range_error", (void**)&napi_throw_range_error_ptr},
249
+ {"napi_throw_type_error", (void**)&napi_throw_type_error_ptr},
250
+ {"napi_typeof", (void**)&napi_typeof_ptr},
251
+ {"napi_unwrap", (void**)&napi_unwrap_ptr},
252
+ {"napi_wrap", (void**)&napi_wrap_ptr},
253
+ {"napi_async_destroy", (void**)&napi_async_destroy_ptr},
254
+ {"napi_async_init", (void**)&napi_async_init_ptr},
255
+ {"napi_cancel_async_work", (void**)&napi_cancel_async_work_ptr},
256
+ {"napi_create_async_work", (void**)&napi_create_async_work_ptr},
257
+ {"napi_create_buffer", (void**)&napi_create_buffer_ptr},
258
+ {"napi_create_buffer_copy", (void**)&napi_create_buffer_copy_ptr},
259
+ {"napi_create_external_buffer", (void**)&napi_create_external_buffer_ptr},
260
+ {"napi_delete_async_work", (void**)&napi_delete_async_work_ptr},
261
+ {"napi_fatal_error", (void**)&napi_fatal_error_ptr},
262
+ {"napi_get_buffer_info", (void**)&napi_get_buffer_info_ptr},
263
+ {"napi_get_node_version", (void**)&napi_get_node_version_ptr},
264
+ {"napi_is_buffer", (void**)&napi_is_buffer_ptr},
265
+ {"napi_make_callback", (void**)&napi_make_callback_ptr},
266
+ {"napi_module_register", (void**)&napi_module_register_ptr},
267
+ {"napi_queue_async_work", (void**)&napi_queue_async_work_ptr},
268
+ {"napi_get_uv_event_loop", (void**)&napi_get_uv_event_loop_ptr},
269
+ {"napi_add_env_cleanup_hook", (void**)&napi_add_env_cleanup_hook_ptr},
270
+ {"napi_close_callback_scope", (void**)&napi_close_callback_scope_ptr},
271
+ {"napi_fatal_exception", (void**)&napi_fatal_exception_ptr},
272
+ {"napi_open_callback_scope", (void**)&napi_open_callback_scope_ptr},
273
+ {"napi_remove_env_cleanup_hook", (void**)&napi_remove_env_cleanup_hook_ptr},
274
+ {"napi_acquire_threadsafe_function", (void**)&napi_acquire_threadsafe_function_ptr},
275
+ {"napi_call_threadsafe_function", (void**)&napi_call_threadsafe_function_ptr},
276
+ {"napi_create_threadsafe_function", (void**)&napi_create_threadsafe_function_ptr},
277
+ {"napi_get_threadsafe_function_context", (void**)&napi_get_threadsafe_function_context_ptr},
278
+ {"napi_ref_threadsafe_function", (void**)&napi_ref_threadsafe_function_ptr},
279
+ {"napi_release_threadsafe_function", (void**)&napi_release_threadsafe_function_ptr},
280
+ {"napi_unref_threadsafe_function", (void**)&napi_unref_threadsafe_function_ptr},
281
+ {"napi_add_finalizer", (void**)&napi_add_finalizer_ptr},
282
+ {"napi_create_date", (void**)&napi_create_date_ptr},
283
+ {"napi_get_date_value", (void**)&napi_get_date_value_ptr},
284
+ {"napi_is_date", (void**)&napi_is_date_ptr},
285
+ {"napi_create_bigint_int64", (void**)&napi_create_bigint_int64_ptr},
286
+ {"napi_create_bigint_uint64", (void**)&napi_create_bigint_uint64_ptr},
287
+ {"napi_create_bigint_words", (void**)&napi_create_bigint_words_ptr},
288
+ {"napi_get_all_property_names", (void**)&napi_get_all_property_names_ptr},
289
+ {"napi_get_instance_data", (void**)&napi_get_instance_data_ptr},
290
+ {"napi_get_value_bigint_int64", (void**)&napi_get_value_bigint_int64_ptr},
291
+ {"napi_get_value_bigint_uint64", (void**)&napi_get_value_bigint_uint64_ptr},
292
+ {"napi_get_value_bigint_words", (void**)&napi_get_value_bigint_words_ptr},
293
+ {"napi_set_instance_data", (void**)&napi_set_instance_data_ptr},
294
+ {NULL, NULL} // END MARK
295
+ };
296
+
297
+ static int load_napi_functions_from_module(HMODULE module) {
298
+ if (!module) return 0;
299
+
300
+ int loaded_count = 0;
301
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
302
+ FARPROC proc = GetProcAddress(module, napi_functions[i].name);
303
+ if (proc) {
304
+ *(napi_functions[i].func_ptr) = (void*)proc;
305
+ loaded_count++;
306
+ }
307
+ }
308
+
309
+ return loaded_count;
310
+ }
311
+
312
+ static int discover_and_load_napi_functions() {
313
+ if (napi_functions_loaded) {
314
+ return 1;
315
+ }
316
+
317
+ const char* module_names[] = {
318
+ "node.exe",
319
+ "node.dll",
320
+ "electron.exe",
321
+ "nw.exe",
322
+ NULL
323
+ };
324
+
325
+ HMODULE current_process = GetModuleHandle(NULL);
326
+ if (load_napi_functions_from_module(current_process) > 0) {
327
+ napi_module_handle = current_process;
328
+ napi_functions_loaded = 1;
329
+ return 1;
330
+ }
331
+
332
+ for (int i = 0; module_names[i] != NULL; i++) {
333
+ HMODULE module = GetModuleHandle(module_names[i]);
334
+ if (module && load_napi_functions_from_module(module) > 0) {
335
+ napi_module_handle = module;
336
+ napi_functions_loaded = 1;
337
+ return 1;
338
+ }
339
+ }
340
+
341
+ HMODULE node_dll = LoadLibrary("node.dll");
342
+ if (node_dll && load_napi_functions_from_module(node_dll) > 0) {
343
+ napi_module_handle = node_dll;
344
+ napi_functions_loaded = 1;
345
+ return 1;
346
+ }
347
+
348
+ return 0;
349
+ }
350
+
351
+
352
+ napi_status napi_adjust_external_memory(napi_env env, int64_t change_in_bytes, int64_t* adjusted_value) {
353
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
354
+ return napi_generic_failure;
355
+ }
356
+
357
+ if (!napi_adjust_external_memory_ptr) {
358
+ return napi_generic_failure;
359
+ }
360
+
361
+ return napi_adjust_external_memory_ptr(env, change_in_bytes, adjusted_value);
362
+ }
363
+
364
+ napi_status napi_call_function(napi_env env, napi_value recv, napi_value func, size_t argc, const napi_value* argv, napi_value* result) {
365
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
366
+ return napi_generic_failure;
367
+ }
368
+
369
+ if (!napi_call_function_ptr) {
370
+ return napi_generic_failure;
371
+ }
372
+
373
+ return napi_call_function_ptr(env, recv, func, argc, argv, result);
374
+ }
375
+
376
+ napi_status napi_close_escapable_handle_scope(napi_env env, napi_escapable_handle_scope scope) {
377
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
378
+ return napi_generic_failure;
379
+ }
380
+
381
+ if (!napi_close_escapable_handle_scope_ptr) {
382
+ return napi_generic_failure;
383
+ }
384
+
385
+ return napi_close_escapable_handle_scope_ptr(env, scope);
386
+ }
387
+
388
+ napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope) {
389
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
390
+ return napi_generic_failure;
391
+ }
392
+
393
+ if (!napi_close_handle_scope_ptr) {
394
+ return napi_generic_failure;
395
+ }
396
+
397
+ return napi_close_handle_scope_ptr(env, scope);
398
+ }
399
+
400
+ napi_status napi_coerce_to_bool(napi_env env, napi_value value, napi_value* result) {
401
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
402
+ return napi_generic_failure;
403
+ }
404
+
405
+ if (!napi_coerce_to_bool_ptr) {
406
+ return napi_generic_failure;
407
+ }
408
+
409
+ return napi_coerce_to_bool_ptr(env, value, result);
410
+ }
411
+
412
+ napi_status napi_coerce_to_number(napi_env env, napi_value value, napi_value* result) {
413
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
414
+ return napi_generic_failure;
415
+ }
416
+
417
+ if (!napi_coerce_to_number_ptr) {
418
+ return napi_generic_failure;
419
+ }
420
+
421
+ return napi_coerce_to_number_ptr(env, value, result);
422
+ }
423
+
424
+ napi_status napi_coerce_to_object(napi_env env, napi_value value, napi_value* result) {
425
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
426
+ return napi_generic_failure;
427
+ }
428
+
429
+ if (!napi_coerce_to_object_ptr) {
430
+ return napi_generic_failure;
431
+ }
432
+
433
+ return napi_coerce_to_object_ptr(env, value, result);
434
+ }
435
+
436
+ napi_status napi_coerce_to_string(napi_env env, napi_value value, napi_value* result) {
437
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
438
+ return napi_generic_failure;
439
+ }
440
+
441
+ if (!napi_coerce_to_string_ptr) {
442
+ return napi_generic_failure;
443
+ }
444
+
445
+ return napi_coerce_to_string_ptr(env, value, result);
446
+ }
447
+
448
+ napi_status napi_create_array(napi_env env, napi_value* result) {
449
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
450
+ return napi_generic_failure;
451
+ }
452
+
453
+ if (!napi_create_array_ptr) {
454
+ return napi_generic_failure;
455
+ }
456
+
457
+ return napi_create_array_ptr(env, result);
458
+ }
459
+
460
+ napi_status napi_create_array_with_length(napi_env env, size_t length, napi_value* result) {
461
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
462
+ return napi_generic_failure;
463
+ }
464
+
465
+ if (!napi_create_array_with_length_ptr) {
466
+ return napi_generic_failure;
467
+ }
468
+
469
+ return napi_create_array_with_length_ptr(env, length, result);
470
+ }
471
+
472
+ napi_status napi_create_arraybuffer(napi_env env, size_t byte_length, void** data, napi_value* result) {
473
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
474
+ return napi_generic_failure;
475
+ }
476
+
477
+ if (!napi_create_arraybuffer_ptr) {
478
+ return napi_generic_failure;
479
+ }
480
+
481
+ return napi_create_arraybuffer_ptr(env, byte_length, data, result);
482
+ }
483
+
484
+ napi_status napi_create_dataview(napi_env env, size_t length, napi_value arraybuffer, size_t byte_offset, napi_value* result) {
485
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
486
+ return napi_generic_failure;
487
+ }
488
+
489
+ if (!napi_create_dataview_ptr) {
490
+ return napi_generic_failure;
491
+ }
492
+
493
+ return napi_create_dataview_ptr(env, length, arraybuffer, byte_offset, result);
494
+ }
495
+
496
+ napi_status napi_create_double(napi_env env, double value, napi_value* result) {
497
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
498
+ return napi_generic_failure;
499
+ }
500
+
501
+ if (!napi_create_double_ptr) {
502
+ return napi_generic_failure;
503
+ }
504
+
505
+ return napi_create_double_ptr(env, value, result);
506
+ }
507
+
508
+ napi_status napi_create_error(napi_env env, napi_value code, napi_value msg, napi_value* result) {
509
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
510
+ return napi_generic_failure;
511
+ }
512
+
513
+ if (!napi_create_error_ptr) {
514
+ return napi_generic_failure;
515
+ }
516
+
517
+ return napi_create_error_ptr(env, code, msg, result);
518
+ }
519
+
520
+ napi_status napi_create_external(napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint, napi_value* result) {
521
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
522
+ return napi_generic_failure;
523
+ }
524
+
525
+ if (!napi_create_external_ptr) {
526
+ return napi_generic_failure;
527
+ }
528
+
529
+ return napi_create_external_ptr(env, data, finalize_cb, finalize_hint, result);
530
+ }
531
+
532
+ napi_status napi_create_external_arraybuffer(napi_env env, void* external_data, size_t byte_length, napi_finalize finalize_cb, void* finalize_hint, napi_value* result) {
533
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
534
+ return napi_generic_failure;
535
+ }
536
+
537
+ if (!napi_create_external_arraybuffer_ptr) {
538
+ return napi_generic_failure;
539
+ }
540
+
541
+ return napi_create_external_arraybuffer_ptr(env, external_data, byte_length, finalize_cb, finalize_hint, result);
542
+ }
543
+
544
+ napi_status napi_create_function(napi_env env, const char* utf8name, size_t length, napi_callback cb, void* data, napi_value* result) {
545
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
546
+ return napi_generic_failure;
547
+ }
548
+
549
+ if (!napi_create_function_ptr) {
550
+ return napi_generic_failure;
551
+ }
552
+
553
+ return napi_create_function_ptr(env, utf8name, length, cb, data, result);
554
+ }
555
+
556
+ napi_status napi_create_int32(napi_env env, int32_t value, napi_value* result) {
557
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
558
+ return napi_generic_failure;
559
+ }
560
+
561
+ if (!napi_create_int32_ptr) {
562
+ return napi_generic_failure;
563
+ }
564
+
565
+ return napi_create_int32_ptr(env, value, result);
566
+ }
567
+
568
+ napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result) {
569
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
570
+ return napi_generic_failure;
571
+ }
572
+
573
+ if (!napi_create_int64_ptr) {
574
+ return napi_generic_failure;
575
+ }
576
+
577
+ return napi_create_int64_ptr(env, value, result);
578
+ }
579
+
580
+ napi_status napi_create_object(napi_env env, napi_value* result) {
581
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
582
+ return napi_generic_failure;
583
+ }
584
+
585
+ if (!napi_create_object_ptr) {
586
+ return napi_generic_failure;
587
+ }
588
+
589
+ return napi_create_object_ptr(env, result);
590
+ }
591
+
592
+ napi_status napi_create_promise(napi_env env, napi_deferred* deferred, napi_value* promise) {
593
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
594
+ return napi_generic_failure;
595
+ }
596
+
597
+ if (!napi_create_promise_ptr) {
598
+ return napi_generic_failure;
599
+ }
600
+
601
+ return napi_create_promise_ptr(env, deferred, promise);
602
+ }
603
+
604
+ napi_status napi_create_range_error(napi_env env, napi_value code, napi_value msg, napi_value* result) {
605
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
606
+ return napi_generic_failure;
607
+ }
608
+
609
+ if (!napi_create_range_error_ptr) {
610
+ return napi_generic_failure;
611
+ }
612
+
613
+ return napi_create_range_error_ptr(env, code, msg, result);
614
+ }
615
+
616
+ napi_status napi_create_reference(napi_env env, napi_value value, uint32_t initial_refcount, napi_ref* result) {
617
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
618
+ return napi_generic_failure;
619
+ }
620
+
621
+ if (!napi_create_reference_ptr) {
622
+ return napi_generic_failure;
623
+ }
624
+
625
+ return napi_create_reference_ptr(env, value, initial_refcount, result);
626
+ }
627
+
628
+ napi_status napi_create_string_latin1(napi_env env, const char* str, size_t length, napi_value* result) {
629
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
630
+ return napi_generic_failure;
631
+ }
632
+
633
+ if (!napi_create_string_latin1_ptr) {
634
+ return napi_generic_failure;
635
+ }
636
+
637
+ return napi_create_string_latin1_ptr(env, str, length, result);
638
+ }
639
+
640
+ napi_status napi_create_string_utf16(napi_env env, const char16_t* str, size_t length, napi_value* result) {
641
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
642
+ return napi_generic_failure;
643
+ }
644
+
645
+ if (!napi_create_string_utf16_ptr) {
646
+ return napi_generic_failure;
647
+ }
648
+
649
+ return napi_create_string_utf16_ptr(env, str, length, result);
650
+ }
651
+
652
+ napi_status napi_create_string_utf8(napi_env env, const char* str, size_t length, napi_value* result) {
653
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
654
+ return napi_generic_failure;
655
+ }
656
+
657
+ if (!napi_create_string_utf8_ptr) {
658
+ return napi_generic_failure;
659
+ }
660
+
661
+ return napi_create_string_utf8_ptr(env, str, length, result);
662
+ }
663
+
664
+ napi_status napi_create_symbol(napi_env env, napi_value description, napi_value* result) {
665
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
666
+ return napi_generic_failure;
667
+ }
668
+
669
+ if (!napi_create_symbol_ptr) {
670
+ return napi_generic_failure;
671
+ }
672
+
673
+ return napi_create_symbol_ptr(env, description, result);
674
+ }
675
+
676
+ napi_status napi_create_type_error(napi_env env, napi_value code, napi_value msg, napi_value* result) {
677
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
678
+ return napi_generic_failure;
679
+ }
680
+
681
+ if (!napi_create_type_error_ptr) {
682
+ return napi_generic_failure;
683
+ }
684
+
685
+ return napi_create_type_error_ptr(env, code, msg, result);
686
+ }
687
+
688
+ napi_status napi_create_typedarray(napi_env env, napi_typedarray_type type, size_t length, napi_value arraybuffer, size_t byte_offset, napi_value* result) {
689
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
690
+ return napi_generic_failure;
691
+ }
692
+
693
+ if (!napi_create_typedarray_ptr) {
694
+ return napi_generic_failure;
695
+ }
696
+
697
+ return napi_create_typedarray_ptr(env, type, length, arraybuffer, byte_offset, result);
698
+ }
699
+
700
+ napi_status napi_create_uint32(napi_env env, uint32_t value, napi_value* result) {
701
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
702
+ return napi_generic_failure;
703
+ }
704
+
705
+ if (!napi_create_uint32_ptr) {
706
+ return napi_generic_failure;
707
+ }
708
+
709
+ return napi_create_uint32_ptr(env, value, result);
710
+ }
711
+
712
+ napi_status napi_define_class(napi_env env, const char* utf8name, size_t length, napi_callback constructor, void* data, size_t property_count, const napi_property_descriptor* properties, napi_value* result) {
713
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
714
+ return napi_generic_failure;
715
+ }
716
+
717
+ if (!napi_define_class_ptr) {
718
+ return napi_generic_failure;
719
+ }
720
+
721
+ return napi_define_class_ptr(env, utf8name, length, constructor, data, property_count, properties, result);
722
+ }
723
+
724
+ napi_status napi_define_properties(napi_env env, napi_value object, size_t property_count, const napi_property_descriptor* properties) {
725
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
726
+ return napi_generic_failure;
727
+ }
728
+
729
+ if (!napi_define_properties_ptr) {
730
+ return napi_generic_failure;
731
+ }
732
+
733
+ return napi_define_properties_ptr(env, object, property_count, properties);
734
+ }
735
+
736
+ napi_status napi_delete_element(napi_env env, napi_value object, uint32_t index, bool* result) {
737
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
738
+ return napi_generic_failure;
739
+ }
740
+
741
+ if (!napi_delete_element_ptr) {
742
+ return napi_generic_failure;
743
+ }
744
+
745
+ return napi_delete_element_ptr(env, object, index, result);
746
+ }
747
+
748
+ napi_status napi_delete_property(napi_env env, napi_value object, napi_value key, bool* result) {
749
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
750
+ return napi_generic_failure;
751
+ }
752
+
753
+ if (!napi_delete_property_ptr) {
754
+ return napi_generic_failure;
755
+ }
756
+
757
+ return napi_delete_property_ptr(env, object, key, result);
758
+ }
759
+
760
+ napi_status napi_delete_reference(napi_env env, napi_ref ref) {
761
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
762
+ return napi_generic_failure;
763
+ }
764
+
765
+ if (!napi_delete_reference_ptr) {
766
+ return napi_generic_failure;
767
+ }
768
+
769
+ return napi_delete_reference_ptr(env, ref);
770
+ }
771
+
772
+ napi_status napi_escape_handle(napi_env env, napi_escapable_handle_scope scope, napi_value escapee, napi_value* result) {
773
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
774
+ return napi_generic_failure;
775
+ }
776
+
777
+ if (!napi_escape_handle_ptr) {
778
+ return napi_generic_failure;
779
+ }
780
+
781
+ return napi_escape_handle_ptr(env, scope, escapee, result);
782
+ }
783
+
784
+ napi_status napi_get_and_clear_last_exception(napi_env env, napi_value* result) {
785
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
786
+ return napi_generic_failure;
787
+ }
788
+
789
+ if (!napi_get_and_clear_last_exception_ptr) {
790
+ return napi_generic_failure;
791
+ }
792
+
793
+ return napi_get_and_clear_last_exception_ptr(env, result);
794
+ }
795
+
796
+ napi_status napi_get_array_length(napi_env env, napi_value value, uint32_t* result) {
797
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
798
+ return napi_generic_failure;
799
+ }
800
+
801
+ if (!napi_get_array_length_ptr) {
802
+ return napi_generic_failure;
803
+ }
804
+
805
+ return napi_get_array_length_ptr(env, value, result);
806
+ }
807
+
808
+ napi_status napi_get_arraybuffer_info(napi_env env, napi_value arraybuffer, void** data, size_t* byte_length) {
809
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
810
+ return napi_generic_failure;
811
+ }
812
+
813
+ if (!napi_get_arraybuffer_info_ptr) {
814
+ return napi_generic_failure;
815
+ }
816
+
817
+ return napi_get_arraybuffer_info_ptr(env, arraybuffer, data, byte_length);
818
+ }
819
+
820
+ napi_status napi_get_boolean(napi_env env, bool value, napi_value* result) {
821
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
822
+ return napi_generic_failure;
823
+ }
824
+
825
+ if (!napi_get_boolean_ptr) {
826
+ return napi_generic_failure;
827
+ }
828
+
829
+ return napi_get_boolean_ptr(env, value, result);
830
+ }
831
+
832
+ napi_status napi_get_cb_info(napi_env env, napi_callback_info cbinfo, size_t* argc, napi_value* argv, napi_value* this_arg, void** data) {
833
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
834
+ return napi_generic_failure;
835
+ }
836
+
837
+ if (!napi_get_cb_info_ptr) {
838
+ return napi_generic_failure;
839
+ }
840
+
841
+ return napi_get_cb_info_ptr(env, cbinfo, argc, argv, this_arg, data);
842
+ }
843
+
844
+ napi_status napi_get_dataview_info(napi_env env, napi_value dataview, size_t* bytelength, void** data, napi_value* arraybuffer, size_t* byte_offset) {
845
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
846
+ return napi_generic_failure;
847
+ }
848
+
849
+ if (!napi_get_dataview_info_ptr) {
850
+ return napi_generic_failure;
851
+ }
852
+
853
+ return napi_get_dataview_info_ptr(env, dataview, bytelength, data, arraybuffer, byte_offset);
854
+ }
855
+
856
+ napi_status napi_get_element(napi_env env, napi_value object, uint32_t index, napi_value* result) {
857
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
858
+ return napi_generic_failure;
859
+ }
860
+
861
+ if (!napi_get_element_ptr) {
862
+ return napi_generic_failure;
863
+ }
864
+
865
+ return napi_get_element_ptr(env, object, index, result);
866
+ }
867
+
868
+ napi_status napi_get_global(napi_env env, napi_value* result) {
869
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
870
+ return napi_generic_failure;
871
+ }
872
+
873
+ if (!napi_get_global_ptr) {
874
+ return napi_generic_failure;
875
+ }
876
+
877
+ return napi_get_global_ptr(env, result);
878
+ }
879
+
880
+ napi_status napi_get_last_error_info(napi_env env, const napi_extended_error_info** result) {
881
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
882
+ return napi_generic_failure;
883
+ }
884
+
885
+ if (!napi_get_last_error_info_ptr) {
886
+ return napi_generic_failure;
887
+ }
888
+
889
+ return napi_get_last_error_info_ptr(env, result);
890
+ }
891
+
892
+ napi_status napi_get_named_property(napi_env env, napi_value object, const char* utf8name, napi_value* result) {
893
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
894
+ return napi_generic_failure;
895
+ }
896
+
897
+ if (!napi_get_named_property_ptr) {
898
+ return napi_generic_failure;
899
+ }
900
+
901
+ return napi_get_named_property_ptr(env, object, utf8name, result);
902
+ }
903
+
904
+ napi_status napi_get_new_target(napi_env env, napi_callback_info cbinfo, napi_value* result) {
905
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
906
+ return napi_generic_failure;
907
+ }
908
+
909
+ if (!napi_get_new_target_ptr) {
910
+ return napi_generic_failure;
911
+ }
912
+
913
+ return napi_get_new_target_ptr(env, cbinfo, result);
914
+ }
915
+
916
+ napi_status napi_get_null(napi_env env, napi_value* result) {
917
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
918
+ return napi_generic_failure;
919
+ }
920
+
921
+ if (!napi_get_null_ptr) {
922
+ return napi_generic_failure;
923
+ }
924
+
925
+ return napi_get_null_ptr(env, result);
926
+ }
927
+
928
+ napi_status napi_get_property(napi_env env, napi_value object, napi_value key, napi_value* result) {
929
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
930
+ return napi_generic_failure;
931
+ }
932
+
933
+ if (!napi_get_property_ptr) {
934
+ return napi_generic_failure;
935
+ }
936
+
937
+ return napi_get_property_ptr(env, object, key, result);
938
+ }
939
+
940
+ napi_status napi_get_property_names(napi_env env, napi_value object, napi_value* result) {
941
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
942
+ return napi_generic_failure;
943
+ }
944
+
945
+ if (!napi_get_property_names_ptr) {
946
+ return napi_generic_failure;
947
+ }
948
+
949
+ return napi_get_property_names_ptr(env, object, result);
950
+ }
951
+
952
+ napi_status napi_get_prototype(napi_env env, napi_value object, napi_value* result) {
953
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
954
+ return napi_generic_failure;
955
+ }
956
+
957
+ if (!napi_get_prototype_ptr) {
958
+ return napi_generic_failure;
959
+ }
960
+
961
+ return napi_get_prototype_ptr(env, object, result);
962
+ }
963
+
964
+ napi_status napi_get_reference_value(napi_env env, napi_ref ref, napi_value* result) {
965
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
966
+ return napi_generic_failure;
967
+ }
968
+
969
+ if (!napi_get_reference_value_ptr) {
970
+ return napi_generic_failure;
971
+ }
972
+
973
+ return napi_get_reference_value_ptr(env, ref, result);
974
+ }
975
+
976
+ napi_status napi_get_typedarray_info(napi_env env, napi_value typedarray, napi_typedarray_type* type, size_t* length, void** data, napi_value* arraybuffer, size_t* byte_offset) {
977
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
978
+ return napi_generic_failure;
979
+ }
980
+
981
+ if (!napi_get_typedarray_info_ptr) {
982
+ return napi_generic_failure;
983
+ }
984
+
985
+ return napi_get_typedarray_info_ptr(env, typedarray, type, length, data, arraybuffer, byte_offset);
986
+ }
987
+
988
+ napi_status napi_get_undefined(napi_env env, napi_value* result) {
989
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
990
+ return napi_generic_failure;
991
+ }
992
+
993
+ if (!napi_get_undefined_ptr) {
994
+ return napi_generic_failure;
995
+ }
996
+
997
+ return napi_get_undefined_ptr(env, result);
998
+ }
999
+
1000
+ napi_status napi_get_value_bool(napi_env env, napi_value value, bool* result) {
1001
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1002
+ return napi_generic_failure;
1003
+ }
1004
+
1005
+ if (!napi_get_value_bool_ptr) {
1006
+ return napi_generic_failure;
1007
+ }
1008
+
1009
+ return napi_get_value_bool_ptr(env, value, result);
1010
+ }
1011
+
1012
+ napi_status napi_get_value_double(napi_env env, napi_value value, double* result) {
1013
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1014
+ return napi_generic_failure;
1015
+ }
1016
+
1017
+ if (!napi_get_value_double_ptr) {
1018
+ return napi_generic_failure;
1019
+ }
1020
+
1021
+ return napi_get_value_double_ptr(env, value, result);
1022
+ }
1023
+
1024
+ napi_status napi_get_value_external(napi_env env, napi_value value, void** result) {
1025
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1026
+ return napi_generic_failure;
1027
+ }
1028
+
1029
+ if (!napi_get_value_external_ptr) {
1030
+ return napi_generic_failure;
1031
+ }
1032
+
1033
+ return napi_get_value_external_ptr(env, value, result);
1034
+ }
1035
+
1036
+ napi_status napi_get_value_int32(napi_env env, napi_value value, int32_t* result) {
1037
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1038
+ return napi_generic_failure;
1039
+ }
1040
+
1041
+ if (!napi_get_value_int32_ptr) {
1042
+ return napi_generic_failure;
1043
+ }
1044
+
1045
+ return napi_get_value_int32_ptr(env, value, result);
1046
+ }
1047
+
1048
+ napi_status napi_get_value_int64(napi_env env, napi_value value, int64_t* result) {
1049
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1050
+ return napi_generic_failure;
1051
+ }
1052
+
1053
+ if (!napi_get_value_int64_ptr) {
1054
+ return napi_generic_failure;
1055
+ }
1056
+
1057
+ return napi_get_value_int64_ptr(env, value, result);
1058
+ }
1059
+
1060
+ napi_status napi_get_value_string_latin1(napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result) {
1061
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1062
+ return napi_generic_failure;
1063
+ }
1064
+
1065
+ if (!napi_get_value_string_latin1_ptr) {
1066
+ return napi_generic_failure;
1067
+ }
1068
+
1069
+ return napi_get_value_string_latin1_ptr(env, value, buf, bufsize, result);
1070
+ }
1071
+
1072
+ napi_status napi_get_value_string_utf16(napi_env env, napi_value value, char16_t* buf, size_t bufsize, size_t* result) {
1073
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1074
+ return napi_generic_failure;
1075
+ }
1076
+
1077
+ if (!napi_get_value_string_utf16_ptr) {
1078
+ return napi_generic_failure;
1079
+ }
1080
+
1081
+ return napi_get_value_string_utf16_ptr(env, value, buf, bufsize, result);
1082
+ }
1083
+
1084
+ napi_status napi_get_value_string_utf8(napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result) {
1085
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1086
+ return napi_generic_failure;
1087
+ }
1088
+
1089
+ if (!napi_get_value_string_utf8_ptr) {
1090
+ return napi_generic_failure;
1091
+ }
1092
+
1093
+ return napi_get_value_string_utf8_ptr(env, value, buf, bufsize, result);
1094
+ }
1095
+
1096
+ napi_status napi_get_value_uint32(napi_env env, napi_value value, uint32_t* result) {
1097
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1098
+ return napi_generic_failure;
1099
+ }
1100
+
1101
+ if (!napi_get_value_uint32_ptr) {
1102
+ return napi_generic_failure;
1103
+ }
1104
+
1105
+ return napi_get_value_uint32_ptr(env, value, result);
1106
+ }
1107
+
1108
+ napi_status napi_get_version(napi_env env, uint32_t* result) {
1109
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1110
+ return napi_generic_failure;
1111
+ }
1112
+
1113
+ if (!napi_get_version_ptr) {
1114
+ return napi_generic_failure;
1115
+ }
1116
+
1117
+ return napi_get_version_ptr(env, result);
1118
+ }
1119
+
1120
+ napi_status napi_has_element(napi_env env, napi_value object, uint32_t index, bool* result) {
1121
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1122
+ return napi_generic_failure;
1123
+ }
1124
+
1125
+ if (!napi_has_element_ptr) {
1126
+ return napi_generic_failure;
1127
+ }
1128
+
1129
+ return napi_has_element_ptr(env, object, index, result);
1130
+ }
1131
+
1132
+ napi_status napi_has_named_property(napi_env env, napi_value object, const char* utf8name, bool* result) {
1133
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1134
+ return napi_generic_failure;
1135
+ }
1136
+
1137
+ if (!napi_has_named_property_ptr) {
1138
+ return napi_generic_failure;
1139
+ }
1140
+
1141
+ return napi_has_named_property_ptr(env, object, utf8name, result);
1142
+ }
1143
+
1144
+ napi_status napi_has_own_property(napi_env env, napi_value object, napi_value key, bool* result) {
1145
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1146
+ return napi_generic_failure;
1147
+ }
1148
+
1149
+ if (!napi_has_own_property_ptr) {
1150
+ return napi_generic_failure;
1151
+ }
1152
+
1153
+ return napi_has_own_property_ptr(env, object, key, result);
1154
+ }
1155
+
1156
+ napi_status napi_has_property(napi_env env, napi_value object, napi_value key, bool* result) {
1157
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1158
+ return napi_generic_failure;
1159
+ }
1160
+
1161
+ if (!napi_has_property_ptr) {
1162
+ return napi_generic_failure;
1163
+ }
1164
+
1165
+ return napi_has_property_ptr(env, object, key, result);
1166
+ }
1167
+
1168
+ napi_status napi_instanceof(napi_env env, napi_value object, napi_value constructor, bool* result) {
1169
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1170
+ return napi_generic_failure;
1171
+ }
1172
+
1173
+ if (!napi_instanceof_ptr) {
1174
+ return napi_generic_failure;
1175
+ }
1176
+
1177
+ return napi_instanceof_ptr(env, object, constructor, result);
1178
+ }
1179
+
1180
+ napi_status napi_is_array(napi_env env, napi_value value, bool* result) {
1181
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1182
+ return napi_generic_failure;
1183
+ }
1184
+
1185
+ if (!napi_is_array_ptr) {
1186
+ return napi_generic_failure;
1187
+ }
1188
+
1189
+ return napi_is_array_ptr(env, value, result);
1190
+ }
1191
+
1192
+ napi_status napi_is_arraybuffer(napi_env env, napi_value value, bool* result) {
1193
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1194
+ return napi_generic_failure;
1195
+ }
1196
+
1197
+ if (!napi_is_arraybuffer_ptr) {
1198
+ return napi_generic_failure;
1199
+ }
1200
+
1201
+ return napi_is_arraybuffer_ptr(env, value, result);
1202
+ }
1203
+
1204
+ napi_status napi_is_dataview(napi_env env, napi_value value, bool* result) {
1205
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1206
+ return napi_generic_failure;
1207
+ }
1208
+
1209
+ if (!napi_is_dataview_ptr) {
1210
+ return napi_generic_failure;
1211
+ }
1212
+
1213
+ return napi_is_dataview_ptr(env, value, result);
1214
+ }
1215
+
1216
+ napi_status napi_is_error(napi_env env, napi_value value, bool* result) {
1217
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1218
+ return napi_generic_failure;
1219
+ }
1220
+
1221
+ if (!napi_is_error_ptr) {
1222
+ return napi_generic_failure;
1223
+ }
1224
+
1225
+ return napi_is_error_ptr(env, value, result);
1226
+ }
1227
+
1228
+ napi_status napi_is_exception_pending(napi_env env, bool* result) {
1229
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1230
+ return napi_generic_failure;
1231
+ }
1232
+
1233
+ if (!napi_is_exception_pending_ptr) {
1234
+ return napi_generic_failure;
1235
+ }
1236
+
1237
+ return napi_is_exception_pending_ptr(env, result);
1238
+ }
1239
+
1240
+ napi_status napi_is_promise(napi_env env, napi_value value, bool* is_promise) {
1241
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1242
+ return napi_generic_failure;
1243
+ }
1244
+
1245
+ if (!napi_is_promise_ptr) {
1246
+ return napi_generic_failure;
1247
+ }
1248
+
1249
+ return napi_is_promise_ptr(env, value, is_promise);
1250
+ }
1251
+
1252
+ napi_status napi_is_typedarray(napi_env env, napi_value value, bool* result) {
1253
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1254
+ return napi_generic_failure;
1255
+ }
1256
+
1257
+ if (!napi_is_typedarray_ptr) {
1258
+ return napi_generic_failure;
1259
+ }
1260
+
1261
+ return napi_is_typedarray_ptr(env, value, result);
1262
+ }
1263
+
1264
+ napi_status napi_new_instance(napi_env env, napi_value constructor, size_t argc, const napi_value* argv, napi_value* result) {
1265
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1266
+ return napi_generic_failure;
1267
+ }
1268
+
1269
+ if (!napi_new_instance_ptr) {
1270
+ return napi_generic_failure;
1271
+ }
1272
+
1273
+ return napi_new_instance_ptr(env, constructor, argc, argv, result);
1274
+ }
1275
+
1276
+ napi_status napi_open_escapable_handle_scope(napi_env env, napi_escapable_handle_scope* result) {
1277
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1278
+ return napi_generic_failure;
1279
+ }
1280
+
1281
+ if (!napi_open_escapable_handle_scope_ptr) {
1282
+ return napi_generic_failure;
1283
+ }
1284
+
1285
+ return napi_open_escapable_handle_scope_ptr(env, result);
1286
+ }
1287
+
1288
+ napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* result) {
1289
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1290
+ return napi_generic_failure;
1291
+ }
1292
+
1293
+ if (!napi_open_handle_scope_ptr) {
1294
+ return napi_generic_failure;
1295
+ }
1296
+
1297
+ return napi_open_handle_scope_ptr(env, result);
1298
+ }
1299
+
1300
+ napi_status napi_reference_ref(napi_env env, napi_ref ref, uint32_t* result) {
1301
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1302
+ return napi_generic_failure;
1303
+ }
1304
+
1305
+ if (!napi_reference_ref_ptr) {
1306
+ return napi_generic_failure;
1307
+ }
1308
+
1309
+ return napi_reference_ref_ptr(env, ref, result);
1310
+ }
1311
+
1312
+ napi_status napi_reference_unref(napi_env env, napi_ref ref, uint32_t* result) {
1313
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1314
+ return napi_generic_failure;
1315
+ }
1316
+
1317
+ if (!napi_reference_unref_ptr) {
1318
+ return napi_generic_failure;
1319
+ }
1320
+
1321
+ return napi_reference_unref_ptr(env, ref, result);
1322
+ }
1323
+
1324
+ napi_status napi_reject_deferred(napi_env env, napi_deferred deferred, napi_value rejection) {
1325
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1326
+ return napi_generic_failure;
1327
+ }
1328
+
1329
+ if (!napi_reject_deferred_ptr) {
1330
+ return napi_generic_failure;
1331
+ }
1332
+
1333
+ return napi_reject_deferred_ptr(env, deferred, rejection);
1334
+ }
1335
+
1336
+ napi_status napi_remove_wrap(napi_env env, napi_value js_object, void** result) {
1337
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1338
+ return napi_generic_failure;
1339
+ }
1340
+
1341
+ if (!napi_remove_wrap_ptr) {
1342
+ return napi_generic_failure;
1343
+ }
1344
+
1345
+ return napi_remove_wrap_ptr(env, js_object, result);
1346
+ }
1347
+
1348
+ napi_status napi_resolve_deferred(napi_env env, napi_deferred deferred, napi_value resolution) {
1349
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1350
+ return napi_generic_failure;
1351
+ }
1352
+
1353
+ if (!napi_resolve_deferred_ptr) {
1354
+ return napi_generic_failure;
1355
+ }
1356
+
1357
+ return napi_resolve_deferred_ptr(env, deferred, resolution);
1358
+ }
1359
+
1360
+ napi_status napi_run_script(napi_env env, napi_value script, napi_value* result) {
1361
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1362
+ return napi_generic_failure;
1363
+ }
1364
+
1365
+ if (!napi_run_script_ptr) {
1366
+ return napi_generic_failure;
1367
+ }
1368
+
1369
+ return napi_run_script_ptr(env, script, result);
1370
+ }
1371
+
1372
+ napi_status napi_set_element(napi_env env, napi_value object, uint32_t index, napi_value value) {
1373
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1374
+ return napi_generic_failure;
1375
+ }
1376
+
1377
+ if (!napi_set_element_ptr) {
1378
+ return napi_generic_failure;
1379
+ }
1380
+
1381
+ return napi_set_element_ptr(env, object, index, value);
1382
+ }
1383
+
1384
+ napi_status napi_set_named_property(napi_env env, napi_value object, const char* utf8name, napi_value value) {
1385
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1386
+ return napi_generic_failure;
1387
+ }
1388
+
1389
+ if (!napi_set_named_property_ptr) {
1390
+ return napi_generic_failure;
1391
+ }
1392
+
1393
+ return napi_set_named_property_ptr(env, object, utf8name, value);
1394
+ }
1395
+
1396
+ napi_status napi_set_property(napi_env env, napi_value object, napi_value key, napi_value value) {
1397
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1398
+ return napi_generic_failure;
1399
+ }
1400
+
1401
+ if (!napi_set_property_ptr) {
1402
+ return napi_generic_failure;
1403
+ }
1404
+
1405
+ return napi_set_property_ptr(env, object, key, value);
1406
+ }
1407
+
1408
+ napi_status napi_strict_equals(napi_env env, napi_value lhs, napi_value rhs, bool* result) {
1409
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1410
+ return napi_generic_failure;
1411
+ }
1412
+
1413
+ if (!napi_strict_equals_ptr) {
1414
+ return napi_generic_failure;
1415
+ }
1416
+
1417
+ return napi_strict_equals_ptr(env, lhs, rhs, result);
1418
+ }
1419
+
1420
+ napi_status napi_throw(napi_env env, napi_value error) {
1421
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1422
+ return napi_generic_failure;
1423
+ }
1424
+
1425
+ if (!napi_throw_ptr) {
1426
+ return napi_generic_failure;
1427
+ }
1428
+
1429
+ return napi_throw_ptr(env, error);
1430
+ }
1431
+
1432
+ napi_status napi_throw_error(napi_env env, const char* code, const char* msg) {
1433
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1434
+ return napi_generic_failure;
1435
+ }
1436
+
1437
+ if (!napi_throw_error_ptr) {
1438
+ return napi_generic_failure;
1439
+ }
1440
+
1441
+ return napi_throw_error_ptr(env, code, msg);
1442
+ }
1443
+
1444
+ napi_status napi_throw_range_error(napi_env env, const char* code, const char* msg) {
1445
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1446
+ return napi_generic_failure;
1447
+ }
1448
+
1449
+ if (!napi_throw_range_error_ptr) {
1450
+ return napi_generic_failure;
1451
+ }
1452
+
1453
+ return napi_throw_range_error_ptr(env, code, msg);
1454
+ }
1455
+
1456
+ napi_status napi_throw_type_error(napi_env env, const char* code, const char* msg) {
1457
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1458
+ return napi_generic_failure;
1459
+ }
1460
+
1461
+ if (!napi_throw_type_error_ptr) {
1462
+ return napi_generic_failure;
1463
+ }
1464
+
1465
+ return napi_throw_type_error_ptr(env, code, msg);
1466
+ }
1467
+
1468
+ napi_status napi_typeof(napi_env env, napi_value value, napi_valuetype* result) {
1469
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1470
+ return napi_generic_failure;
1471
+ }
1472
+
1473
+ if (!napi_typeof_ptr) {
1474
+ return napi_generic_failure;
1475
+ }
1476
+
1477
+ return napi_typeof_ptr(env, value, result);
1478
+ }
1479
+
1480
+ napi_status napi_unwrap(napi_env env, napi_value js_object, void** result) {
1481
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1482
+ return napi_generic_failure;
1483
+ }
1484
+
1485
+ if (!napi_unwrap_ptr) {
1486
+ return napi_generic_failure;
1487
+ }
1488
+
1489
+ return napi_unwrap_ptr(env, js_object, result);
1490
+ }
1491
+
1492
+ napi_status napi_wrap(napi_env env, napi_value js_object, void* native_object, napi_finalize finalize_cb, void* finalize_hint, napi_ref* result) {
1493
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1494
+ return napi_generic_failure;
1495
+ }
1496
+
1497
+ if (!napi_wrap_ptr) {
1498
+ return napi_generic_failure;
1499
+ }
1500
+
1501
+ return napi_wrap_ptr(env, js_object, native_object, finalize_cb, finalize_hint, result);
1502
+ }
1503
+
1504
+ napi_status napi_async_destroy(napi_env env, napi_async_context async_context) {
1505
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1506
+ return napi_generic_failure;
1507
+ }
1508
+
1509
+ if (!napi_async_destroy_ptr) {
1510
+ return napi_generic_failure;
1511
+ }
1512
+
1513
+ return napi_async_destroy_ptr(env, async_context);
1514
+ }
1515
+
1516
+ napi_status napi_async_init(napi_env env, napi_value async_resource, napi_value async_resource_name, napi_async_context* result) {
1517
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1518
+ return napi_generic_failure;
1519
+ }
1520
+
1521
+ if (!napi_async_init_ptr) {
1522
+ return napi_generic_failure;
1523
+ }
1524
+
1525
+ return napi_async_init_ptr(env, async_resource, async_resource_name, result);
1526
+ }
1527
+
1528
+ napi_status napi_cancel_async_work(napi_env env, napi_async_work work) {
1529
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1530
+ return napi_generic_failure;
1531
+ }
1532
+
1533
+ if (!napi_cancel_async_work_ptr) {
1534
+ return napi_generic_failure;
1535
+ }
1536
+
1537
+ return napi_cancel_async_work_ptr(env, work);
1538
+ }
1539
+
1540
+ napi_status napi_create_async_work(napi_env env, napi_value async_resource, napi_value async_resource_name, napi_async_execute_callback execute, napi_async_complete_callback complete, void* data, napi_async_work* result) {
1541
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1542
+ return napi_generic_failure;
1543
+ }
1544
+
1545
+ if (!napi_create_async_work_ptr) {
1546
+ return napi_generic_failure;
1547
+ }
1548
+
1549
+ return napi_create_async_work_ptr(env, async_resource, async_resource_name, execute, complete, data, result);
1550
+ }
1551
+
1552
+ napi_status napi_create_buffer(napi_env env, size_t length, void** data, napi_value* result) {
1553
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1554
+ return napi_generic_failure;
1555
+ }
1556
+
1557
+ if (!napi_create_buffer_ptr) {
1558
+ return napi_generic_failure;
1559
+ }
1560
+
1561
+ return napi_create_buffer_ptr(env, length, data, result);
1562
+ }
1563
+
1564
+ napi_status napi_create_buffer_copy(napi_env env, size_t length, const void* data, void** result_data, napi_value* result) {
1565
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1566
+ return napi_generic_failure;
1567
+ }
1568
+
1569
+ if (!napi_create_buffer_copy_ptr) {
1570
+ return napi_generic_failure;
1571
+ }
1572
+
1573
+ return napi_create_buffer_copy_ptr(env, length, data, result_data, result);
1574
+ }
1575
+
1576
+ napi_status napi_create_external_buffer(napi_env env, size_t length, void* data, napi_finalize finalize_cb, void* finalize_hint, napi_value* result) {
1577
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1578
+ return napi_generic_failure;
1579
+ }
1580
+
1581
+ if (!napi_create_external_buffer_ptr) {
1582
+ return napi_generic_failure;
1583
+ }
1584
+
1585
+ return napi_create_external_buffer_ptr(env, length, data, finalize_cb, finalize_hint, result);
1586
+ }
1587
+
1588
+ napi_status napi_delete_async_work(napi_env env, napi_async_work work) {
1589
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1590
+ return napi_generic_failure;
1591
+ }
1592
+
1593
+ if (!napi_delete_async_work_ptr) {
1594
+ return napi_generic_failure;
1595
+ }
1596
+
1597
+ return napi_delete_async_work_ptr(env, work);
1598
+ }
1599
+
1600
+ void napi_fatal_error(const char* location, size_t location_len, const char* message, size_t message_len) {
1601
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1602
+ return;
1603
+ }
1604
+
1605
+ if (!napi_fatal_error_ptr) {
1606
+ return;
1607
+ }
1608
+
1609
+ napi_fatal_error_ptr(location, location_len, message, message_len);
1610
+ }
1611
+
1612
+ napi_status napi_get_buffer_info(napi_env env, napi_value value, void** data, size_t* length) {
1613
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1614
+ return napi_generic_failure;
1615
+ }
1616
+
1617
+ if (!napi_get_buffer_info_ptr) {
1618
+ return napi_generic_failure;
1619
+ }
1620
+
1621
+ return napi_get_buffer_info_ptr(env, value, data, length);
1622
+ }
1623
+
1624
+ napi_status napi_get_node_version(napi_env env, const napi_node_version** version) {
1625
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1626
+ return napi_generic_failure;
1627
+ }
1628
+
1629
+ if (!napi_get_node_version_ptr) {
1630
+ return napi_generic_failure;
1631
+ }
1632
+
1633
+ return napi_get_node_version_ptr(env, version);
1634
+ }
1635
+
1636
+ napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) {
1637
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1638
+ return napi_generic_failure;
1639
+ }
1640
+
1641
+ if (!napi_is_buffer_ptr) {
1642
+ return napi_generic_failure;
1643
+ }
1644
+
1645
+ return napi_is_buffer_ptr(env, value, result);
1646
+ }
1647
+
1648
+ napi_status napi_make_callback(napi_env env, napi_async_context async_context, napi_value recv, napi_value func, size_t argc, const napi_value* argv, napi_value* result) {
1649
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1650
+ return napi_generic_failure;
1651
+ }
1652
+
1653
+ if (!napi_make_callback_ptr) {
1654
+ return napi_generic_failure;
1655
+ }
1656
+
1657
+ return napi_make_callback_ptr(env, async_context, recv, func, argc, argv, result);
1658
+ }
1659
+
1660
+ void napi_module_register(napi_module* mod) {
1661
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1662
+ return;
1663
+ }
1664
+
1665
+ if (!napi_module_register_ptr) {
1666
+ return;
1667
+ }
1668
+
1669
+ napi_module_register_ptr(mod);
1670
+ }
1671
+
1672
+ napi_status napi_queue_async_work(napi_env env, napi_async_work work) {
1673
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1674
+ return napi_generic_failure;
1675
+ }
1676
+
1677
+ if (!napi_queue_async_work_ptr) {
1678
+ return napi_generic_failure;
1679
+ }
1680
+
1681
+ return napi_queue_async_work_ptr(env, work);
1682
+ }
1683
+
1684
+ napi_status napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop) {
1685
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1686
+ return napi_generic_failure;
1687
+ }
1688
+
1689
+ if (!napi_get_uv_event_loop_ptr) {
1690
+ return napi_generic_failure;
1691
+ }
1692
+
1693
+ return napi_get_uv_event_loop_ptr(env, loop);
1694
+ }
1695
+
1696
+ napi_status napi_add_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg) {
1697
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1698
+ return napi_generic_failure;
1699
+ }
1700
+
1701
+ if (!napi_add_env_cleanup_hook_ptr) {
1702
+ return napi_generic_failure;
1703
+ }
1704
+
1705
+ return napi_add_env_cleanup_hook_ptr(env, fun, arg);
1706
+ }
1707
+
1708
+ napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) {
1709
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1710
+ return napi_generic_failure;
1711
+ }
1712
+
1713
+ if (!napi_close_callback_scope_ptr) {
1714
+ return napi_generic_failure;
1715
+ }
1716
+
1717
+ return napi_close_callback_scope_ptr(env, scope);
1718
+ }
1719
+
1720
+ napi_status napi_fatal_exception(napi_env env, napi_value err) {
1721
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1722
+ return napi_generic_failure;
1723
+ }
1724
+
1725
+ if (!napi_fatal_exception_ptr) {
1726
+ return napi_generic_failure;
1727
+ }
1728
+
1729
+ return napi_fatal_exception_ptr(env, err);
1730
+ }
1731
+
1732
+ napi_status napi_open_callback_scope(napi_env env, napi_value resource_object, napi_async_context context, napi_callback_scope* result) {
1733
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1734
+ return napi_generic_failure;
1735
+ }
1736
+
1737
+ if (!napi_open_callback_scope_ptr) {
1738
+ return napi_generic_failure;
1739
+ }
1740
+
1741
+ return napi_open_callback_scope_ptr(env, resource_object, context, result);
1742
+ }
1743
+
1744
+ napi_status napi_remove_env_cleanup_hook(napi_env env, napi_cleanup_hook fun, void* arg) {
1745
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1746
+ return napi_generic_failure;
1747
+ }
1748
+
1749
+ if (!napi_remove_env_cleanup_hook_ptr) {
1750
+ return napi_generic_failure;
1751
+ }
1752
+
1753
+ return napi_remove_env_cleanup_hook_ptr(env, fun, arg);
1754
+ }
1755
+
1756
+ napi_status napi_acquire_threadsafe_function(napi_threadsafe_function func) {
1757
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1758
+ return napi_generic_failure;
1759
+ }
1760
+
1761
+ if (!napi_acquire_threadsafe_function_ptr) {
1762
+ return napi_generic_failure;
1763
+ }
1764
+
1765
+ return napi_acquire_threadsafe_function_ptr(func);
1766
+ }
1767
+
1768
+ napi_status napi_call_threadsafe_function(napi_threadsafe_function func, void* data, napi_threadsafe_function_call_mode is_blocking) {
1769
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1770
+ return napi_generic_failure;
1771
+ }
1772
+
1773
+ if (!napi_call_threadsafe_function_ptr) {
1774
+ return napi_generic_failure;
1775
+ }
1776
+
1777
+ return napi_call_threadsafe_function_ptr(func, data, is_blocking);
1778
+ }
1779
+
1780
+ napi_status napi_create_threadsafe_function(napi_env env, napi_value func, napi_value async_resource, napi_value async_resource_name, size_t max_queue_size, size_t initial_thread_count, void* thread_finalize_data, napi_finalize thread_finalize_cb, void* context, napi_threadsafe_function_call_js call_js_cb, napi_threadsafe_function* result) {
1781
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1782
+ return napi_generic_failure;
1783
+ }
1784
+
1785
+ if (!napi_create_threadsafe_function_ptr) {
1786
+ return napi_generic_failure;
1787
+ }
1788
+
1789
+ return napi_create_threadsafe_function_ptr(env, func, async_resource, async_resource_name, max_queue_size, initial_thread_count, thread_finalize_data, thread_finalize_cb, context, call_js_cb, result);
1790
+ }
1791
+
1792
+ napi_status napi_get_threadsafe_function_context(napi_threadsafe_function func, void** result) {
1793
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1794
+ return napi_generic_failure;
1795
+ }
1796
+
1797
+ if (!napi_get_threadsafe_function_context_ptr) {
1798
+ return napi_generic_failure;
1799
+ }
1800
+
1801
+ return napi_get_threadsafe_function_context_ptr(func, result);
1802
+ }
1803
+
1804
+ napi_status napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
1805
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1806
+ return napi_generic_failure;
1807
+ }
1808
+
1809
+ if (!napi_ref_threadsafe_function_ptr) {
1810
+ return napi_generic_failure;
1811
+ }
1812
+
1813
+ return napi_ref_threadsafe_function_ptr(env, func);
1814
+ }
1815
+
1816
+ napi_status napi_release_threadsafe_function(napi_threadsafe_function func, napi_threadsafe_function_release_mode mode) {
1817
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1818
+ return napi_generic_failure;
1819
+ }
1820
+
1821
+ if (!napi_release_threadsafe_function_ptr) {
1822
+ return napi_generic_failure;
1823
+ }
1824
+
1825
+ return napi_release_threadsafe_function_ptr(func, mode);
1826
+ }
1827
+
1828
+ napi_status napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func) {
1829
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1830
+ return napi_generic_failure;
1831
+ }
1832
+
1833
+ if (!napi_unref_threadsafe_function_ptr) {
1834
+ return napi_generic_failure;
1835
+ }
1836
+
1837
+ return napi_unref_threadsafe_function_ptr(env, func);
1838
+ }
1839
+
1840
+ napi_status napi_add_finalizer(napi_env env, napi_value js_object, void* finalize_data, napi_finalize finalize_cb, void* finalize_hint, napi_ref* result) {
1841
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1842
+ return napi_generic_failure;
1843
+ }
1844
+
1845
+ if (!napi_add_finalizer_ptr) {
1846
+ return napi_generic_failure;
1847
+ }
1848
+
1849
+ return napi_add_finalizer_ptr(env, js_object, finalize_data, finalize_cb, finalize_hint, result);
1850
+ }
1851
+
1852
+ napi_status napi_create_date(napi_env env, double time, napi_value* result) {
1853
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1854
+ return napi_generic_failure;
1855
+ }
1856
+
1857
+ if (!napi_create_date_ptr) {
1858
+ return napi_generic_failure;
1859
+ }
1860
+
1861
+ return napi_create_date_ptr(env, time, result);
1862
+ }
1863
+
1864
+ napi_status napi_get_date_value(napi_env env, napi_value value, double* result) {
1865
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1866
+ return napi_generic_failure;
1867
+ }
1868
+
1869
+ if (!napi_get_date_value_ptr) {
1870
+ return napi_generic_failure;
1871
+ }
1872
+
1873
+ return napi_get_date_value_ptr(env, value, result);
1874
+ }
1875
+
1876
+ napi_status napi_is_date(napi_env env, napi_value value, bool* is_date) {
1877
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1878
+ return napi_generic_failure;
1879
+ }
1880
+
1881
+ if (!napi_is_date_ptr) {
1882
+ return napi_generic_failure;
1883
+ }
1884
+
1885
+ return napi_is_date_ptr(env, value, is_date);
1886
+ }
1887
+
1888
+ napi_status napi_create_bigint_int64(napi_env env, int64_t value, napi_value* result) {
1889
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1890
+ return napi_generic_failure;
1891
+ }
1892
+
1893
+ if (!napi_create_bigint_int64_ptr) {
1894
+ return napi_generic_failure;
1895
+ }
1896
+
1897
+ return napi_create_bigint_int64_ptr(env, value, result);
1898
+ }
1899
+
1900
+ napi_status napi_create_bigint_uint64(napi_env env, uint64_t value, napi_value* result) {
1901
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1902
+ return napi_generic_failure;
1903
+ }
1904
+
1905
+ if (!napi_create_bigint_uint64_ptr) {
1906
+ return napi_generic_failure;
1907
+ }
1908
+
1909
+ return napi_create_bigint_uint64_ptr(env, value, result);
1910
+ }
1911
+
1912
+ napi_status napi_create_bigint_words(napi_env env, int sign_bit, size_t word_count, const uint64_t* words, napi_value* result) {
1913
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1914
+ return napi_generic_failure;
1915
+ }
1916
+
1917
+ if (!napi_create_bigint_words_ptr) {
1918
+ return napi_generic_failure;
1919
+ }
1920
+
1921
+ return napi_create_bigint_words_ptr(env, sign_bit, word_count, words, result);
1922
+ }
1923
+
1924
+ napi_status napi_get_all_property_names(napi_env env, napi_value object, napi_key_collection_mode key_mode, napi_key_filter key_filter, napi_key_conversion key_conversion, napi_value* result) {
1925
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1926
+ return napi_generic_failure;
1927
+ }
1928
+
1929
+ if (!napi_get_all_property_names_ptr) {
1930
+ return napi_generic_failure;
1931
+ }
1932
+
1933
+ return napi_get_all_property_names_ptr(env, object, key_mode, key_filter, key_conversion, result);
1934
+ }
1935
+
1936
+ napi_status napi_get_instance_data(napi_env env, void** data) {
1937
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1938
+ return napi_generic_failure;
1939
+ }
1940
+
1941
+ if (!napi_get_instance_data_ptr) {
1942
+ return napi_generic_failure;
1943
+ }
1944
+
1945
+ return napi_get_instance_data_ptr(env, data);
1946
+ }
1947
+
1948
+ napi_status napi_get_value_bigint_int64(napi_env env, napi_value value, int64_t* result, bool* lossless) {
1949
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1950
+ return napi_generic_failure;
1951
+ }
1952
+
1953
+ if (!napi_get_value_bigint_int64_ptr) {
1954
+ return napi_generic_failure;
1955
+ }
1956
+
1957
+ return napi_get_value_bigint_int64_ptr(env, value, result, lossless);
1958
+ }
1959
+
1960
+ napi_status napi_get_value_bigint_uint64(napi_env env, napi_value value, uint64_t* result, bool* lossless) {
1961
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1962
+ return napi_generic_failure;
1963
+ }
1964
+
1965
+ if (!napi_get_value_bigint_uint64_ptr) {
1966
+ return napi_generic_failure;
1967
+ }
1968
+
1969
+ return napi_get_value_bigint_uint64_ptr(env, value, result, lossless);
1970
+ }
1971
+
1972
+ napi_status napi_get_value_bigint_words(napi_env env, napi_value value, int* sign_bit, size_t* word_count, uint64_t* words) {
1973
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1974
+ return napi_generic_failure;
1975
+ }
1976
+
1977
+ if (!napi_get_value_bigint_words_ptr) {
1978
+ return napi_generic_failure;
1979
+ }
1980
+
1981
+ return napi_get_value_bigint_words_ptr(env, value, sign_bit, word_count, words);
1982
+ }
1983
+
1984
+ napi_status napi_set_instance_data(napi_env env, void* data, napi_finalize finalize_cb, void* finalize_hint) {
1985
+ if (!napi_functions_loaded && !discover_and_load_napi_functions()) {
1986
+ return napi_generic_failure;
1987
+ }
1988
+
1989
+ if (!napi_set_instance_data_ptr) {
1990
+ return napi_generic_failure;
1991
+ }
1992
+
1993
+ return napi_set_instance_data_ptr(env, data, finalize_cb, finalize_hint);
1994
+ }
1995
+
1996
+ __attribute__((constructor))
1997
+ static void init_napi_dynamic_load() {
1998
+ discover_and_load_napi_functions();
1999
+ }
2000
+
2001
+ __attribute__((destructor))
2002
+ static void cleanup_napi_dynamic_load() {
2003
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
2004
+ *(napi_functions[i].func_ptr) = NULL;
2005
+ }
2006
+
2007
+ napi_module_handle = NULL;
2008
+ napi_functions_loaded = 0;
2009
+ }
2010
+
2011
+ int napi_dynamic_load_init() {
2012
+ return discover_and_load_napi_functions();
2013
+ }
2014
+
2015
+ int napi_dynamic_load_is_loaded() {
2016
+ return napi_functions_loaded;
2017
+ }
2018
+
2019
+ int napi_dynamic_load_get_function_count() {
2020
+ int count = 0;
2021
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
2022
+ if (*(napi_functions[i].func_ptr) != NULL) {
2023
+ count++;
2024
+ }
2025
+ }
2026
+ return count;
2027
+ }
2028
+
2029
+ int napi_dynamic_load_is_function_available(const char* function_name) {
2030
+ if (!function_name) return 0;
2031
+
2032
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
2033
+ if (strcmp(napi_functions[i].name, function_name) == 0) {
2034
+ return *(napi_functions[i].func_ptr) != NULL;
2035
+ }
2036
+ }
2037
+
2038
+ return 0;
2039
+ }
2040
+
2041
+ const char* napi_dynamic_load_get_version(void) {
2042
+ return "1.0.0 (NAPI v6 compatible)";
2043
+ }
2044
+
2045
+ int napi_dynamic_load_get_status_info(char* buffer, size_t buffer_size) {
2046
+ if (!buffer || buffer_size == 0) {
2047
+ return -1;
2048
+ }
2049
+
2050
+ char temp[2048] = {0};
2051
+ int len = 0;
2052
+
2053
+ len += snprintf(temp + len, sizeof(temp) - len,
2054
+ "NAPI Dynamic Load Status:\n");
2055
+ len += snprintf(temp + len, sizeof(temp) - len,
2056
+ " Loaded: %s\n", napi_functions_loaded ? "Yes" : "No");
2057
+ len += snprintf(temp + len, sizeof(temp) - len,
2058
+ " Module Handle: %p\n", (void*)napi_module_handle);
2059
+
2060
+ int total_functions = 0;
2061
+ int loaded_functions = 0;
2062
+
2063
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
2064
+ total_functions++;
2065
+ if (*(napi_functions[i].func_ptr) != NULL) {
2066
+ loaded_functions++;
2067
+ }
2068
+ }
2069
+
2070
+ len += snprintf(temp + len, sizeof(temp) - len,
2071
+ " Functions: %d/%d loaded\n", loaded_functions, total_functions);
2072
+
2073
+ if (len >= buffer_size) {
2074
+ return -((int)buffer_size);
2075
+ }
2076
+
2077
+ strcpy(buffer, temp);
2078
+ return len;
2079
+ }
2080
+
2081
+ int napi_dynamic_load_reload(void) {
2082
+ napi_functions_loaded = 0;
2083
+ napi_module_handle = NULL;
2084
+
2085
+ for (int i = 0; napi_functions[i].name != NULL; i++) {
2086
+ *(napi_functions[i].func_ptr) = NULL;
2087
+ }
2088
+
2089
+ return discover_and_load_napi_functions();
2090
+ }
2091
+
2092
+ __attribute__((visibility("default")))
2093
+ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
2094
+ switch (fdwReason) {
2095
+ case DLL_PROCESS_ATTACH:
2096
+ napi_dynamic_load_init();
2097
+ break;
2098
+ }
2099
+ return TRUE;
2100
+ }
2101
+
2102
+ #endif // _WIN32