blob: 14bc010d5b79b1e0de0511ab44b408e581e39728 [file] [log] [blame]
Martijn Coenen99e6beb2016-12-01 15:48:42 +01001/*
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
22namespace android {
23
24PointerType::PointerType() {}
25
26bool PointerType::isPointer() const {
27 return true;
28}
29
30void PointerType::addNamedTypesToSet(std::set<const FQName> &) const {
31 // do nothing
32}
33
34std::string PointerType::getCppType(StorageMode /* mode */,
35 bool /* specifyNamespaces */) const {
36 return "void*";
37}
38
39std::string PointerType::getVtsType() const {
40 return "TYPE_POINTER";
41}
42
43void PointerType::emitReaderWriter(
44 Formatter& out,
45 const std::string& /* name */,
46 const std::string& /* parcelObj */,
47 bool /* parcelObjIsPointer */,
48 bool /* isReader */,
49 ErrorMode /* mode */) const {
50 out << "LOG_ALWAYS_FATAL(\"Pointer is only supported in passthrough mode\");\n";
51}
52
53bool PointerType::needsEmbeddedReadWrite() const {
54 return false;
55}
56
57bool PointerType::resultNeedsDeref() const {
58 return false;
59}
60
61bool PointerType::isJavaCompatible() const {
62 return false;
63}
64
65void PointerType::getAlignmentAndSize(size_t *align, size_t *size) const {
66 *align = *size = 0; // this object should only be used in passthrough mode
67}
68
69status_t PointerType::emitVtsTypeDeclarations(Formatter &out) const {
70 out << "type: " << getVtsType() << "\n";
71 return OK;
72}
73
74} // namespace android
75