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 INTERFACE_H_ |
| 18 | |
| 19 | #define INTERFACE_H_ |
| 20 | |
| 21 | #include "Scope.h" |
| 22 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 23 | #include <vector> |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
Zhuoyao Zhang | ba7e6e9 | 2016-08-10 12:19:02 -0700 | [diff] [blame] | 27 | struct Annotation; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 28 | struct Method; |
| 29 | |
| 30 | struct Interface : public Scope { |
Zhuoyao Zhang | ba7e6e9 | 2016-08-10 12:19:02 -0700 | [diff] [blame] | 31 | Interface( |
Andreas Huber | 9ed827c | 2016-08-22 12:31:13 -0700 | [diff] [blame] | 32 | const char *localName, |
Zhuoyao Zhang | ba7e6e9 | 2016-08-10 12:19:02 -0700 | [diff] [blame] | 33 | Interface *super, |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 34 | std::vector<Annotation *> *annotations); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 35 | |
| 36 | void addMethod(Method *method); |
| 37 | |
Andreas Huber | a2723d2 | 2016-07-29 15:36:07 -0700 | [diff] [blame] | 38 | bool isInterface() const override; |
Andreas Huber | 295ad30 | 2016-08-16 11:35:00 -0700 | [diff] [blame] | 39 | bool isBinder() const override; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 40 | |
Andreas Huber | 6cb08cf | 2016-08-03 15:44:51 -0700 | [diff] [blame] | 41 | const Interface *superType() const; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 42 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 43 | const std::vector<Method *> &methods() const; |
| 44 | |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 45 | const std::vector<Annotation *> &annotations() const; |
Zhuoyao Zhang | ba7e6e9 | 2016-08-10 12:19:02 -0700 | [diff] [blame] | 46 | |
Steven Moreland | 4078631 | 2016-08-16 10:29:40 -0700 | [diff] [blame] | 47 | std::string getBaseName() const; |
| 48 | |
Andreas Huber | 4c865b7 | 2016-09-14 15:26:27 -0700 | [diff] [blame] | 49 | std::string getCppType( |
| 50 | StorageMode mode, |
| 51 | std::string *extra, |
| 52 | bool specifyNamespaces) const override; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 53 | |
Andreas Huber | 4c865b7 | 2016-09-14 15:26:27 -0700 | [diff] [blame] | 54 | std::string getJavaType( |
| 55 | std::string *extra, bool forInitializer) const override; |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 56 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 57 | void emitReaderWriter( |
| 58 | Formatter &out, |
| 59 | const std::string &name, |
| 60 | const std::string &parcelObj, |
| 61 | bool parcelObjIsPointer, |
| 62 | bool isReader, |
| 63 | ErrorMode mode) const override; |
| 64 | |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 65 | void emitJavaReaderWriter( |
| 66 | Formatter &out, |
| 67 | const std::string &parcelObj, |
| 68 | const std::string &argName, |
| 69 | bool isReader) const override; |
| 70 | |
Zhuoyao Zhang | 864c771 | 2016-08-16 15:35:28 -0700 | [diff] [blame] | 71 | status_t emitVtsAttributeType(Formatter &out) const override; |
| 72 | |
| 73 | status_t emitVtsAttributeDeclaration(Formatter &out) const; |
| 74 | status_t emitVtsMethodDeclaration(Formatter &out) const; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 75 | |
Steven Moreland | 69e7c70 | 2016-09-09 11:16:32 -0700 | [diff] [blame] | 76 | bool hasOnewayMethods() const; |
| 77 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 78 | bool isJavaCompatible() const override; |
| 79 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 80 | private: |
Andreas Huber | 6cb08cf | 2016-08-03 15:44:51 -0700 | [diff] [blame] | 81 | Interface *mSuperType; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 82 | std::vector<Method *> mMethods; |
Steven Moreland | d537ab0 | 2016-09-12 10:32:01 -0700 | [diff] [blame] | 83 | std::vector<Annotation *> *mAnnotations; |
Andreas Huber | ea081b3 | 2016-08-17 15:57:47 -0700 | [diff] [blame] | 84 | mutable bool mIsJavaCompatibleInProgress; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 85 | |
| 86 | DISALLOW_COPY_AND_ASSIGN(Interface); |
| 87 | }; |
| 88 | |
| 89 | } // namespace android |
| 90 | |
| 91 | #endif // INTERFACE_H_ |
| 92 | |