1/* 2 * Copyright (c) 2021-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_api.h> 17 18#include "contacts_api.h" 19 20extern const char _binary_contact_js_start[]; 21extern const char _binary_contact_js_end[]; 22extern const char _binary_contact_abc_start[]; 23extern const char _binary_contact_abc_end[]; 24 25namespace OHOS { 26namespace ContactsApi { 27static napi_value ModuleInit(napi_env env, napi_value exports) 28{ 29 OHOS::ContactsApi::Init(env, exports); 30 return exports; 31} 32 33extern "C" __attribute__((constructor)) void RegisterModule(void) 34{ 35 napi_module module = { 36 .nm_version = 1, // NAPI v1 37 .nm_flags = 0, // normal 38 .nm_filename = nullptr, 39 .nm_register_func = ModuleInit, 40 .nm_modname = "contact", 41 .nm_priv = nullptr, 42 .reserved = {} 43 }; 44 napi_module_register(&module); 45} 46 47extern "C" __attribute__((visibility("default"))) void NAPI_contact_GetJSCode(const char** buf, 48 int* bufLen) 49{ 50 if (buf != nullptr) { 51 *buf = _binary_contact_js_start; 52 } 53 54 if (bufLen != nullptr) { 55 *bufLen = _binary_contact_js_end - _binary_contact_js_start; 56 } 57} 58 59extern "C" __attribute__((visibility("default"))) void NAPI_contact_GetABCCode(const char** buf, 60 int* bufLen) 61{ 62 if (buf != nullptr) { 63 *buf = _binary_contact_abc_start; 64 } 65 66 if (bufLen != nullptr) { 67 *bufLen = _binary_contact_abc_end - _binary_contact_abc_start; 68 } 69} 70} // namespace ContactsApi 71} // namespace OHOS