1 /*
2 * Copyright (c) 2023 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 "aot/aot_args.h"
17
18 #include "parcel_macro.h"
19 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)23 bool AOTArgs::ReadFromParcel(Parcel &parcel)
24 {
25 bundleName = Str16ToStr8(parcel.ReadString16());
26 moduleName = Str16ToStr8(parcel.ReadString16());
27 compileMode = Str16ToStr8(parcel.ReadString16());
28 hapPath = Str16ToStr8(parcel.ReadString16());
29 coreLibPath = Str16ToStr8(parcel.ReadString16());
30 outputPath = Str16ToStr8(parcel.ReadString16());
31 arkProfilePath = Str16ToStr8(parcel.ReadString16());
32 offset = parcel.ReadUint32();
33 length = parcel.ReadUint32();
34 return true;
35 }
36
Marshalling(Parcel & parcel) const37 bool AOTArgs::Marshalling(Parcel &parcel) const
38 {
39 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
40 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
41 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(compileMode));
42 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(hapPath));
43 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(coreLibPath));
44 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(outputPath));
45 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(arkProfilePath));
46 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, offset);
47 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Uint32, parcel, length);
48 return true;
49 }
50
Unmarshalling(Parcel & parcel)51 AOTArgs *AOTArgs::Unmarshalling(Parcel &parcel)
52 {
53 AOTArgs *aotArgs = new (std::nothrow) AOTArgs();
54 if (aotArgs) {
55 aotArgs->ReadFromParcel(parcel);
56 }
57 return aotArgs;
58 }
59
ToString() const60 std::string AOTArgs::ToString() const
61 {
62 return "[ bundleName = " + bundleName
63 + ", moduleName = " + moduleName
64 + ", compileMode = " + compileMode
65 + ", hapPath = " + hapPath
66 + ", coreLibPath = " + coreLibPath
67 + ", outputPath = " + outputPath
68 + ", arkProfilePath = " + arkProfilePath
69 + ", offset = " + std::to_string(offset)
70 + ", length = " + std::to_string(length) + "]";
71 }
72 } // namespace AppExecFwk
73 } // namespace OHOS
74