• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "napi_native_object.h"
17 
18 namespace OHOS {
19 namespace Bluetooth {
ToNapiValue(napi_env env) const20 napi_value NapiNativeInt::ToNapiValue(napi_env env) const
21 {
22     napi_value value = nullptr;
23     napi_status status = napi_create_int32(env, value_, &value);
24     if (status != napi_ok) {
25         HILOGE("napi_create_int32 failed");
26     }
27     return value;
28 }
29 
ToNapiValue(napi_env env) const30 napi_value NapiNativeString::ToNapiValue(napi_env env) const
31 {
32     napi_value value = nullptr;
33     napi_status status = napi_create_string_utf8(env, value_.c_str(), NAPI_AUTO_LENGTH, &value);
34     if (status != napi_ok) {
35         HILOGE("napi_create_string_utf8 failed");
36     }
37     return value;
38 }
ToNapiValue(napi_env env) const39 napi_value NapiNativeUuidsArray::ToNapiValue(napi_env env) const
40 {
41     napi_value array;
42     napi_create_array(env, &array);
43     ConvertUuidsVectorToJS(env, array, uuids_);
44     return array;
45 }
46 }  // namespace Bluetooth
47 }  // namespace OHOS