• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef OHOS_NAPI_ACE_PLUGIN_DATA_H
17 #define OHOS_NAPI_ACE_PLUGIN_DATA_H
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 #include "ability.h"
24 #include "napi/native_api.h"
25 #include "napi/native_common.h"
26 #include "napi/native_node_api.h"
27 #include "pac_map.h"
28 #include "want.h"
29 
30 namespace OHOS::Ace::Napi {
31 struct ACECallbackInfo {
32     napi_env env = nullptr;
33     napi_ref callback = nullptr;
34     int32_t containerId = -1;
35 };
36 
37 enum class TACENativeValueType {
38     NVT_NONE = 0,
39     NVT_UNDEFINED,
40     NVT_INT32,
41     NVT_BOOL,
42     NVT_STRING,
43     NVT_DOUBLE,
44 };
45 
46 struct ACEThreadReturnData {
47     TACENativeValueType data_type = TACENativeValueType::NVT_NONE;
48     int32_t int32_value = 0;
49     bool bool_value = false;
50     std::string str_value = {};
51     double double_value = 0.0;
52     AppExecFwk::PacMap paramList = {};
53 };
54 
55 struct AceFromJSParam {
56     AAFwk::Want want = {};
57     AppExecFwk::PacMap paramList = {};
58 };
59 
60 struct ACERequestCallbackData {
61     std::string sourceName;
62     std::string abilityName;
63     std::string data;
64     std::string extraData;
65     std::string name;
66 };
67 
68 struct ACEAsyncJSCallbackInfo {
69     ACECallbackInfo cbInfo = {};
70     Ability* ability = nullptr;
71     napi_async_work asyncWork = nullptr;
72     napi_deferred deferred = nullptr;
73     ACEThreadReturnData native_data = {};
74     AceFromJSParam jsParamList = {};
75     napi_value result = nullptr;
76     int error_code = 0;
77     AAFwk::Want wantStage = {};
78     napi_value onRequestData = nullptr;
79     bool onRequestCallbackOK = false;
80     ACERequestCallbackData requestCallbackData;
81 };
82 
83 struct ACEComplexArrayData {
84     std::vector<int> intList = {};
85     std::vector<int64_t> longList = {};
86     std::vector<bool> boolList = {};
87     std::vector<double> doubleList = {};
88     std::vector<std::string> stringList = {};
89 };
90 }  // namespace OHOS::Ace::Napi
91 #endif  // OHOS_NAPI_ACE_PLUGIN_DATA_H
92