1 /*
2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 "nodeapi.h"
17
18 static const char *TAG = "[nodeapi_value]";
19
testNapiValue(napi_env env,napi_callback_info info)20 napi_value testNapiValue(napi_env env, napi_callback_info info)
21 {
22 // pages/nodeapi/datatypes/napivalue
23 size_t argc = PARAM2;
24 napi_value argv[PARAM2];
25 napi_status status;
26
27 // 返回结果
28 napi_value resultValue;
29 status = napi_create_string_utf8(env, "test_napi_value", NAPI_AUTO_LENGTH, &resultValue);
30 if (status != napi_ok) {
31 napi_throw_error(env, NULL, "Failed to create result value");
32 return NULL;
33 }
34
35 return resultValue;
36 }
37