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 24 TypeDef::TypeDef(const char* localName, const Location &location, Type *type) 25 : NamedType(localName, location), 26 mReferencedType(type) { 27 } 28 29 const ScalarType *TypeDef::resolveToScalarType() const { 30 CHECK(!"Should not be here"); 31 return NULL; 32 } 33 34 Type *TypeDef::referencedType() const { 35 return mReferencedType; 36 } 37 38 bool TypeDef::isInterface() const { 39 return false; 40 } 41 42 bool TypeDef::isEnum() const { 43 CHECK(!"Should not be here"); 44 return false; 45 } 46 47 bool TypeDef::isTypeDef() const { 48 return true; 49 } 50 51 bool TypeDef::needsEmbeddedReadWrite() const { 52 CHECK(!"Should not be here"); 53 return false; 54 } 55 56 bool TypeDef::resultNeedsDeref() const { 57 CHECK(!"Should not be here"); 58 return false; 59 } 60 61 status_t TypeDef::emitTypeDeclarations(Formatter &out) const { 62 out << "typedef " 63 << mReferencedType->getCppStackType() 64 << " " 65 << localName() 66 << ";\n\n"; 67 68 return OK; 69 } 70 71 } // namespace android 72 73