The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | #ifndef AIDL_TYPE_H |
| 2 | #define AIDL_TYPE_H |
| 3 | |
| 4 | #include "AST.h" |
| 5 | #include <string> |
| 6 | #include <vector> |
| 7 | |
| 8 | using namespace std; |
| 9 | |
| 10 | class Type |
| 11 | { |
| 12 | public: |
| 13 | // kinds |
| 14 | enum { |
| 15 | BUILT_IN, |
| 16 | PARCELABLE, |
| 17 | INTERFACE, |
| 18 | GENERATED |
| 19 | }; |
| 20 | |
| 21 | // WriteToParcel flags |
| 22 | enum { |
| 23 | PARCELABLE_WRITE_RETURN_VALUE = 0x0001 |
| 24 | }; |
| 25 | |
| 26 | Type(const string& name, int kind, bool canWriteToParcel, |
| 27 | bool canBeOut); |
| 28 | Type(const string& package, const string& name, |
| 29 | int kind, bool canWriteToParcel, bool canBeOut, |
| 30 | const string& declFile = "", int declLine = -1); |
| 31 | virtual ~Type(); |
| 32 | |
| 33 | inline string Package() const { return m_package; } |
| 34 | inline string Name() const { return m_name; } |
| 35 | inline string QualifiedName() const { return m_qualifiedName; } |
| 36 | inline int Kind() const { return m_kind; } |
| 37 | inline string DeclFile() const { return m_declFile; } |
| 38 | inline int DeclLine() const { return m_declLine; } |
| 39 | inline bool CanBeMarshalled() const { return m_canWriteToParcel; } |
| 40 | inline bool CanBeOutParameter() const { return m_canBeOut; } |
| 41 | |
| 42 | virtual string ImportType() const; |
| 43 | virtual string CreatorName() const; |
| 44 | virtual string InstantiableName() const; |
| 45 | |
| 46 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 47 | Variable* parcel, int flags); |
| 48 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 49 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 51 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | |
| 53 | virtual bool CanBeArray() const; |
| 54 | |
| 55 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 56 | Variable* parcel, int flags); |
| 57 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 58 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 60 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 62 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 63 | Variable* data, int flags); |
| 64 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 65 | Variable* data, Variable** cl); |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 66 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | protected: |
| 68 | void SetQualifiedName(const string& qualified); |
| 69 | Expression* BuildWriteToParcelFlags(int flags); |
| 70 | |
| 71 | private: |
| 72 | Type(); |
| 73 | Type(const Type&); |
| 74 | |
| 75 | string m_package; |
| 76 | string m_name; |
| 77 | string m_qualifiedName; |
| 78 | string m_declFile; |
| 79 | int m_declLine; |
| 80 | int m_kind; |
| 81 | bool m_canWriteToParcel; |
| 82 | bool m_canBeOut; |
| 83 | }; |
| 84 | |
| 85 | class BasicType : public Type |
| 86 | { |
| 87 | public: |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 88 | BasicType(const string& name, |
| 89 | const string& marshallParcel, |
| 90 | const string& unmarshallParcel, |
| 91 | const string& writeArrayParcel, |
| 92 | const string& createArrayParcel, |
| 93 | const string& readArrayParcel, |
| 94 | const string& marshallRpc, |
| 95 | const string& unmarshallRpc, |
| 96 | const string& writeArrayRpc, |
| 97 | const string& createArrayRpc, |
| 98 | const string& readArrayRpc); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | |
| 100 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 101 | Variable* parcel, int flags); |
| 102 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 103 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | |
| 105 | virtual bool CanBeArray() const; |
| 106 | |
| 107 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 108 | Variable* parcel, int flags); |
| 109 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 110 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 112 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 114 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 115 | Variable* data, int flags); |
| 116 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 117 | Variable* data, Variable** cl); |
| 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | private: |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 120 | string m_marshallParcel; |
| 121 | string m_unmarshallParcel; |
| 122 | string m_writeArrayParcel; |
| 123 | string m_createArrayParcel; |
| 124 | string m_readArrayParcel; |
| 125 | string m_marshallRpc; |
| 126 | string m_unmarshallRpc; |
| 127 | string m_writeArrayRpc; |
| 128 | string m_createArrayRpc; |
| 129 | string m_readArrayRpc; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | class BooleanType : public Type |
| 133 | { |
| 134 | public: |
| 135 | BooleanType(); |
| 136 | |
| 137 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 138 | Variable* parcel, int flags); |
| 139 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 140 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | |
| 142 | virtual bool CanBeArray() const; |
| 143 | |
| 144 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 145 | Variable* parcel, int flags); |
| 146 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 147 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 149 | Variable* parcel, Variable** cl); |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 150 | |
| 151 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 152 | Variable* data, int flags); |
| 153 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 154 | Variable* data, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | class CharType : public Type |
| 158 | { |
| 159 | public: |
| 160 | CharType(); |
| 161 | |
| 162 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 163 | Variable* parcel, int flags); |
| 164 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 165 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | |
| 167 | virtual bool CanBeArray() const; |
| 168 | |
| 169 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 170 | Variable* parcel, int flags); |
| 171 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 172 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 174 | Variable* parcel, Variable** cl); |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 175 | |
| 176 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 177 | Variable* data, int flags); |
| 178 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 179 | Variable* data, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | |
| 183 | class StringType : public Type |
| 184 | { |
| 185 | public: |
| 186 | StringType(); |
| 187 | |
| 188 | virtual string CreatorName() const; |
| 189 | |
| 190 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 191 | Variable* parcel, int flags); |
| 192 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 193 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | |
| 195 | virtual bool CanBeArray() const; |
| 196 | |
| 197 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 198 | Variable* parcel, int flags); |
| 199 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 200 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 201 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 202 | Variable* parcel, Variable** cl); |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 203 | |
| 204 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 205 | Variable* data, int flags); |
| 206 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 207 | Variable* data, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | class CharSequenceType : public Type |
| 211 | { |
| 212 | public: |
| 213 | CharSequenceType(); |
| 214 | |
| 215 | virtual string CreatorName() const; |
| 216 | |
| 217 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 218 | Variable* parcel, int flags); |
| 219 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 220 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | }; |
| 222 | |
| 223 | class RemoteExceptionType : public Type |
| 224 | { |
| 225 | public: |
| 226 | RemoteExceptionType(); |
| 227 | |
| 228 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 229 | Variable* parcel, int flags); |
| 230 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 231 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 232 | }; |
| 233 | |
| 234 | class RuntimeExceptionType : public Type |
| 235 | { |
| 236 | public: |
| 237 | RuntimeExceptionType(); |
| 238 | |
| 239 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 240 | Variable* parcel, int flags); |
| 241 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 242 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | }; |
| 244 | |
| 245 | class IBinderType : public Type |
| 246 | { |
| 247 | public: |
| 248 | IBinderType(); |
| 249 | |
| 250 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 251 | Variable* parcel, int flags); |
| 252 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 253 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 254 | |
| 255 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 256 | Variable* parcel, int flags); |
| 257 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 258 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 260 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | class IInterfaceType : public Type |
| 264 | { |
| 265 | public: |
| 266 | IInterfaceType(); |
| 267 | |
| 268 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 269 | Variable* parcel, int flags); |
| 270 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 271 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | }; |
| 273 | |
| 274 | class BinderType : public Type |
| 275 | { |
| 276 | public: |
| 277 | BinderType(); |
| 278 | |
| 279 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 280 | Variable* parcel, int flags); |
| 281 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 282 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | class BinderProxyType : public Type |
| 286 | { |
| 287 | public: |
| 288 | BinderProxyType(); |
| 289 | |
| 290 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 291 | Variable* parcel, int flags); |
| 292 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 293 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | class ParcelType : public Type |
| 297 | { |
| 298 | public: |
| 299 | ParcelType(); |
| 300 | |
| 301 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 302 | Variable* parcel, int flags); |
| 303 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 304 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 305 | }; |
| 306 | |
| 307 | class ParcelableInterfaceType : public Type |
| 308 | { |
| 309 | public: |
| 310 | ParcelableInterfaceType(); |
| 311 | |
| 312 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 313 | Variable* parcel, int flags); |
| 314 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 315 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | }; |
| 317 | |
| 318 | class MapType : public Type |
| 319 | { |
| 320 | public: |
| 321 | MapType(); |
| 322 | |
| 323 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 324 | Variable* parcel, int flags); |
| 325 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 326 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 327 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 328 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | }; |
| 330 | |
| 331 | class ListType : public Type |
| 332 | { |
| 333 | public: |
| 334 | ListType(); |
| 335 | |
| 336 | virtual string InstantiableName() const; |
| 337 | |
| 338 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 339 | Variable* parcel, int flags); |
| 340 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 341 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 343 | Variable* parcel, Variable** cl); |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 344 | |
| 345 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 346 | Variable* data, int flags); |
| 347 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 348 | Variable* data, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 349 | }; |
| 350 | |
| 351 | class ParcelableType : public Type |
| 352 | { |
| 353 | public: |
| 354 | ParcelableType(const string& package, const string& name, |
| 355 | bool builtIn, const string& declFile, int declLine); |
| 356 | |
| 357 | virtual string CreatorName() const; |
| 358 | |
| 359 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 360 | Variable* parcel, int flags); |
| 361 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 362 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 363 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 364 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 365 | |
| 366 | virtual bool CanBeArray() const; |
| 367 | |
| 368 | virtual void WriteArrayToParcel(StatementBlock* addTo, Variable* v, |
| 369 | Variable* parcel, int flags); |
| 370 | virtual void CreateArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 371 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 372 | virtual void ReadArrayFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 373 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | }; |
| 375 | |
| 376 | class InterfaceType : public Type |
| 377 | { |
| 378 | public: |
| 379 | InterfaceType(const string& package, const string& name, |
| 380 | bool builtIn, bool oneway, |
| 381 | const string& declFile, int declLine); |
| 382 | |
| 383 | bool OneWay() const; |
| 384 | |
| 385 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 386 | Variable* parcel, int flags); |
| 387 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 388 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | |
| 390 | private: |
| 391 | bool m_oneway; |
| 392 | }; |
| 393 | |
| 394 | |
| 395 | class GenericType : public Type |
| 396 | { |
| 397 | public: |
| 398 | GenericType(const string& package, const string& name, |
| 399 | const vector<Type*>& args); |
| 400 | |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 401 | const vector<Type*>& GenericArgumentTypes() const; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | string GenericArguments() const; |
| 403 | |
| 404 | virtual string ImportType() const; |
| 405 | |
| 406 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 407 | Variable* parcel, int flags); |
| 408 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 409 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 411 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | |
| 413 | private: |
| 414 | string m_genericArguments; |
| 415 | string m_importName; |
| 416 | vector<Type*> m_args; |
| 417 | }; |
| 418 | |
| 419 | |
| 420 | class GenericListType : public GenericType |
| 421 | { |
| 422 | public: |
| 423 | GenericListType(const string& package, const string& name, |
| 424 | const vector<Type*>& args); |
| 425 | |
| 426 | virtual string CreatorName() const; |
| 427 | virtual string InstantiableName() const; |
| 428 | |
| 429 | virtual void WriteToParcel(StatementBlock* addTo, Variable* v, |
| 430 | Variable* parcel, int flags); |
| 431 | virtual void CreateFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 432 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 433 | virtual void ReadFromParcel(StatementBlock* addTo, Variable* v, |
Elliott Hughes | b9eba86 | 2011-07-13 12:10:30 -0700 | [diff] [blame] | 434 | Variable* parcel, Variable** cl); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 435 | |
Joe Onorato | a1426e6 | 2011-09-02 15:28:36 -0700 | [diff] [blame^] | 436 | virtual void WriteToRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 437 | Variable* data, int flags); |
| 438 | virtual void CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, |
| 439 | Variable* data, Variable** cl); |
| 440 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | private: |
| 442 | string m_creator; |
| 443 | }; |
| 444 | |
| 445 | class ClassLoaderType : public Type |
| 446 | { |
| 447 | public: |
| 448 | ClassLoaderType(); |
| 449 | }; |
| 450 | |
| 451 | class Namespace |
| 452 | { |
| 453 | public: |
| 454 | Namespace(); |
| 455 | ~Namespace(); |
| 456 | void Add(Type* type); |
| 457 | |
| 458 | // args is the number of template types (what is this called?) |
| 459 | void AddGenericType(const string& package, const string& name, int args); |
| 460 | |
| 461 | // lookup a specific class name |
| 462 | Type* Find(const string& name) const; |
| 463 | Type* Find(const char* package, const char* name) const; |
| 464 | |
| 465 | // try to search by either a full name or a partial name |
| 466 | Type* Search(const string& name); |
| 467 | |
| 468 | void Dump() const; |
| 469 | |
| 470 | private: |
| 471 | struct Generic { |
| 472 | string package; |
| 473 | string name; |
| 474 | string qualified; |
| 475 | int args; |
| 476 | }; |
| 477 | |
| 478 | const Generic* search_generic(const string& name) const; |
| 479 | |
| 480 | vector<Type*> m_types; |
| 481 | vector<Generic> m_generics; |
| 482 | }; |
| 483 | |
| 484 | extern Namespace NAMES; |
| 485 | |
| 486 | extern Type* VOID_TYPE; |
| 487 | extern Type* BOOLEAN_TYPE; |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 488 | extern Type* BYTE_TYPE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 489 | extern Type* CHAR_TYPE; |
| 490 | extern Type* INT_TYPE; |
| 491 | extern Type* LONG_TYPE; |
| 492 | extern Type* FLOAT_TYPE; |
| 493 | extern Type* DOUBLE_TYPE; |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 494 | extern Type* OBJECT_TYPE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | extern Type* STRING_TYPE; |
| 496 | extern Type* CHAR_SEQUENCE_TYPE; |
| 497 | extern Type* TEXT_UTILS_TYPE; |
| 498 | extern Type* REMOTE_EXCEPTION_TYPE; |
| 499 | extern Type* RUNTIME_EXCEPTION_TYPE; |
| 500 | extern Type* IBINDER_TYPE; |
| 501 | extern Type* IINTERFACE_TYPE; |
| 502 | extern Type* BINDER_NATIVE_TYPE; |
| 503 | extern Type* BINDER_PROXY_TYPE; |
| 504 | extern Type* PARCEL_TYPE; |
| 505 | extern Type* PARCELABLE_INTERFACE_TYPE; |
| 506 | |
Joe Onorato | 7add83b | 2011-08-30 17:24:17 -0700 | [diff] [blame] | 507 | extern Type* CONTEXT_TYPE; |
| 508 | |
| 509 | extern Type* RPC_SERVICE_BASE_TYPE; |
| 510 | extern Type* RPC_DATA_TYPE; |
| 511 | extern Type* RPC_BROKER_TYPE; |
| 512 | extern Type* RPC_ENDPOINT_INFO_TYPE; |
| 513 | extern Type* RPC_RESULT_HANDLER_TYPE; |
| 514 | extern Type* RPC_ERROR_TYPE; |
| 515 | extern Type* RPC_ERROR_LISTENER_TYPE; |
| 516 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | extern Expression* NULL_VALUE; |
| 518 | extern Expression* THIS_VALUE; |
| 519 | extern Expression* SUPER_VALUE; |
| 520 | extern Expression* TRUE_VALUE; |
| 521 | extern Expression* FALSE_VALUE; |
| 522 | |
| 523 | void register_base_types(); |
| 524 | |
| 525 | #endif // AIDL_TYPE_H |