• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include "TypeDef.h"
18 
19 #include <hidl-util/Formatter.h>
20 #include <android-base/logging.h>
21 
22 namespace android {
23 
TypeDef(const char * localName,const Location & location,Scope * parent,Type * type)24 TypeDef::TypeDef(const char* localName, const Location& location, Scope* parent, Type* type)
25     : NamedType(localName, location, parent), mReferencedType(type) {}
26 
resolveToScalarType() const27 const ScalarType *TypeDef::resolveToScalarType() const {
28     CHECK(!"Should not be here");
29     return NULL;
30 }
31 
referencedType() const32 Type *TypeDef::referencedType() const {
33     return mReferencedType;
34 }
35 
isInterface() const36 bool TypeDef::isInterface() const {
37     return false;
38 }
39 
isEnum() const40 bool TypeDef::isEnum() const {
41     CHECK(!"Should not be here");
42     return false;
43 }
44 
typeName() const45 std::string TypeDef::typeName() const {
46     return "typedef " + localName();
47 }
48 
isTypeDef() const49 bool TypeDef::isTypeDef() const {
50     return true;
51 }
52 
needsEmbeddedReadWrite() const53 bool TypeDef::needsEmbeddedReadWrite() const {
54     CHECK(!"Should not be here");
55     return false;
56 }
57 
resultNeedsDeref() const58 bool TypeDef::resultNeedsDeref() const {
59     CHECK(!"Should not be here");
60     return false;
61 }
62 
emitTypeDeclarations(Formatter & out) const63 status_t TypeDef::emitTypeDeclarations(Formatter &out) const {
64     out << "typedef "
65         << mReferencedType->getCppStackType()
66         << " "
67         << localName()
68         << ";\n\n";
69 
70     return OK;
71 }
72 
73 }  // namespace android
74 
75