Scope.h revision d537ab02e1707597d70665fd8c75ca1ec9f57326
11aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber/* 21aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Copyright (C) 2016 The Android Open Source Project 31aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 41aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 51aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * you may not use this file except in compliance with the License. 61aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * You may obtain a copy of the License at 71aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 81aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 91aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 101aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Unless required by applicable law or agreed to in writing, software 111aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 121aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * See the License for the specific language governing permissions and 141aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * limitations under the License. 151aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber */ 161aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber 17c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#ifndef SCOPE_H_ 18c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 19c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#define SCOPE_H_ 20c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 21c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#include "NamedType.h" 22c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 23d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland#include <map> 2470a59e1dc3dcf32f791d2dd7966111d4adf32ecaAndreas Huber#include <vector> 25c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 26c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Hubernamespace android { 27c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 28881227d860c59471eee31d39946e96ce2daa35d6Andreas Huberstruct Formatter; 29881227d860c59471eee31d39946e96ce2daa35d6Andreas Huberstruct Interface; 30c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 31c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberstruct Scope : public NamedType { 329ed827c8cd6e8eddb1ad9987ab9413c1de8a27dfAndreas Huber Scope(const char *localName); 33c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 34d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland bool addType(NamedType *type, std::string *errorMsg); 355a545440766886a1bbd09ed7221bb337705e5d14Andreas Huber 36d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland NamedType *lookupType(const char *name) const; 37c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 385345ec2b1b7e4126b77aa2131b231a9eb5ee811dAndreas Huber bool isScope() const override; 39881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 40881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber // Returns the single interface or NULL. 41881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber Interface *getInterface() const; 42881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 43a2723d26427f7db19777dfed330047253e7a4e1bAndreas Huber bool containsSingleInterface(std::string *ifaceName) const; 44c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 45c7dfef3fda2061dcaeeb144c10eef3cf7360b03cAndreas Huber std::string pickUniqueAnonymousName() const; 46c7dfef3fda2061dcaeeb144c10eef3cf7360b03cAndreas Huber 472831d5145675ead9f2fb767bf5fe4ae56b88349fAndreas Huber std::string getJavaType() const override; 482831d5145675ead9f2fb767bf5fe4ae56b88349fAndreas Huber 49881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber status_t emitTypeDeclarations(Formatter &out) const override; 5085eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber 5185eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber status_t emitJavaTypeDeclarations( 5285eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber Formatter &out, bool atTopLevel) const override; 53881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 54881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber status_t emitTypeDefinitions( 55881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber Formatter &out, const std::string prefix) const override; 56881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 57d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland const std::vector<NamedType *> &getSubTypes() const; 585158db484e5ab302368f191d75d5b1334c270e52Zhuoyao Zhang 595158db484e5ab302368f191d75d5b1334c270e52Zhuoyao Zhang status_t emitVtsTypeDeclarations(Formatter &out) const override; 605158db484e5ab302368f191d75d5b1334c270e52Zhuoyao Zhang 6170a59e1dc3dcf32f791d2dd7966111d4adf32ecaAndreas Huber bool isJavaCompatible() const override; 6270a59e1dc3dcf32f791d2dd7966111d4adf32ecaAndreas Huber 63c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberprivate: 64d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland std::vector<NamedType *> mTypes; 65d537ab02e1707597d70665fd8c75ca1ec9f57326Steven Moreland std::map<std::string, size_t> mTypeIndexByName; 66c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 67c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber DISALLOW_COPY_AND_ASSIGN(Scope); 68c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber}; 69c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 70c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber} // namespace android 71c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 72c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#endif // SCOPE_H_ 73c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 74