1 /*
2 * Copyright (C) 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_accessibility_gesture_path.h"
17 #include "napi_accessibility_def.h"
18 #include "hilog_wrapper.h"
19
20 using namespace OHOS;
21
JSConstructor(napi_env env,napi_callback_info info)22 napi_value NAccessibilityGesturePath::JSConstructor(napi_env env, napi_callback_info info)
23 {
24 HILOG_DEBUG();
25 size_t argc = ARGS_SIZE_ONE;
26 napi_value argv[ARGS_SIZE_ONE] = {nullptr};
27 napi_valuetype valueType;
28 napi_value jsthis = nullptr;
29 NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &jsthis, nullptr));
30 if (argc != ARGS_SIZE_ONE) {
31 HILOG_ERROR("argc %{public}zu is not 1", argc);
32 return nullptr;
33 }
34 NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valueType));
35 if (valueType != napi_number) {
36 HILOG_ERROR("valueType %{public}d is not napi_number", valueType);
37 return nullptr;
38 }
39 napi_value points;
40 NAPI_CALL(env, napi_create_array(env, &points));
41 NAPI_CALL(env, napi_set_named_property(env, jsthis, "points", points));
42 NAPI_CALL(env, napi_set_named_property(env, jsthis, "durationTime", argv[PARAM0]));
43 return jsthis;
44 }
45