1 /* 2 * Copyright (c) 2021 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 "ohos/aafwk/content/pac_map.h" 28 #include "ohos/aafwk/content/want.h" 29 30 namespace OHOS::Ace::Napi { 31 struct ACECallbackInfo { 32 napi_env env = nullptr; 33 napi_ref callback = nullptr; 34 }; 35 36 enum class TACENativeValueType { 37 NVT_NONE = 0, 38 NVT_UNDEFINED, 39 NVT_INT32, 40 NVT_BOOL, 41 NVT_STRING, 42 NVT_DOUBLE, 43 }; 44 45 struct ACEThreadReturnData { 46 TACENativeValueType data_type = TACENativeValueType::NVT_NONE; 47 int32_t int32_value = 0; 48 bool bool_value = false; 49 std::string str_value = {}; 50 double double_value = 0.0; 51 AppExecFwk::PacMap paramList = {}; 52 }; 53 54 struct AceFromJSParam { 55 AAFwk::Want want = {}; 56 AppExecFwk::PacMap paramList = {}; 57 }; 58 59 struct ACEAsyncJSCallbackInfo { 60 ACECallbackInfo cbInfo = {}; 61 Ability* ability = nullptr; 62 napi_async_work asyncWork = nullptr; 63 napi_deferred deferred = nullptr; 64 ACEThreadReturnData native_data = {}; 65 AceFromJSParam jsParamList = {}; 66 napi_value result = nullptr; 67 int error_code = 0; 68 AAFwk::Want wantStage = {}; 69 }; 70 71 struct ACEAsyncParamEx { 72 std::string resource = {}; 73 size_t argc = 0; 74 napi_async_execute_callback execute = nullptr; 75 napi_async_complete_callback complete = nullptr; 76 }; 77 78 struct ACEComplexArrayData { 79 std::vector<int> intList = {}; 80 std::vector<long> longList = {}; 81 std::vector<bool> boolList = {}; 82 std::vector<double> doubleList = {}; 83 std::vector<std::string> stringList = {}; 84 }; 85 } // namespace OHOS::Ace::Napi 86 #endif // OHOS_NAPI_ACE_PLUGIN_DATA_H 87