Christopher Wiley | 775fa1f | 2015-09-22 15:00:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, 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 | |
Steven Moreland | 9fccf58 | 2018-08-27 20:36:27 -0700 | [diff] [blame] | 17 | #pragma once |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 18 | |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
Christopher Wiley | 038485e | 2015-09-12 11:14:14 -0700 | [diff] [blame] | 22 | #include "ast_java.h" |
Christopher Wiley | 84c1eac | 2015-09-23 13:29:28 -0700 | [diff] [blame] | 23 | #include "type_namespace.h" |
Christopher Wiley | 038485e | 2015-09-12 11:14:14 -0700 | [diff] [blame] | 24 | |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 25 | namespace android { |
| 26 | namespace aidl { |
Christopher Wiley | db154a5 | 2015-09-28 16:32:25 -0700 | [diff] [blame] | 27 | namespace java { |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 28 | |
Christopher Wiley | 8b2d3ee | 2015-09-23 15:43:01 -0700 | [diff] [blame] | 29 | class JavaTypeNamespace; |
Christopher Wiley | 60b02ae | 2015-09-23 16:35:18 -0700 | [diff] [blame] | 30 | |
Christopher Wiley | fb4b22d | 2015-09-25 15:16:13 -0700 | [diff] [blame] | 31 | class Type : public ValidatableType { |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 32 | public: |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 33 | // WriteToParcel flags |
| 34 | enum { PARCELABLE_WRITE_RETURN_VALUE = 0x0001 }; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 35 | |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 36 | // defaultValue is by default set to "null" because that is the default value |
| 37 | // for most of the types like class and array. default values for built-in |
| 38 | // types like int, double, boolean, etc. are explicitly set via BasicType |
Jiyong Park | 1d2df7d | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 39 | Type(const JavaTypeNamespace* types, const std::string& name, int kind, bool canWriteToParcel); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 40 | Type(const JavaTypeNamespace* types, const std::string& package, const std::string& name, |
Jiyong Park | 1d2df7d | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 41 | int kind, bool canWriteToParcel, const std::string& declFile = "", int declLine = -1); |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 42 | virtual ~Type() = default; |
| 43 | |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 44 | bool CanWriteToParcel() const override { return m_canWriteToParcel; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 45 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 46 | const ValidatableType* ArrayType() const override { return m_array_type.get(); } |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 47 | const ValidatableType* NullableType() const override { return nullptr; } |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 48 | |
Christopher Wiley | d21bfee | 2016-01-29 15:11:38 -0800 | [diff] [blame] | 49 | virtual std::string JavaType() const { return m_javaType; } |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 50 | virtual std::string InstantiableName() const; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 51 | |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 52 | // The namespace where this type is defined in |
| 53 | const JavaTypeNamespace* GetTypeNamespace() const { return m_types; } |
| 54 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 55 | protected: |
Christopher Wiley | 3637a4d | 2015-09-22 15:37:59 -0700 | [diff] [blame] | 56 | Expression* BuildWriteToParcelFlags(int flags) const; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 57 | |
Christopher Wiley | 8b2d3ee | 2015-09-23 15:43:01 -0700 | [diff] [blame] | 58 | const JavaTypeNamespace* m_types; |
| 59 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 60 | std::unique_ptr<Type> m_array_type; |
| 61 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 62 | private: |
| 63 | Type(); |
| 64 | Type(const Type&); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 65 | |
Christopher Wiley | d21bfee | 2016-01-29 15:11:38 -0800 | [diff] [blame] | 66 | std::string m_javaType; |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 67 | std::string m_declFile; |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 68 | bool m_canWriteToParcel; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 71 | class BasicArrayType : public Type { |
| 72 | public: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 73 | BasicArrayType(const JavaTypeNamespace* types, const std::string& name, |
| 74 | const std::string& writeArrayParcel, |
| 75 | const std::string& createArrayParcel, |
| 76 | const std::string& readArrayParcel); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 77 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 78 | const ValidatableType* NullableType() const override { return this; } |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 79 | |
| 80 | private: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 81 | std::string m_writeArrayParcel; |
| 82 | std::string m_createArrayParcel; |
| 83 | std::string m_readArrayParcel; |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 86 | class BasicType : public Type { |
| 87 | public: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 88 | BasicType(const JavaTypeNamespace* types, const std::string& name, |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 89 | const std::string& marshallParcel, const std::string& unmarshallParcel, |
| 90 | const std::string& writeArrayParcel, const std::string& createArrayParcel, |
Jiyong Park | 1d2df7d | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 91 | const std::string& readArrayParcel); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 92 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 93 | private: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 94 | std::string m_marshallParcel; |
| 95 | std::string m_unmarshallParcel; |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | class FileDescriptorArrayType : public Type { |
| 99 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 100 | explicit FileDescriptorArrayType(const JavaTypeNamespace* types); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 101 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 102 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 103 | }; |
| 104 | |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 105 | class FileDescriptorType : public Type { |
| 106 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 107 | explicit FileDescriptorType(const JavaTypeNamespace* types); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 108 | }; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 109 | |
Jiyong Park | e05195e | 2018-10-08 18:24:23 +0900 | [diff] [blame] | 110 | class ParcelFileDescriptorArrayType : public Type { |
| 111 | public: |
| 112 | explicit ParcelFileDescriptorArrayType(const JavaTypeNamespace* types); |
| 113 | |
| 114 | const ValidatableType* NullableType() const override { return this; } |
| 115 | }; |
| 116 | |
| 117 | class ParcelFileDescriptorType : public Type { |
| 118 | public: |
| 119 | explicit ParcelFileDescriptorType(const JavaTypeNamespace* types); |
| 120 | |
| 121 | const ValidatableType* NullableType() const override { return this; } |
| 122 | }; |
| 123 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 124 | class BooleanArrayType : public Type { |
| 125 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 126 | explicit BooleanArrayType(const JavaTypeNamespace* types); |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 127 | const ValidatableType* NullableType() const override { return this; } |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 128 | }; |
| 129 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 130 | class BooleanType : public Type { |
| 131 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 132 | explicit BooleanType(const JavaTypeNamespace* types); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 133 | }; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 134 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 135 | class CharArrayType : public Type { |
| 136 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 137 | explicit CharArrayType(const JavaTypeNamespace* types); |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 138 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 139 | }; |
| 140 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 141 | class CharType : public Type { |
| 142 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 143 | explicit CharType(const JavaTypeNamespace* types); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 144 | }; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 145 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 146 | class StringArrayType : public Type { |
| 147 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 148 | explicit StringArrayType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 149 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 150 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 151 | }; |
| 152 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 153 | class StringType : public Type { |
| 154 | public: |
Christopher Wiley | 9f40372 | 2016-01-27 16:04:11 -0800 | [diff] [blame] | 155 | StringType(const JavaTypeNamespace* types, const std::string& package, |
| 156 | const std::string& class_name); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 157 | |
Christopher Wiley | d21bfee | 2016-01-29 15:11:38 -0800 | [diff] [blame] | 158 | std::string JavaType() const override { return "java.lang.String"; } |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 159 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 160 | }; |
| 161 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 162 | class CharSequenceType : public Type { |
| 163 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 164 | explicit CharSequenceType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 165 | }; |
| 166 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 167 | class RemoteExceptionType : public Type { |
| 168 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 169 | explicit RemoteExceptionType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 170 | }; |
| 171 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 172 | class RuntimeExceptionType : public Type { |
| 173 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 174 | explicit RuntimeExceptionType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 175 | }; |
| 176 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 177 | class IBinderArrayType : public Type { |
| 178 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 179 | explicit IBinderArrayType(const JavaTypeNamespace* types); |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 180 | const ValidatableType* NullableType() const override { return this; } |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 181 | }; |
| 182 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 183 | class IBinderType : public Type { |
| 184 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 185 | explicit IBinderType(const JavaTypeNamespace* types); |
Christopher Wiley | d646e0b | 2016-03-09 09:24:55 -0800 | [diff] [blame] | 186 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 187 | }; |
| 188 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 189 | class IInterfaceType : public Type { |
| 190 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 191 | explicit IInterfaceType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 194 | class BinderType : public Type { |
| 195 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 196 | explicit BinderType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 197 | }; |
| 198 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 199 | class BinderProxyType : public Type { |
| 200 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 201 | explicit BinderProxyType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 202 | }; |
| 203 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 204 | class ParcelType : public Type { |
| 205 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 206 | explicit ParcelType(const JavaTypeNamespace* types); |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 207 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 208 | }; |
| 209 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 210 | class ParcelableInterfaceType : public Type { |
| 211 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 212 | explicit ParcelableInterfaceType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 213 | }; |
| 214 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 215 | class MapType : public Type { |
| 216 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 217 | explicit MapType(const JavaTypeNamespace* types); |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 218 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 219 | }; |
| 220 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 221 | class ListType : public Type { |
| 222 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 223 | explicit ListType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 224 | |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 225 | std::string InstantiableName() const override; |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 226 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 227 | }; |
| 228 | |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 229 | class UserDataArrayType : public Type { |
| 230 | public: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 231 | UserDataArrayType(const JavaTypeNamespace* types, const std::string& package, |
| 232 | const std::string& name, bool builtIn, |
| 233 | bool canWriteToParcel, const std::string& declFile = "", |
| 234 | int declLine = -1); |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 235 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 236 | const ValidatableType* NullableType() const override { return this; } |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 237 | }; |
| 238 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 239 | class UserDataType : public Type { |
| 240 | public: |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 241 | UserDataType(const JavaTypeNamespace* types, const std::string& package, |
| 242 | const std::string& name, bool builtIn, bool canWriteToParcel, |
| 243 | const std::string& declFile = "", int declLine = -1); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 244 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 245 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 246 | }; |
| 247 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 248 | class InterfaceType : public Type { |
| 249 | public: |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 250 | InterfaceType(const JavaTypeNamespace* types, const std::string& package, const std::string& name, |
Steven Moreland | acd5347 | 2018-12-14 10:17:26 -0800 | [diff] [blame] | 251 | bool builtIn, const std::string& declFile, int declLine, const Type* stub, |
| 252 | const Type* proxy, const Type* defaultImpl); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 253 | |
Christopher Wiley | 0123543 | 2016-07-15 11:15:56 -0700 | [diff] [blame] | 254 | const ValidatableType* NullableType() const override { return this; } |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 255 | const Type* GetStub() const { return stub_; } |
| 256 | const Type* GetProxy() const { return proxy_; } |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 257 | const Type* GetDefaultImpl() const { return defaultImpl_; } |
Christopher Wiley | f690be5 | 2015-09-14 15:19:10 -0700 | [diff] [blame] | 258 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 259 | private: |
Casey Dahlin | a2f77c4 | 2015-12-01 18:26:02 -0800 | [diff] [blame] | 260 | const Type* stub_; |
| 261 | const Type* proxy_; |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 262 | const Type* defaultImpl_; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 263 | }; |
| 264 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 265 | class ClassLoaderType : public Type { |
| 266 | public: |
Chih-Hung Hsieh | 156a57f | 2016-06-02 16:17:28 -0700 | [diff] [blame] | 267 | explicit ClassLoaderType(const JavaTypeNamespace* types); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 268 | }; |
| 269 | |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 270 | class GenericListType : public Type { |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 271 | public: |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 272 | GenericListType(const JavaTypeNamespace* types, const Type* arg); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 273 | |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 274 | std::string InstantiableName() const override; |
Christopher Wiley | 5d9bc93 | 2016-02-01 13:23:16 -0800 | [diff] [blame] | 275 | std::string JavaType() const override { |
| 276 | return "java.util.List<" + m_contained_type->JavaType() + ">"; |
| 277 | } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 278 | |
Casey Dahlin | 57dbe24 | 2015-12-04 11:44:02 -0800 | [diff] [blame] | 279 | const ValidatableType* NullableType() const override { return this; } |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 280 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 281 | private: |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 282 | const Type* m_contained_type; |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 283 | }; |
| 284 | |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 285 | class JavaTypeNamespace : public LanguageTypeNamespace<Type> { |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 286 | public: |
Christopher Wiley | 5679952 | 2015-10-31 10:17:04 -0700 | [diff] [blame] | 287 | JavaTypeNamespace() = default; |
Christopher Wiley | 09af469 | 2015-10-30 11:48:25 -0700 | [diff] [blame] | 288 | virtual ~JavaTypeNamespace() = default; |
Christopher Wiley | 84c1eac | 2015-09-23 13:29:28 -0700 | [diff] [blame] | 289 | |
Christopher Wiley | 5679952 | 2015-10-31 10:17:04 -0700 | [diff] [blame] | 290 | void Init() override; |
Casey Dahlin | c1f39b4 | 2015-11-24 10:34:34 -0800 | [diff] [blame] | 291 | bool AddParcelableType(const AidlParcelable& p, |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 292 | const std::string& filename) override; |
Casey Dahlin | c1f39b4 | 2015-11-24 10:34:34 -0800 | [diff] [blame] | 293 | bool AddBinderType(const AidlInterface& b, |
Christopher Wiley | 12e894a | 2016-01-29 11:55:07 -0800 | [diff] [blame] | 294 | const std::string& filename) override; |
Christopher Wiley | cd8e897 | 2015-10-26 10:24:35 -0700 | [diff] [blame] | 295 | bool AddListType(const std::string& contained_type_name) override; |
| 296 | bool AddMapType(const std::string& key_type_name, |
| 297 | const std::string& value_type_name) override; |
Christopher Wiley | 4582ecb | 2015-09-25 13:27:45 -0700 | [diff] [blame] | 298 | |
Christopher Wiley | 60b02ae | 2015-09-23 16:35:18 -0700 | [diff] [blame] | 299 | const Type* BoolType() const { return m_bool_type; } |
| 300 | const Type* IntType() const { return m_int_type; } |
| 301 | const Type* StringType() const { return m_string_type; } |
| 302 | const Type* TextUtilsType() const { return m_text_utils_type; } |
| 303 | const Type* RemoteExceptionType() const { return m_remote_exception_type; } |
| 304 | const Type* RuntimeExceptionType() const { return m_runtime_exception_type; } |
| 305 | const Type* IBinderType() const { return m_ibinder_type; } |
| 306 | const Type* IInterfaceType() const { return m_iinterface_type; } |
| 307 | const Type* BinderNativeType() const { return m_binder_native_type; } |
| 308 | const Type* BinderProxyType() const { return m_binder_proxy_type; } |
| 309 | const Type* ParcelType() const { return m_parcel_type; } |
| 310 | const Type* ParcelableInterfaceType() const { |
| 311 | return m_parcelable_interface_type; |
| 312 | } |
| 313 | const Type* ContextType() const { return m_context_type; } |
| 314 | const Type* ClassLoaderType() const { return m_classloader_type; } |
Christopher Wiley | 8b2d3ee | 2015-09-23 15:43:01 -0700 | [diff] [blame] | 315 | |
Christopher Wiley | e6dee91 | 2015-09-22 14:50:23 -0700 | [diff] [blame] | 316 | private: |
Christopher Wiley | 60b02ae | 2015-09-23 16:35:18 -0700 | [diff] [blame] | 317 | const Type* m_bool_type{nullptr}; |
| 318 | const Type* m_int_type{nullptr}; |
| 319 | const Type* m_string_type{nullptr}; |
| 320 | const Type* m_text_utils_type{nullptr}; |
| 321 | const Type* m_remote_exception_type{nullptr}; |
| 322 | const Type* m_runtime_exception_type{nullptr}; |
| 323 | const Type* m_ibinder_type{nullptr}; |
| 324 | const Type* m_iinterface_type{nullptr}; |
| 325 | const Type* m_binder_native_type{nullptr}; |
| 326 | const Type* m_binder_proxy_type{nullptr}; |
| 327 | const Type* m_parcel_type{nullptr}; |
| 328 | const Type* m_parcelable_interface_type{nullptr}; |
| 329 | const Type* m_context_type{nullptr}; |
| 330 | const Type* m_classloader_type{nullptr}; |
Christopher Wiley | 8b2d3ee | 2015-09-23 15:43:01 -0700 | [diff] [blame] | 331 | |
Christopher Wiley | 84c1eac | 2015-09-23 13:29:28 -0700 | [diff] [blame] | 332 | DISALLOW_COPY_AND_ASSIGN(JavaTypeNamespace); |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 333 | }; |
| 334 | |
Adam Lesinski | ffa1686 | 2014-01-23 18:17:42 -0800 | [diff] [blame] | 335 | extern Expression* NULL_VALUE; |
| 336 | extern Expression* THIS_VALUE; |
| 337 | extern Expression* SUPER_VALUE; |
| 338 | extern Expression* TRUE_VALUE; |
| 339 | extern Expression* FALSE_VALUE; |
| 340 | |
Christopher Wiley | db154a5 | 2015-09-28 16:32:25 -0700 | [diff] [blame] | 341 | } // namespace java |
Christopher Wiley | fdeb0f4 | 2015-09-11 15:38:22 -0700 | [diff] [blame] | 342 | } // namespace aidl |
| 343 | } // namespace android |