• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 DEVELOPTOOLS_PROFILER_HIDEBUG_ANI_UTIL_H
17 #define DEVELOPTOOLS_PROFILER_HIDEBUG_ANI_UTIL_H
18 
19 #include <string>
20 
21 #include "ani.h"
22 
23 namespace OHOS {
24 namespace HiviewDFX {
25 constexpr int32_t HIDEBUG_DEFAULT_ERROR_CODE = 11400104;  //SYSTEM_STATUS_ABNORMAL
26 class AniUtil {
27 public:
28     static void ThrowErrorMessage(ani_env *env, const std::string &msg, int32_t errCode = HIDEBUG_DEFAULT_ERROR_CODE);
29     static ani_object CreateUndefined(ani_env *env);
30     static ani_status ToAniBigInt(ani_env *env, uint64_t uint64Val, ani_object &aniBigInt);
31     static ani_status ParseAniString(ani_env *env, ani_string aniStr, std::string &str);
32     static ani_status ParseAniEnum(ani_env *env, ani_enum_item enumItem, uint32_t &value);
33     static ani_status SetNamedPropertyNumber(ani_env *env, ani_object object, const std::string& name, double value);
34     static ani_status SetNamedPropertyBigInt(ani_env *env, ani_object object, const std::string& name, uint64_t value);
35 };
36 } // namespace HiviewDFX
37 } // namespace OHOS
38 #endif //DEVELOPTOOLS_PROFILER_HIDEBUG_ANI_UTIL_H
39