blob: 330e0c3aa10a4d9404b59ae97d023dc12732e493 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -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
Andreas Huberc9410c72016-07-28 12:18:40 -070017#ifndef TYPE_DEF_H_
18
19#define TYPE_DEF_H_
20
Steven Morelandd537ab02016-09-12 10:32:01 -070021#include "NamedType.h"
Andreas Huberc9410c72016-07-28 12:18:40 -070022
Neel Mehta69920a62019-07-22 16:22:13 -070023#include <string>
24
Andreas Huberc9410c72016-07-28 12:18:40 -070025namespace android {
26
Steven Morelandd537ab02016-09-12 10:32:01 -070027struct TypeDef : public NamedType {
Neel Mehta69920a62019-07-22 16:22:13 -070028 TypeDef(const std::string& localName, const FQName& fullName, const Location& location,
29 Scope* parent, const Reference<Type>& type);
Andreas Huberc9410c72016-07-28 12:18:40 -070030
Andreas Huber737080b2016-08-02 15:38:04 -070031 const ScalarType *resolveToScalarType() const override;
32
Steven Moreland0ecc7b82017-07-19 12:59:23 -070033 std::string typeName() const override;
34
Timur Iskhakov24e605b2017-08-30 14:02:55 -070035 Type* referencedType();
36 const Type* referencedType() const;
Andreas Huberc9410c72016-07-28 12:18:40 -070037
Andreas Huber5a545442016-08-03 10:44:56 -070038 bool isInterface() const override;
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070039 bool isEnum() const override;
40 bool isTypeDef() const override;
Andreas Huberbb797e42016-08-03 12:53:02 -070041 bool needsEmbeddedReadWrite() const override;
42 bool resultNeedsDeref() const override;
43
Timur Iskhakovdbaed332017-08-31 16:33:41 -070044 const Type* resolve() const override;
45
Timur Iskhakov542920e2017-08-30 21:31:18 -070046 std::vector<const Reference<Type>*> getReferences() const override;
Timur Iskhakov542920e2017-08-30 21:31:18 -070047
Steven Moreland6ec9eb92018-02-16 14:21:49 -080048 void emitTypeDeclarations(Formatter& out) const override;
Neel Mehta3b414a82019-07-02 15:47:48 -070049 void emitHidlDefinition(Formatter& out) const override;
Steven Moreland2a55e052016-09-27 10:14:24 -070050
Neel Mehta3b414a82019-07-02 15:47:48 -070051 private:
Timur Iskhakov505316c2017-08-05 03:38:59 +000052 Reference<Type> mReferencedType;
Andreas Huberc9410c72016-07-28 12:18:40 -070053
54 DISALLOW_COPY_AND_ASSIGN(TypeDef);
55};
56
57} // namespace android
58
59#endif // TYPE_DEF_H_
60