Martijn Coenen | 99e6beb | 2016-12-01 15:48:42 +0100 | [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 | |
| 17 | #include "PointerType.h" |
| 18 | |
| 19 | #include <hidl-util/Formatter.h> |
| 20 | #include <android-base/logging.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | PointerType::PointerType() {} |
| 25 | |
| 26 | bool PointerType::isPointer() const { |
| 27 | return true; |
| 28 | } |
| 29 | |
Steven Moreland | 9df5244 | 2016-12-12 08:51:14 -0800 | [diff] [blame] | 30 | bool PointerType::isElidableType() const { |
| 31 | return true; |
| 32 | } |
| 33 | |
Martijn Coenen | 99e6beb | 2016-12-01 15:48:42 +0100 | [diff] [blame] | 34 | std::string PointerType::getCppType(StorageMode /* mode */, |
| 35 | bool /* specifyNamespaces */) const { |
| 36 | return "void*"; |
| 37 | } |
| 38 | |
| 39 | std::string PointerType::getVtsType() const { |
| 40 | return "TYPE_POINTER"; |
| 41 | } |
| 42 | |
| 43 | void PointerType::emitReaderWriter( |
| 44 | Formatter& out, |
Steven Moreland | a6ce1e2 | 2017-06-19 09:42:23 -0700 | [diff] [blame] | 45 | const std::string& name, |
Martijn Coenen | 99e6beb | 2016-12-01 15:48:42 +0100 | [diff] [blame] | 46 | const std::string& /* parcelObj */, |
| 47 | bool /* parcelObjIsPointer */, |
| 48 | bool /* isReader */, |
| 49 | ErrorMode /* mode */) const { |
Steven Moreland | a6ce1e2 | 2017-06-19 09:42:23 -0700 | [diff] [blame] | 50 | out << "(void)" << name << ";\n"; |
Martijn Coenen | 99e6beb | 2016-12-01 15:48:42 +0100 | [diff] [blame] | 51 | out << "LOG_ALWAYS_FATAL(\"Pointer is only supported in passthrough mode\");\n"; |
| 52 | } |
| 53 | |
| 54 | bool PointerType::needsEmbeddedReadWrite() const { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | bool PointerType::resultNeedsDeref() const { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | bool PointerType::isJavaCompatible() const { |
| 63 | return false; |
| 64 | } |
| 65 | |
Andreas Huber | 60d3b22 | 2017-03-30 09:10:56 -0700 | [diff] [blame] | 66 | bool PointerType::containsPointer() const { |
| 67 | return true; |
Martijn Coenen | 99e6beb | 2016-12-01 15:48:42 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | status_t PointerType::emitVtsTypeDeclarations(Formatter &out) const { |
| 71 | out << "type: " << getVtsType() << "\n"; |
| 72 | return OK; |
| 73 | } |
| 74 | |
| 75 | } // namespace android |
| 76 | |