blob: d1e40b5c6034b99a380efdd7ff77c5bafa5fa5e1 [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
Steven Moreland30bb6a82016-11-30 09:18:34 -080044 std::string typeName() const override;
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,
Andreas Huber4c865b72016-09-14 15:26:27 -070051 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070052
Yifan Hong4ed13472016-11-02 10:44:11 -070053 std::string getJavaType(bool forInitializer) const override;
Andreas Huber4c865b72016-09-14 15:26:27 -070054
Andreas Huber85eabdb2016-08-25 11:24:49 -070055 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070056 std::string getJavaSuffix() const override;
57
Zhuoyao Zhangc5ea9f52016-10-06 15:05:39 -070058 std::string getVtsType() const override;
59 std::string getVtsScalarType() const;
60
Andreas Huber881227d2016-08-02 14:20:21 -070061 void emitReaderWriter(
62 Formatter &out,
63 const std::string &name,
64 const std::string &parcelObj,
65 bool parcelObjIsPointer,
66 bool isReader,
67 ErrorMode mode) const override;
68
Andreas Huber737080b2016-08-02 15:38:04 -070069 void emitReaderWriterWithCast(
70 Formatter &out,
71 const std::string &name,
72 const std::string &parcelObj,
73 bool parcelObjIsPointer,
74 bool isReader,
75 ErrorMode mode,
76 bool needsCast) const;
77
Andreas Huber85eabdb2016-08-25 11:24:49 -070078 void emitJavaFieldReaderWriter(
79 Formatter &out,
Andreas Huber4c865b72016-09-14 15:26:27 -070080 size_t depth,
Andreas Huber709b62d2016-09-19 11:21:18 -070081 const std::string &parcelName,
Andreas Huber85eabdb2016-08-25 11:24:49 -070082 const std::string &blobName,
83 const std::string &fieldName,
84 const std::string &offset,
85 bool isReader) const override;
86
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070087 status_t emitVtsTypeDeclarations(Formatter &out) const override;
88
Andreas Huber85eabdb2016-08-25 11:24:49 -070089 void getAlignmentAndSize(size_t *align, size_t *size) const override;
90
Yifan Hong57886972016-08-17 10:42:15 -070091 Kind getKind() const;
92
Andreas Huberc9410c72016-07-28 12:18:40 -070093private:
94 Kind mKind;
95
96 DISALLOW_COPY_AND_ASSIGN(ScalarType);
97};
98
99} // namespace android
100
101#endif // SCALAR_TYPE_H_