1 /* 2 * Copyright (C) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef NAPI_NATIVE_API_H 17 #define NAPI_NATIVE_API_H 18 19 struct napi_env {}; 20 using napi_value = void *; 21 enum napi_status { 22 napi_ok = 0, 23 napi_invalid_arg, 24 }; 25 struct napi_async_work {}; 26 struct napi_deferred {}; 27 using napi_ref = int; 28 struct uv_work_t { 29 void *data; 30 }; 31 struct napi_callback_info {}; 32 using napi_handle_scope = void *; 33 typedef enum { 34 napi_undefined, 35 napi_null, 36 } napi_valuetype; 37 38 napi_status napi_create_reference(napi_env env, napi_value value, uint32_t initial_refcount, napi_ref* result); 39 napi_status napi_get_reference_value(napi_env env, napi_ref ref, napi_value* result); 40 napi_status napi_call_function(napi_env env, napi_value recv, napi_value func, size_t argc, 41 const napi_value* argv, napi_value* result); 42 napi_status napi_is_exception_pending(napi_env env, bool* result); 43 napi_status napi_delete_reference(napi_env env, napi_ref ref); 44 napi_status napi_get_and_clear_last_exception(napi_env env, napi_value* result); 45 napi_status napi_strict_equals(napi_env env, napi_value lhs, napi_value rhs, bool* result); 46 napi_status napi_create_promise(napi_env env, napi_deferred* deferred, napi_value* promise); 47 napi_status napi_resolve_deferred(napi_env env, napi_deferred deferred, napi_value resolution); 48 napi_status napi_reject_deferred(napi_env env, napi_deferred deferred, napi_value rejection); 49 napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* result); 50 napi_status napi_get_cb_info(napi_env env, napi_callback_info cbinfo, size_t* argc, napi_value* argv, 51 napi_value* this_arg, void** data); 52 napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope); 53 54 using napi_threadsafe_function = void *; 55 #endif // NAPI_NATIVE_API_H