blob: dc163960a56bc84a739a1bd3514ecccde357feb5 [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
Steven Moreland979e0992016-09-07 09:18:08 -070051 std::string getCppType(StorageMode mode,
52 std::string *extra,
53 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070054
Andreas Huber2831d512016-08-15 09:33:47 -070055 std::string getJavaType() const override;
56
Andreas Huber881227d2016-08-02 14:20:21 -070057 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 Huber2831d512016-08-15 09:33:47 -070065 void emitJavaReaderWriter(
66 Formatter &out,
67 const std::string &parcelObj,
68 const std::string &argName,
69 bool isReader) const override;
70
Zhuoyao Zhang864c7712016-08-16 15:35:28 -070071 status_t emitVtsAttributeType(Formatter &out) const override;
72
73 status_t emitVtsAttributeDeclaration(Formatter &out) const;
74 status_t emitVtsMethodDeclaration(Formatter &out) const;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070075
Andreas Huber70a59e12016-08-16 12:57:01 -070076 bool isJavaCompatible() const override;
77
Andreas Huberc9410c72016-07-28 12:18:40 -070078private:
Andreas Huber6cb08cf2016-08-03 15:44:51 -070079 Interface *mSuperType;
Andreas Huber881227d2016-08-02 14:20:21 -070080 std::vector<Method *> mMethods;
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070081 AnnotationVector *mAnnotationsByName;
Andreas Huberea081b32016-08-17 15:57:47 -070082 mutable bool mIsJavaCompatibleInProgress;
Andreas Huberc9410c72016-07-28 12:18:40 -070083
84 DISALLOW_COPY_AND_ASSIGN(Interface);
85};
86
87} // namespace android
88
89#endif // INTERFACE_H_
90