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