Andreas Huber | 1aec397 | 2016-08-26 09:26:32 -0700 | [diff] [blame] | 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 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 17 | #ifndef SCOPE_H_ |
| 18 | |
| 19 | #define SCOPE_H_ |
| 20 | |
| 21 | #include "NamedType.h" |
| 22 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame^] | 23 | #include <map> |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 24 | #include <vector> |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 28 | struct Formatter; |
| 29 | struct Interface; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 30 | |
| 31 | struct Scope : public NamedType { |
Andreas Huber | 9ed827c | 2016-08-22 12:31:13 -0700 | [diff] [blame] | 32 | Scope(const char *localName); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 33 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame^] | 34 | bool addType(NamedType *type, std::string *errorMsg); |
Andreas Huber | 5a54544 | 2016-08-03 10:44:56 -0700 | [diff] [blame] | 35 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame^] | 36 | NamedType *lookupType(const char *name) const; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 37 | |
Andreas Huber | 5345ec2 | 2016-07-29 13:33:27 -0700 | [diff] [blame] | 38 | bool isScope() const override; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 39 | |
| 40 | // Returns the single interface or NULL. |
| 41 | Interface *getInterface() const; |
| 42 | |
Andreas Huber | a2723d2 | 2016-07-29 15:36:07 -0700 | [diff] [blame] | 43 | bool containsSingleInterface(std::string *ifaceName) const; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 44 | |
Andreas Huber | c7dfef3 | 2016-08-16 10:57:14 -0700 | [diff] [blame] | 45 | std::string pickUniqueAnonymousName() const; |
| 46 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 47 | std::string getJavaType() const override; |
| 48 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 49 | status_t emitTypeDeclarations(Formatter &out) const override; |
Andreas Huber | 85eabdb | 2016-08-25 11:24:49 -0700 | [diff] [blame] | 50 | |
| 51 | status_t emitJavaTypeDeclarations( |
| 52 | Formatter &out, bool atTopLevel) const override; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 53 | |
| 54 | status_t emitTypeDefinitions( |
| 55 | Formatter &out, const std::string prefix) const override; |
| 56 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame^] | 57 | const std::vector<NamedType *> &getSubTypes() const; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 58 | |
| 59 | status_t emitVtsTypeDeclarations(Formatter &out) const override; |
| 60 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 61 | bool isJavaCompatible() const override; |
| 62 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 63 | private: |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame^] | 64 | std::vector<NamedType *> mTypes; |
| 65 | std::map<std::string, size_t> mTypeIndexByName; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 66 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 67 | DISALLOW_COPY_AND_ASSIGN(Scope); |
| 68 | }; |
| 69 | |
| 70 | } // namespace android |
| 71 | |
| 72 | #endif // SCOPE_H_ |
| 73 | |