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