blob: 4adfbaecfab01e12f7ade81104025decadcff47c [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 Huber881227d2016-08-02 14:20:21 -070023#include <vector>
Andreas Huberc9410c72016-07-28 12:18:40 -070024
25namespace android {
26
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070027struct Annotation;
Andreas Huberc9410c72016-07-28 12:18:40 -070028struct Method;
29
30struct Interface : public Scope {
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070031 Interface(
Andreas Huber9ed827c2016-08-22 12:31:13 -070032 const char *localName,
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070033 Interface *super,
Steven Morelandd537ab02016-09-12 10:32:01 -070034 std::vector<Annotation *> *annotations);
Andreas Huberc9410c72016-07-28 12:18:40 -070035
36 void addMethod(Method *method);
37
Andreas Hubera2723d22016-07-29 15:36:07 -070038 bool isInterface() const override;
Andreas Huber295ad302016-08-16 11:35:00 -070039 bool isBinder() const override;
Andreas Huberc9410c72016-07-28 12:18:40 -070040
Andreas Huber6cb08cf2016-08-03 15:44:51 -070041 const Interface *superType() const;
Andreas Huberc9410c72016-07-28 12:18:40 -070042
Andreas Huber881227d2016-08-02 14:20:21 -070043 const std::vector<Method *> &methods() const;
44
Steven Morelandd537ab02016-09-12 10:32:01 -070045 const std::vector<Annotation *> &annotations() const;
Zhuoyao Zhangba7e6e92016-08-10 12:19:02 -070046
Steven Moreland40786312016-08-16 10:29:40 -070047 std::string getBaseName() const;
48
Andreas Huber4c865b72016-09-14 15:26:27 -070049 std::string getCppType(
50 StorageMode mode,
51 std::string *extra,
52 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070053
Andreas Huber4c865b72016-09-14 15:26:27 -070054 std::string getJavaType(
55 std::string *extra, bool forInitializer) const override;
Andreas Huber2831d512016-08-15 09:33:47 -070056
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;
Steven Morelandd537ab02016-09-12 10:32:01 -070081 std::vector<Annotation *> *mAnnotations;
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