1/* 2 * Copyright (c) 2023 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 <pthread.h> 17#include <unistd.h> 18 19#include "module_init.h" 20#include "napi/native_api.h" 21#include "napi/native_node_api.h" 22#include "calendar_log.h" 23 24extern const char _binary_editor_js_start[]; 25extern const char _binary_editor_js_end[]; 26extern const char _binary_editor_abc_start[]; 27extern const char _binary_editor_abc_end[]; 28 29namespace OHOS::CalendarApi { 30EXTERN_C_START 31/* 32 * function for module exports 33 */ 34static napi_value Init(napi_env env, napi_value exports) 35{ 36 LOG_INFO("napi_module Init start..."); 37 exports = ModuleInit(env, exports); 38 return exports; 39} 40EXTERN_C_END 41 42/* 43 * Module define 44 */ 45static napi_module _module = { 46 .nm_version = 1, 47 .nm_flags = 0, 48 .nm_filename = nullptr, 49 .nm_register_func = Init, 50 .nm_modname = "calendarManager", 51 .nm_priv = ((void *)0), 52 .reserved = {0}, 53}; 54 55/* 56 * Module register function 57 */ 58extern "C" __attribute__((constructor)) void RegisterModule(void) 59{ 60 napi_module_register(&_module); 61} 62} // namespace OHOS::CalendarApi 63 64extern "C" __attribute__((visibility("default"))) void NAPI_calendarManager_GetJSCode(const char** buf, 65 int* bufLen) 66{ 67 if (buf != nullptr) { 68 *buf = _binary_editor_js_start; 69 } 70 71 if (bufLen != nullptr) { 72 *bufLen = _binary_editor_js_end - _binary_editor_js_start; 73 } 74} 75 76extern "C" __attribute__((visibility("default"))) void NAPI_calendarManager_GetABCCode(const char** buf, 77 int* bufLen) 78{ 79 if (buf != nullptr) { 80 *buf = _binary_editor_abc_start; 81 } 82 83 if (bufLen != nullptr) { 84 *bufLen = _binary_editor_abc_end - _binary_editor_abc_start; 85 } 86}