• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "native_engine/native_engine.h"
17 
18 #define EXTERN_C_VISIBILITY_DEFAULT extern "C" __attribute__((visibility("default")))
19 #define EXTERN_C_CONSTRUCTOR extern "C" __attribute__((constructor))
20 
21 extern const char _binary_backup_extension_context_js_start[];
22 extern const char _binary_backup_extension_context_js_end[];
23 extern const char _binary_backup_extension_context_abc_start[];
24 extern const char _binary_backup_extension_context_abc_end[];
25 
26 static napi_module _module = {
27     .nm_version = 0,
28     .nm_filename = "application/libbackupextensioncontext_napi.so/backup_extension_context.js",
29     .nm_modname = "application.BackupExtensionContext",
30 };
31 
NAPI_application_BackupExtensionContext_AutoRegister()32 EXTERN_C_CONSTRUCTOR void NAPI_application_BackupExtensionContext_AutoRegister()
33 {
34     napi_module_register(&_module);
35 }
36 
NAPI_application_BackupExtensionContext_GetJSCode(const char ** buf,int * bufLen)37 EXTERN_C_VISIBILITY_DEFAULT void NAPI_application_BackupExtensionContext_GetJSCode(const char **buf, int *bufLen)
38 {
39     if (buf != nullptr) {
40         *buf = _binary_backup_extension_context_js_start;
41     }
42 
43     if (bufLen != nullptr) {
44         *bufLen = _binary_backup_extension_context_js_end - _binary_backup_extension_context_js_start;
45     }
46 }
47 
48 // extension_context JS register
NAPI_application_BackupExtensionContext_GetABCCode(const char ** buf,int * buflen)49 EXTERN_C_VISIBILITY_DEFAULT void NAPI_application_BackupExtensionContext_GetABCCode(const char **buf, int *buflen)
50 {
51     if (buf != nullptr) {
52         *buf = _binary_backup_extension_context_abc_start;
53     }
54     if (buflen != nullptr) {
55         *buflen = _binary_backup_extension_context_abc_end - _binary_backup_extension_context_abc_start;
56     }
57 }
58