blob: 7d5721860ac45f972b1b4051aed4a97bc253ac60 [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
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070021#include "Method.h"
Andreas Huberc9410c72016-07-28 12:18:40 -070022#include "Scope.h"
23
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070024#include <utils/KeyedVector.h>
Andreas Huber881227d2016-08-02 14:20:21 -070025#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -070026
27namespace android {
28
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070029struct Annotation;
Andreas Huberc9410c72016-07-28 12:18:40 -070030struct Method;
31
32struct Interface : public Scope {
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070033 Interface(
Andreas Huber9ed827c2016-08-22 12:31:13 -070034 const char *localName,
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070035 Interface *super,
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070036 AnnotationVector *annotations);
Andreas Huberc9410c72016-07-28 12:18:40 -070037
38 void addMethod(Method *method);
39
Andreas Hubera2723d22016-07-29 15:36:07 -070040 bool isInterface() const override;
Andreas Huber295ad302016-08-16 11:35:00 -070041 bool isBinder() const override;
Andreas Huberc9410c72016-07-28 12:18:40 -070042
Andreas Huber6cb08cf2016-08-03 15:44:51 -070043 const Interface *superType() const;
Andreas Huberc9410c72016-07-28 12:18:40 -070044
Andreas Huber881227d2016-08-02 14:20:21 -070045 const std::vector<Method *> &methods() const;
46
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070047 const AnnotationVector &annotations() const;
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070048
Steven Moreland40786312016-08-16 10:29:40 -070049 std::string getBaseName() const;
50
Andreas Huber881227d2016-08-02 14:20:21 -070051 std::string getCppType(StorageMode mode, std::string *extra) const override;
52
Andreas Huber2831d512016-08-15 09:33:47 -070053 std::string getJavaType() const override;
54
Andreas Huber881227d2016-08-02 14:20:21 -070055 void emitReaderWriter(
56 Formatter &out,
57 const std::string &name,
58 const std::string &parcelObj,
59 bool parcelObjIsPointer,
60 bool isReader,
61 ErrorMode mode) const override;
62
Andreas Huber2831d512016-08-15 09:33:47 -070063 void emitJavaReaderWriter(
64 Formatter &out,
65 const std::string &parcelObj,
66 const std::string &argName,
67 bool isReader) const override;
68
Zhuoyao Zhang864c7712016-08-16 15:35:28 -070069 status_t emitVtsAttributeType(Formatter &out) const override;
70
71 status_t emitVtsAttributeDeclaration(Formatter &out) const;
72 status_t emitVtsMethodDeclaration(Formatter &out) const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070073
Andreas Huber70a59e12016-08-16 12:57:01 -070074 bool isJavaCompatible() const override;
75
Andreas Huberc9410c72016-07-28 12:18:40 -070076private:
Andreas Huber6cb08cf2016-08-03 15:44:51 -070077 Interface *mSuperType;
Andreas Huber881227d2016-08-02 14:20:21 -070078 std::vector<Method *> mMethods;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070079 AnnotationVector *mAnnotationsByName;
Andreas Huberea081b32016-08-17 15:57:47 -070080 mutable bool mIsJavaCompatibleInProgress;
Andreas Huberc9410c72016-07-28 12:18:40 -070081
82 DISALLOW_COPY_AND_ASSIGN(Interface);
83};
84
85} // namespace android
86
87#endif // INTERFACE_H_
88