• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_treeset_js_start[];
19 extern const char _binary_js_treeset_js_end[];
20 extern const char _binary_treeset_abc_start[];
21 extern const char _binary_treeset_abc_end[];
22 
23 namespace OHOS::Util {
TreeSetInit(napi_env env,napi_value exports)24 static napi_value TreeSetInit(napi_env env, napi_value exports)
25 {
26     return exports;
27 }
28 
29 extern "C"
NAPI_util_TreeSet_GetJSCode(const char ** buf,int * bufLen)30 __attribute__((visibility("default"))) void NAPI_util_TreeSet_GetJSCode(const char **buf, int *bufLen)
31 {
32     if (buf != nullptr) {
33         *buf = _binary_js_treeset_js_start;
34     }
35 
36     if (bufLen != nullptr) {
37         *bufLen = _binary_js_treeset_js_end - _binary_js_treeset_js_start;
38     }
39 }
40 
41 extern "C"
NAPI_util_TreeSet_GetABCCode(const char ** buf,int * buflen)42 __attribute__((visibility("default"))) void NAPI_util_TreeSet_GetABCCode(const char** buf, int* buflen)
43 {
44     if (buf != nullptr) {
45         *buf = _binary_treeset_abc_start;
46     }
47     if (buflen != nullptr) {
48         *buflen = _binary_treeset_abc_end - _binary_treeset_abc_start;
49     }
50 }
51 
52 static napi_module_with_js treeSetModule = {
53     .nm_version = 1,
54     .nm_flags = 0,
55     .nm_filename = nullptr,
56     .nm_register_func = TreeSetInit,
57     .nm_modname = "util.TreeSet",
58     .nm_priv = ((void*)0),
59     .nm_get_abc_code = NAPI_util_TreeSet_GetABCCode,
60     .nm_get_js_code = NAPI_util_TreeSet_GetJSCode,
61 };
62 
TreeSetRegisterModule()63 extern "C" __attribute__ ((constructor)) void TreeSetRegisterModule()
64 {
65     napi_module_with_js_register(&treeSetModule);
66 }
67 } // namespace  OHOS::Util
68