blob: 80bc9a0b52f3c2500a06d8edea64beeeab143fdb [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
Yifan Hongabf73ee2016-12-05 18:47:00 -080042 bool isScalar() const override;
43
Steven Moreland9df52442016-12-12 08:51:14 -080044 bool isElidableType() const override;
Andreas Huber737080b2016-08-02 15:38:04 -070045 const ScalarType *resolveToScalarType() const override;
46
Steven Moreland30bb6a82016-11-30 09:18:34 -080047 std::string typeName() const override;
Andreas Huber8d3ac0c2016-08-04 14:49:23 -070048 bool isValidEnumStorageType() const;
49
Steven Moreland979e0992016-09-07 09:18:08 -070050 void addNamedTypesToSet(std::set<const FQName> &set) const override;
51
Andreas Huber4c865b72016-09-14 15:26:27 -070052 std::string getCppType(
53 StorageMode mode,
Andreas Huber4c865b72016-09-14 15:26:27 -070054 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070055
Yifan Hong4ed13472016-11-02 10:44:11 -070056 std::string getJavaType(bool forInitializer) const override;
Andreas Huber4c865b72016-09-14 15:26:27 -070057
Andreas Huber85eabdb2016-08-25 11:24:49 -070058 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070059 std::string getJavaSuffix() const override;
60
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -070061 std::string getVtsType() const override;
62 std::string getVtsScalarType() const;
63
Andreas Huber881227d2016-08-02 14:20:21 -070064 void emitReaderWriter(
65 Formatter &out,
66 const std::string &name,
67 const std::string &parcelObj,
68 bool parcelObjIsPointer,
69 bool isReader,
70 ErrorMode mode) const override;
71
Andreas Huber737080b2016-08-02 15:38:04 -070072 void emitReaderWriterWithCast(
73 Formatter &out,
74 const std::string &name,
75 const std::string &parcelObj,
76 bool parcelObjIsPointer,
77 bool isReader,
78 ErrorMode mode,
79 bool needsCast) const;
80
Andreas Huber85eabdb2016-08-25 11:24:49 -070081 void emitJavaFieldReaderWriter(
82 Formatter &out,
Andreas Huber4c865b72016-09-14 15:26:27 -070083 size_t depth,
Andreas Huber709b62d2016-09-19 11:21:18 -070084 const std::string &parcelName,
Andreas Huber85eabdb2016-08-25 11:24:49 -070085 const std::string &blobName,
86 const std::string &fieldName,
87 const std::string &offset,
88 bool isReader) const override;
89
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070090 status_t emitVtsTypeDeclarations(Formatter &out) const override;
91
Andreas Huber85eabdb2016-08-25 11:24:49 -070092 void getAlignmentAndSize(size_t *align, size_t *size) const override;
93
Yifan Hong57886972016-08-17 10:42:15 -070094 Kind getKind() const;
95
Andreas Huberc9410c72016-07-28 12:18:40 -070096private:
97 Kind mKind;
98
99 DISALLOW_COPY_AND_ASSIGN(ScalarType);
100};
101
102} // namespace android
103
104#endif // SCALAR_TYPE_H_