blob: 9554e347b9a9678caa13c25236ed5001cb03327b [file] [log] [blame]
Andreas Huber1aec3972016-08-26 09:26:32 -07001/*
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 Huberc9410c72016-07-28 12:18:40 -070017#ifndef SCALAR_TYPE_H_
18
19#define SCALAR_TYPE_H_
20
21#include "Type.h"
22
23namespace android {
24
25struct ScalarType : public Type {
26 enum Kind {
Andreas Huberc9410c72016-07-28 12:18:40 -070027 KIND_BOOL,
28 KIND_OPAQUE,
29 KIND_INT8,
30 KIND_UINT8,
31 KIND_INT16,
32 KIND_UINT16,
33 KIND_INT32,
34 KIND_UINT32,
35 KIND_INT64,
36 KIND_UINT64,
37 KIND_FLOAT,
38 KIND_DOUBLE,
39 };
40
41 ScalarType(Kind kind);
42
Andreas Huber737080b2016-08-02 15:38:04 -070043 const ScalarType *resolveToScalarType() const override;
44
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070045 bool isValidEnumStorageType() const;
46
Steven Moreland979e0992016-09-07 09:18:08 -070047 void addNamedTypesToSet(std::set<const FQName> &set) const override;
48
Andreas Huber4c865b72016-09-14 15:26:27 -070049 std::string getCppType(
50 StorageMode mode,
51 std::string *extra,
52 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070053
Andreas Huber4c865b72016-09-14 15:26:27 -070054 std::string getJavaType(
55 std::string *extra, bool forInitializer) const override;
56
Andreas Huber85eabdb2016-08-25 11:24:49 -070057 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070058 std::string getJavaSuffix() const override;
59
Andreas Huber881227d2016-08-02 14:20:21 -070060 void emitReaderWriter(
61 Formatter &out,
62 const std::string &name,
63 const std::string &parcelObj,
64 bool parcelObjIsPointer,
65 bool isReader,
66 ErrorMode mode) const override;
67
Andreas Huber737080b2016-08-02 15:38:04 -070068 void emitReaderWriterWithCast(
69 Formatter &out,
70 const std::string &name,
71 const std::string &parcelObj,
72 bool parcelObjIsPointer,
73 bool isReader,
74 ErrorMode mode,
75 bool needsCast) const;
76
Andreas Huber85eabdb2016-08-25 11:24:49 -070077 void emitJavaFieldReaderWriter(
78 Formatter &out,
Andreas Huber4c865b72016-09-14 15:26:27 -070079 size_t depth,
Andreas Huber85eabdb2016-08-25 11:24:49 -070080 const std::string &blobName,
81 const std::string &fieldName,
82 const std::string &offset,
83 bool isReader) const override;
84
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070085 status_t emitVtsTypeDeclarations(Formatter &out) const override;
86
Andreas Huber85eabdb2016-08-25 11:24:49 -070087 void getAlignmentAndSize(size_t *align, size_t *size) const override;
88
Yifan Hong57886972016-08-17 10:42:15 -070089 Kind getKind() const;
90
Andreas Huberc9410c72016-07-28 12:18:40 -070091private:
92 Kind mKind;
93
94 DISALLOW_COPY_AND_ASSIGN(ScalarType);
95};
96
97} // namespace android
98
99#endif // SCALAR_TYPE_H_