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_point.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 NAccessibilityGesturePoint::JSConstructor(napi_env env, napi_callback_info info)
24 {
25 HILOG_DEBUG();
26 size_t argc = ARGS_SIZE_TWO;
27 napi_value argv[ARGS_SIZE_TWO] = {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_TWO) {
32 HILOG_ERROR("argc %{public}zu is not 2", argc);
33 return nullptr;
34 }
35 NAPI_CALL(env, napi_typeof(env, argv[PARAM0], &valueType));
36 if (valueType != napi_number) {
37 HILOG_ERROR("PARAM0's valueType %{public}d is not napi_number", valueType);
38 return nullptr;
39 }
40 NAPI_CALL(env, napi_typeof(env, argv[PARAM1], &valueType));
41 if (valueType != napi_number) {
42 HILOG_ERROR("PARAM1's valueType %{public}d is not napi_number", valueType);
43 return nullptr;
44 }
45 NAPI_CALL(env, napi_set_named_property(env, jsthis, "positionX", argv[PARAM0]));
46 NAPI_CALL(env, napi_set_named_property(env, jsthis, "positionY", argv[PARAM1]));
47 return jsthis;
48 }
49