1 /*
2 * Copyright (c) 2022 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/native_node_api.h"
17
18 extern const char _binary_js_deque_js_start[];
19 extern const char _binary_js_deque_js_end[];
20 extern const char _binary_deque_abc_start[];
21 extern const char _binary_deque_abc_end[];
22 namespace OHOS::Util {
DequeInit(napi_env env,napi_value exports)23 static napi_value DequeInit(napi_env env, napi_value exports)
24 {
25 return exports;
26 }
27 extern "C"
NAPI_util_Deque_GetJSCode(const char ** buf,int * bufLen)28 __attribute__((visibility("default"))) void NAPI_util_Deque_GetJSCode(const char **buf, int *bufLen)
29 {
30 if (buf != nullptr) {
31 *buf = _binary_js_deque_js_start;
32 }
33
34 if (bufLen != nullptr) {
35 *bufLen = _binary_js_deque_js_end - _binary_js_deque_js_start;
36 }
37 }
38 extern "C"
NAPI_util_Deque_GetABCCode(const char ** buf,int * buflen)39 __attribute__((visibility("default"))) void NAPI_util_Deque_GetABCCode(const char **buf, int *buflen)
40 {
41 if (buf != nullptr) {
42 *buf = _binary_deque_abc_start;
43 }
44 if (buflen != nullptr) {
45 *buflen = _binary_deque_abc_end - _binary_deque_abc_start;
46 }
47 }
48
49 static napi_module_with_js dequeModule = {
50 .nm_version = 1,
51 .nm_flags = 0,
52 .nm_filename = nullptr,
53 .nm_register_func = DequeInit,
54 .nm_modname = "util.Deque",
55 .nm_priv = ((void *)0),
56 .nm_get_abc_code = NAPI_util_Deque_GetABCCode,
57 .nm_get_js_code = NAPI_util_Deque_GetJSCode,
58 };
59
DequeRegisterModule()60 extern "C" __attribute__((constructor)) void DequeRegisterModule()
61 {
62 napi_module_with_js_register(&dequeModule);
63 }
64 } // namespace OHOS::Util
65