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
PointerType()24 PointerType::PointerType() {}
25
isPointer() const26 bool PointerType::isPointer() const {
27 return true;
28 }
29
isElidableType() const30 bool PointerType::isElidableType() const {
31 return true;
32 }
33
addNamedTypesToSet(std::set<const FQName> &) const34 void PointerType::addNamedTypesToSet(std::set<const FQName> &) const {
35 // do nothing
36 }
37
getCppType(StorageMode,bool) const38 std::string PointerType::getCppType(StorageMode /* mode */,
39 bool /* specifyNamespaces */) const {
40 return "void*";
41 }
42
getVtsType() const43 std::string PointerType::getVtsType() const {
44 return "TYPE_POINTER";
45 }
46
emitReaderWriter(Formatter & out,const std::string &,const std::string &,bool,bool,ErrorMode) const47 void PointerType::emitReaderWriter(
48 Formatter& out,
49 const std::string& /* name */,
50 const std::string& /* parcelObj */,
51 bool /* parcelObjIsPointer */,
52 bool /* isReader */,
53 ErrorMode /* mode */) const {
54 out << "LOG_ALWAYS_FATAL(\"Pointer is only supported in passthrough mode\");\n";
55 }
56
needsEmbeddedReadWrite() const57 bool PointerType::needsEmbeddedReadWrite() const {
58 return false;
59 }
60
resultNeedsDeref() const61 bool PointerType::resultNeedsDeref() const {
62 return false;
63 }
64
isJavaCompatible() const65 bool PointerType::isJavaCompatible() const {
66 return false;
67 }
68
containsPointer() const69 bool PointerType::containsPointer() const {
70 return true;
71 }
72
emitVtsTypeDeclarations(Formatter & out) const73 status_t PointerType::emitVtsTypeDeclarations(Formatter &out) const {
74 out << "type: " << getVtsType() << "\n";
75 return OK;
76 }
77
78 } // namespace android
79
80