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