blob: 135f6fb29559305c2cbd9a832598bf519100e8fd [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,
Andreas Huberc9410c72016-07-28 12:18:40 -070028 KIND_INT8,
29 KIND_UINT8,
30 KIND_INT16,
31 KIND_UINT16,
32 KIND_INT32,
33 KIND_UINT32,
34 KIND_INT64,
35 KIND_UINT64,
36 KIND_FLOAT,
37 KIND_DOUBLE,
38 };
39
40 ScalarType(Kind kind);
41
Andreas Huber737080b2016-08-02 15:38:04 -070042 const ScalarType *resolveToScalarType() const override;
43
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070044 bool isValidEnumStorageType() const;
45
Steven Moreland979e0992016-09-07 09:18:08 -070046 void addNamedTypesToSet(std::set<const FQName> &set) const override;
47
Andreas Huber4c865b72016-09-14 15:26:27 -070048 std::string getCppType(
49 StorageMode mode,
50 std::string *extra,
51 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070052
Andreas Huber4c865b72016-09-14 15:26:27 -070053 std::string getJavaType(
54 std::string *extra, bool forInitializer) const override;
55
Andreas Huber85eabdb2016-08-25 11:24:49 -070056 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070057 std::string getJavaSuffix() const override;
58
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -070059 std::string getVtsType() const override;
60 std::string getVtsScalarType() const;
61
Andreas Huber881227d2016-08-02 14:20:21 -070062 void emitReaderWriter(
63 Formatter &out,
64 const std::string &name,
65 const std::string &parcelObj,
66 bool parcelObjIsPointer,
67 bool isReader,
68 ErrorMode mode) const override;
69
Andreas Huber737080b2016-08-02 15:38:04 -070070 void emitReaderWriterWithCast(
71 Formatter &out,
72 const std::string &name,
73 const std::string &parcelObj,
74 bool parcelObjIsPointer,
75 bool isReader,
76 ErrorMode mode,
77 bool needsCast) const;
78
Andreas Huber85eabdb2016-08-25 11:24:49 -070079 void emitJavaFieldReaderWriter(
80 Formatter &out,
Andreas Huber4c865b72016-09-14 15:26:27 -070081 size_t depth,
Andreas Huber709b62d2016-09-19 11:21:18 -070082 const std::string &parcelName,
Andreas Huber85eabdb2016-08-25 11:24:49 -070083 const std::string &blobName,
84 const std::string &fieldName,
85 const std::string &offset,
86 bool isReader) const override;
87
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070088 status_t emitVtsTypeDeclarations(Formatter &out) const override;
89
Andreas Huber85eabdb2016-08-25 11:24:49 -070090 void getAlignmentAndSize(size_t *align, size_t *size) const override;
91
Yifan Hong57886972016-08-17 10:42:15 -070092 Kind getKind() const;
93
Andreas Huberc9410c72016-07-28 12:18:40 -070094private:
95 Kind mKind;
96
97 DISALLOW_COPY_AND_ASSIGN(ScalarType);
98};
99
100} // namespace android
101
102#endif // SCALAR_TYPE_H_