blob: 06892bf16fe7cefbf8f2cda787255cdbdb2f15ab [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
Andreas Huber881227d2016-08-02 14:20:21 -070047 std::string getCppType(StorageMode mode, std::string *extra) const override;
48
Andreas Huber2831d512016-08-15 09:33:47 -070049 std::string getJavaType() const override;
Andreas Huber85eabdb2016-08-25 11:24:49 -070050 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070051 std::string getJavaSuffix() const override;
52
Andreas Huber881227d2016-08-02 14:20:21 -070053 void emitReaderWriter(
54 Formatter &out,
55 const std::string &name,
56 const std::string &parcelObj,
57 bool parcelObjIsPointer,
58 bool isReader,
59 ErrorMode mode) const override;
60
Andreas Huber737080b2016-08-02 15:38:04 -070061 void emitReaderWriterWithCast(
62 Formatter &out,
63 const std::string &name,
64 const std::string &parcelObj,
65 bool parcelObjIsPointer,
66 bool isReader,
67 ErrorMode mode,
68 bool needsCast) const;
69
Andreas Huber85eabdb2016-08-25 11:24:49 -070070 void emitJavaFieldReaderWriter(
71 Formatter &out,
72 const std::string &blobName,
73 const std::string &fieldName,
74 const std::string &offset,
75 bool isReader) const override;
76
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070077 status_t emitVtsTypeDeclarations(Formatter &out) const override;
78
Andreas Huber85eabdb2016-08-25 11:24:49 -070079 void getAlignmentAndSize(size_t *align, size_t *size) const override;
80
Yifan Hong57886972016-08-17 10:42:15 -070081 Kind getKind() const;
82
Andreas Huberc9410c72016-07-28 12:18:40 -070083private:
84 Kind mKind;
85
86 DISALLOW_COPY_AND_ASSIGN(ScalarType);
87};
88
89} // namespace android
90
91#endif // SCALAR_TYPE_H_