1 /*
2  * Copyright (c) 2024 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 #include "napi_mock.h"
17 #include "uv.h"
18 
uv_queue_work(uv_loop_t * loop,uv_work_t * req,uv_work_cb work_cb,uv_after_work_cb after_work_cb)19 int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb, uv_after_work_cb after_work_cb)
20 {
21     return OHOS::FileManagement::Backup::Napi::napi->uv_queue_work(loop, req, work_cb, after_work_cb);
22 }
23 
napi_get_uv_event_loop(napi_env env,struct uv_loop_s ** loop)24 napi_status napi_get_uv_event_loop(napi_env env, struct uv_loop_s** loop)
25 {
26     return OHOS::FileManagement::Backup::Napi::napi->napi_get_uv_event_loop(env, loop);
27 }
28 
napi_call_function(napi_env env,napi_value recv,napi_value func,size_t argc,const napi_value * argv,napi_value * result)29 napi_status napi_call_function(napi_env env, napi_value recv, napi_value func, size_t argc, const napi_value* argv,
30     napi_value* result)
31 {
32     return OHOS::FileManagement::Backup::Napi::napi->napi_call_function(env, recv, func, argc, argv, result);
33 }
34 
napi_get_reference_value(napi_env env,napi_ref ref,napi_value * result)35 napi_status napi_get_reference_value(napi_env env, napi_ref ref, napi_value* result)
36 {
37     return OHOS::FileManagement::Backup::Napi::napi->napi_get_reference_value(env, ref, result);
38 }
39 
napi_get_named_property(napi_env env,napi_value object,const char * utf8name,napi_value * result)40 napi_status napi_get_named_property(napi_env env, napi_value object, const char* utf8name, napi_value* result)
41 {
42     return OHOS::FileManagement::Backup::Napi::napi->napi_get_named_property(env, object, utf8name, result);
43 }
44 
napi_get_value_int32(napi_env env,napi_value value,int32_t * result)45 napi_status napi_get_value_int32(napi_env env, napi_value value, int32_t* result)
46 {
47     return OHOS::FileManagement::Backup::Napi::napi->napi_get_value_int32(env, value, result);
48 }
49 
napi_get_value_int64(napi_env env,napi_value value,int64_t * result)50 napi_status napi_get_value_int64(napi_env env, napi_value value, int64_t* result)
51 {
52     return OHOS::FileManagement::Backup::Napi::napi->napi_get_value_int64(env, value, result);
53 }
54 
napi_create_string_utf8(napi_env env,const char * str,size_t length,napi_value * result)55 napi_status napi_create_string_utf8(napi_env env, const char* str, size_t length, napi_value* result)
56 {
57     return OHOS::FileManagement::Backup::Napi::napi->napi_create_string_utf8(env, str, length, result);
58 }
59 
napi_create_int32(napi_env env,int32_t value,napi_value * result)60 napi_status napi_create_int32(napi_env env, int32_t value, napi_value* result)
61 {
62     return OHOS::FileManagement::Backup::Napi::napi->napi_create_int32(env, value, result);
63 }
64 
napi_create_int64(napi_env env,int64_t value,napi_value * result)65 napi_status napi_create_int64(napi_env env, int64_t value, napi_value* result)
66 {
67     return OHOS::FileManagement::Backup::Napi::napi->napi_create_int64(env, value, result);
68 }
69 
napi_get_value_string_utf8(napi_env env,napi_value value,char * buf,size_t bufsize,size_t * result)70 napi_status napi_get_value_string_utf8(napi_env env, napi_value value, char* buf, size_t bufsize, size_t* result)
71 {
72     return OHOS::FileManagement::Backup::Napi::napi->napi_get_value_string_utf8(env, value, buf, bufsize, result);
73 }
74 
napi_get_boolean(napi_env env,bool value,napi_value * result)75 napi_status napi_get_boolean(napi_env env, bool value, napi_value* result)
76 {
77     return OHOS::FileManagement::Backup::Napi::napi->napi_get_boolean(env, value, result);
78 }
79 
napi_create_array(napi_env env,napi_value * result)80 napi_status napi_create_array(napi_env env, napi_value* result)
81 {
82     return OHOS::FileManagement::Backup::Napi::napi->napi_create_array(env, result);
83 }
84 
napi_get_array_length(napi_env env,napi_value value,uint32_t * result)85 napi_status napi_get_array_length(napi_env env, napi_value value, uint32_t* result)
86 {
87     return OHOS::FileManagement::Backup::Napi::napi->napi_get_array_length(env, value, result);
88 }
89 
napi_get_element(napi_env env,napi_value object,uint32_t index,napi_value * result)90 napi_status napi_get_element(napi_env env, napi_value object, uint32_t index, napi_value* result)
91 {
92     return OHOS::FileManagement::Backup::Napi::napi->napi_get_element(env, object, index, result);
93 }
94 
napi_escape_handle(napi_env env,napi_escapable_handle_scope scope,napi_value escapee,napi_value * result)95 napi_status napi_escape_handle(napi_env env, napi_escapable_handle_scope scope, napi_value escapee, napi_value* result)
96 {
97     return OHOS::FileManagement::Backup::Napi::napi->napi_escape_handle(env, scope, escapee, result);
98 }
99 
napi_get_null(napi_env env,napi_value * result)100 napi_status napi_get_null(napi_env env, napi_value* result)
101 {
102     return OHOS::FileManagement::Backup::Napi::napi->napi_get_null(env, result);
103 }
104 
napi_create_object(napi_env env,napi_value * result)105 napi_status napi_create_object(napi_env env, napi_value* result)
106 {
107     return OHOS::FileManagement::Backup::Napi::napi->napi_create_object(env, result);
108 }
109 
napi_create_array_with_length(napi_env env,size_t length,napi_value * result)110 napi_status napi_create_array_with_length(napi_env env, size_t length, napi_value* result)
111 {
112     return OHOS::FileManagement::Backup::Napi::napi->napi_create_array_with_length(env, length, result);
113 }
114 
napi_create_double(napi_env env,double value,napi_value * result)115 napi_status napi_create_double(napi_env env, double value, napi_value* result)
116 {
117     return OHOS::FileManagement::Backup::Napi::napi->napi_create_double(env, value, result);
118 }
119 
napi_set_named_property(napi_env env,napi_value object,const char * utf8Name,napi_value value)120 napi_status napi_set_named_property(napi_env env, napi_value object, const char* utf8Name, napi_value value)
121 {
122     return OHOS::FileManagement::Backup::Napi::napi->napi_set_named_property(env, object, utf8Name, value);
123 }
124 
napi_get_and_clear_last_exception(napi_env env,napi_value * result)125 napi_status napi_get_and_clear_last_exception(napi_env env, napi_value* result)
126 {
127     return OHOS::FileManagement::Backup::Napi::napi->napi_get_and_clear_last_exception(env, result);
128 }
129 
napi_get_cb_info(napi_env env,napi_callback_info cbinfo,size_t * argc,napi_value * argv,napi_value * thisArg,void ** data)130 napi_status napi_get_cb_info(napi_env env, napi_callback_info cbinfo, size_t* argc, napi_value* argv,
131     napi_value* thisArg, void** data)
132 {
133     return OHOS::FileManagement::Backup::Napi::napi->napi_get_cb_info(env, cbinfo, argc, argv, thisArg, data);
134 }
135 
napi_is_promise(napi_env env,napi_value value,bool * is_promise)136 napi_status napi_is_promise(napi_env env, napi_value value, bool* is_promise)
137 {
138     return OHOS::FileManagement::Backup::Napi::napi->napi_is_promise(env, value, is_promise);
139 }
140 
napi_is_callable(napi_env env,napi_value method,bool * isCallable)141 napi_status napi_is_callable(napi_env env, napi_value method, bool* isCallable)
142 {
143     return OHOS::FileManagement::Backup::Napi::napi->napi_is_callable(env, method, isCallable);
144 }
145 
napi_create_function(napi_env env,const char * utf8name,size_t length,napi_callback cb,void * data,napi_value * result)146 napi_status napi_create_function(napi_env env, const char* utf8name, size_t length, napi_callback cb, void* data,
147     napi_value* result)
148 {
149     return OHOS::FileManagement::Backup::Napi::napi->napi_create_function(env, utf8name, length, cb, data, result);
150 }
151 
napi_open_handle_scope(napi_env env,napi_handle_scope * result)152 NAPI_EXTERN napi_status napi_open_handle_scope(napi_env env, napi_handle_scope* result)
153 {
154     return OHOS::FileManagement::Backup::Napi::napi->napi_open_handle_scope(env, result);
155 }
156 
napi_close_handle_scope(napi_env env,napi_handle_scope scope)157 NAPI_EXTERN napi_status napi_close_handle_scope(napi_env env, napi_handle_scope scope)
158 {
159     return OHOS::FileManagement::Backup::Napi::napi->napi_close_handle_scope(env, scope);
160 }
161 
napi_is_exception_pending(napi_env env,bool * result)162 napi_status napi_is_exception_pending(napi_env env, bool* result)
163 {
164     return OHOS::FileManagement::Backup::Napi::napi->napi_is_exception_pending(env, result);
165 }