Andreas Huber | 1aec397 | 2016-08-26 09:26:32 -0700 | [diff] [blame] | 1 | /* |
| 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 Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 17 | #ifndef METHOD_H_ |
| 18 | |
| 19 | #define METHOD_H_ |
| 20 | |
| 21 | #include <android-base/macros.h> |
| 22 | #include <string> |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 23 | #include <utils/KeyedVector.h> |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 24 | #include <vector> |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 28 | struct Annotation; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 29 | struct Formatter; |
Iliyan Malchev | 40d474a | 2016-08-16 06:20:17 -0700 | [diff] [blame] | 30 | struct ScalarType; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 31 | struct Type; |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 32 | struct TypedVar; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 33 | |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 34 | using AnnotationVector = |
| 35 | DefaultKeyedVector<std::string, Annotation *>; |
| 36 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 37 | struct Method { |
| 38 | Method(const char *name, |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 39 | std::vector<TypedVar *> *args, |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 40 | std::vector<TypedVar *> *results, |
Iliyan Malchev | 639bff8 | 2016-08-13 14:24:11 -0700 | [diff] [blame] | 41 | bool oneway, |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 42 | AnnotationVector *annotations); |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 43 | |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 44 | std::string name() const; |
| 45 | const std::vector<TypedVar *> &args() const; |
| 46 | const std::vector<TypedVar *> &results() const; |
Iliyan Malchev | 639bff8 | 2016-08-13 14:24:11 -0700 | [diff] [blame] | 47 | bool isOneway() const { return mOneway; } |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 48 | const AnnotationVector &annotations() const; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 49 | |
| 50 | static std::string GetSignature(const std::vector<TypedVar *> &args); |
Andreas Huber | 2831d51 | 2016-08-15 09:33:47 -0700 | [diff] [blame] | 51 | static std::string GetJavaSignature(const std::vector<TypedVar *> &args); |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 52 | |
Iliyan Malchev | 40d474a | 2016-08-16 06:20:17 -0700 | [diff] [blame] | 53 | const TypedVar* canElideCallback() const; |
| 54 | |
Andreas Huber | 3599d92 | 2016-08-09 10:42:57 -0700 | [diff] [blame] | 55 | void dumpAnnotations(Formatter &out) const; |
| 56 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 57 | bool isJavaCompatible() const; |
| 58 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 59 | private: |
| 60 | std::string mName; |
Andreas Huber | 881227d | 2016-08-02 14:20:21 -0700 | [diff] [blame] | 61 | std::vector<TypedVar *> *mArgs; |
| 62 | std::vector<TypedVar *> *mResults; |
Iliyan Malchev | 639bff8 | 2016-08-13 14:24:11 -0700 | [diff] [blame] | 63 | bool mOneway; |
Zhuoyao Zhang | 5158db4 | 2016-08-10 10:25:20 -0700 | [diff] [blame] | 64 | AnnotationVector *mAnnotationsByName; |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 65 | |
| 66 | DISALLOW_COPY_AND_ASSIGN(Method); |
| 67 | }; |
| 68 | |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 69 | struct TypedVar { |
| 70 | TypedVar(const char *name, Type *type); |
| 71 | |
| 72 | std::string name() const; |
| 73 | const Type &type() const; |
| 74 | |
Andreas Huber | 70a59e1 | 2016-08-16 12:57:01 -0700 | [diff] [blame] | 75 | bool isJavaCompatible() const; |
| 76 | |
Andreas Huber | 31629bc | 2016-08-03 09:06:40 -0700 | [diff] [blame] | 77 | private: |
| 78 | std::string mName; |
| 79 | Type *mType; |
| 80 | |
| 81 | DISALLOW_COPY_AND_ASSIGN(TypedVar); |
| 82 | }; |
| 83 | |
Andreas Huber | c9410c7 | 2016-07-28 12:18:40 -0700 | [diff] [blame] | 84 | } // namespace android |
| 85 | |
| 86 | #endif // METHOD_H_ |
| 87 | |