blob: d7b428c379610558e0a85dad9d43150628a5e00b [file] [log] [blame]
Yifan Hongbf459bc2016-08-23 16:50:37 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef REF_TYPE_H_
18
19#define REF_TYPE_H_
20
Timur Iskhakov40731af2017-08-24 14:18:35 -070021#include <vector>
22
23#include "Reference.h"
Yifan Hongbf459bc2016-08-23 16:50:37 -070024#include "Type.h"
25
26namespace android {
27
28struct RefType : public TemplatedType {
Timur Iskhakov63f39902017-08-29 15:47:29 -070029 RefType(Scope* parent);
Yifan Hongbf459bc2016-08-23 16:50:37 -070030
Timur Iskhakov3f1d26e2017-08-30 15:35:53 -070031 std::string templatedTypeName() const override;
Timur Iskhakov24e605b2017-08-30 14:02:55 -070032
33 bool isCompatibleElementType(const Type* elementType) const override;
Steven Moreland30bb6a82016-11-30 09:18:34 -080034
Timur Iskhakovb58f4182017-08-29 15:19:24 -070035 std::vector<const Reference<Type>*> getStrongReferences() const override;
Timur Iskhakov40731af2017-08-24 14:18:35 -070036
Yifan Hong3b320f82016-11-01 15:15:54 -070037 std::string getCppType(StorageMode mode,
Yifan Hongbf459bc2016-08-23 16:50:37 -070038 bool specifyNamespaces) const override;
39
Zhuoyao Zhange9667842017-01-19 12:35:32 -080040 std::string getVtsType() const override;
41 std::string getVtsValueName() const override;
42
Yifan Hongbf459bc2016-08-23 16:50:37 -070043 void emitReaderWriter(
44 Formatter &out,
45 const std::string &name,
46 const std::string &parcelObj,
47 bool parcelObjIsPointer,
48 bool isReader,
49 ErrorMode mode) const override;
50
51 void emitResolveReferences(
52 Formatter &out,
53 const std::string &name,
54 bool nameIsPointer,
55 const std::string &parcelObj,
56 bool parcelObjIsPointer,
57 bool isReader,
58 ErrorMode mode) const override;
59
60 void emitResolveReferencesEmbedded(
61 Formatter &out,
62 size_t depth,
63 const std::string &name,
64 const std::string &sanitizedName,
65 bool nameIsPointer,
66 const std::string &parcelObj,
67 bool parcelObjIsPointer,
68 bool isReader,
69 ErrorMode mode,
70 const std::string &parentName,
71 const std::string &offsetText) const override;
72
73 bool needsEmbeddedReadWrite() const override;
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -070074 bool deepNeedsResolveReferences(std::unordered_set<const Type*>* visited) const override;
Yifan Hongbf459bc2016-08-23 16:50:37 -070075 bool resultNeedsDeref() const override;
76
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -070077 bool deepIsJavaCompatible(std::unordered_set<const Type*>* visited) const override;
78 bool deepContainsPointer(std::unordered_set<const Type*>* visited) const override;
Yifan Hongbf459bc2016-08-23 16:50:37 -070079
Timur Iskhakov5dc72fe2017-09-07 23:13:44 -070080 private:
Yifan Hongbf459bc2016-08-23 16:50:37 -070081 DISALLOW_COPY_AND_ASSIGN(RefType);
82};
83
84} // namespace android
85
86#endif // REF_TYPE_H_
87