blob: 7f7edc7af54afcd3d12dd3b168e44da82dec3c27 [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -07001/*
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 Huberc9410c72016-07-28 12:18:40 -070017#ifndef INTERFACE_H_
18
19#define INTERFACE_H_
20
21#include "Scope.h"
22
Andreas Huberc9410c72016-07-28 12:18:40 -070023namespace android {
24
25struct Method;
26
27struct Interface : public Scope {
Andreas Huber7c5ddfb2016-09-29 13:45:22 -070028 Interface(const char *localName, Interface *super);
Andreas Huberc9410c72016-07-28 12:18:40 -070029
Steven Moreland14ee6742016-10-18 12:58:28 -070030 bool addMethod(Method *method);
Andreas Huberc9410c72016-07-28 12:18:40 -070031
Andreas Hubera2723d22016-07-29 15:36:07 -070032 bool isInterface() const override;
Andreas Huber295ad302016-08-16 11:35:00 -070033 bool isBinder() const override;
Andreas Huberc9410c72016-07-28 12:18:40 -070034
Andreas Huber6cb08cf2016-08-03 15:44:51 -070035 const Interface *superType() const;
Andreas Huberc9410c72016-07-28 12:18:40 -070036
Andreas Huber881227d2016-08-02 14:20:21 -070037 const std::vector<Method *> &methods() const;
Steven Moreland14ee6742016-10-18 12:58:28 -070038 Method *lookupMethod(std::string name) const;
Andreas Huber881227d2016-08-02 14:20:21 -070039
Steven Moreland40786312016-08-16 10:29:40 -070040 std::string getBaseName() const;
41
Andreas Huber4c865b72016-09-14 15:26:27 -070042 std::string getCppType(
43 StorageMode mode,
44 std::string *extra,
45 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070046
Andreas Huber4c865b72016-09-14 15:26:27 -070047 std::string getJavaType(
48 std::string *extra, bool forInitializer) const override;
Andreas Huber2831d512016-08-15 09:33:47 -070049
Andreas Huber881227d2016-08-02 14:20:21 -070050 void emitReaderWriter(
51 Formatter &out,
52 const std::string &name,
53 const std::string &parcelObj,
54 bool parcelObjIsPointer,
55 bool isReader,
56 ErrorMode mode) const override;
57
Andreas Huber2831d512016-08-15 09:33:47 -070058 void emitJavaReaderWriter(
59 Formatter &out,
60 const std::string &parcelObj,
61 const std::string &argName,
62 bool isReader) const override;
63
Zhuoyao Zhang864c7712016-08-16 15:35:28 -070064 status_t emitVtsAttributeType(Formatter &out) const override;
65
66 status_t emitVtsAttributeDeclaration(Formatter &out) const;
67 status_t emitVtsMethodDeclaration(Formatter &out) const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070068
Steven Moreland69e7c702016-09-09 11:16:32 -070069 bool hasOnewayMethods() const;
70
Andreas Huber70a59e12016-08-16 12:57:01 -070071 bool isJavaCompatible() const override;
72
Andreas Huberc9410c72016-07-28 12:18:40 -070073private:
Andreas Huber6cb08cf2016-08-03 15:44:51 -070074 Interface *mSuperType;
Andreas Huber881227d2016-08-02 14:20:21 -070075 std::vector<Method *> mMethods;
Andreas Huberea081b32016-08-17 15:57:47 -070076 mutable bool mIsJavaCompatibleInProgress;
Andreas Huberc9410c72016-07-28 12:18:40 -070077
78 DISALLOW_COPY_AND_ASSIGN(Interface);
79};
80
81} // namespace android
82
83#endif // INTERFACE_H_
84