Scope.h revision 7c5ddfb41a806a7bf71581952d06b637a7670cf7
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#ifndef SCOPE_H_ 18 19#define SCOPE_H_ 20 21#include "NamedType.h" 22 23#include <map> 24#include <vector> 25 26namespace android { 27 28struct Formatter; 29struct Interface; 30struct LocalIdentifier; 31 32struct Scope : public NamedType { 33 Scope(const char *localName); 34 virtual ~Scope(); 35 36 bool addType(NamedType *type, std::string *errorMsg); 37 38 NamedType *lookupType(const FQName &fqName) const; 39 40 virtual LocalIdentifier *lookupIdentifier(const std::string &name) const; 41 42 bool isScope() const override; 43 44 // Returns the single interface or NULL. 45 Interface *getInterface() const; 46 47 bool containsSingleInterface(std::string *ifaceName) const; 48 bool containsInterfaces() const; 49 50 std::string pickUniqueAnonymousName() const; 51 52 status_t emitTypeDeclarations(Formatter &out) const override; 53 54 status_t emitJavaTypeDeclarations( 55 Formatter &out, bool atTopLevel) const override; 56 57 status_t emitTypeDefinitions( 58 Formatter &out, const std::string prefix) const override; 59 60 const std::vector<NamedType *> &getSubTypes() const; 61 62 status_t emitVtsTypeDeclarations(Formatter &out) const override; 63 64 bool isJavaCompatible() const override; 65 66private: 67 std::vector<NamedType *> mTypes; 68 std::map<std::string, size_t> mTypeIndexByName; 69 70 DISALLOW_COPY_AND_ASSIGN(Scope); 71}; 72 73struct LocalIdentifier { 74 LocalIdentifier(); 75 virtual ~LocalIdentifier(); 76 virtual bool isEnumValue() const; 77}; 78 79} // namespace android 80 81#endif // SCOPE_H_ 82 83