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 "VarDeclaration.h" 18 19 namespace android { 20 VarDeclaration(Type * type,const std::string & name)21VarDeclaration::VarDeclaration(Type *type, const std::string &name) 22 : Declaration(""), 23 mType(type) 24 { 25 setName(name); 26 } 27 ~VarDeclaration()28VarDeclaration::~VarDeclaration() { 29 delete mType; 30 } 31 setName(const std::string & name)32void VarDeclaration::setName(const std::string &name) { 33 Declaration::setName(name); 34 // special case for varargs 35 if(getName() == "...") 36 return; 37 forceCamelCase(); 38 } 39 getType() const40Type* VarDeclaration::getType() const { 41 return mType; 42 } 43 generateSource(Formatter & out) const44void VarDeclaration::generateSource(Formatter &out) const { 45 out << getType()->decorateName(getName()) 46 << ";\n"; 47 } 48 generateParameterSource(Formatter & out) const49void VarDeclaration::generateParameterSource(Formatter &out) const { 50 out << getType()->decorateName(getName()); 51 } 52 processContents(AST &)53void VarDeclaration::processContents(AST &) { 54 // nothing to do 55 } 56 57 } // namespace android