blob: 7f89cc934bd845737f2ae0e2480813808fa34d6d [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
49 std::string getCppType(StorageMode mode,
50 std::string *extra,
51 bool specifyNamespaces) const override;
Andreas Huber881227d2016-08-02 14:20:21 -070052
Andreas Huber2831d512016-08-15 09:33:47 -070053 std::string getJavaType() const override;
Andreas Huber85eabdb2016-08-25 11:24:49 -070054 std::string getJavaWrapperType() const override;
Andreas Huber2831d512016-08-15 09:33:47 -070055 std::string getJavaSuffix() const override;
56
Andreas Huber881227d2016-08-02 14:20:21 -070057 void emitReaderWriter(
58 Formatter &out,
59 const std::string &name,
60 const std::string &parcelObj,
61 bool parcelObjIsPointer,
62 bool isReader,
63 ErrorMode mode) const override;
64
Andreas Huber737080b2016-08-02 15:38:04 -070065 void emitReaderWriterWithCast(
66 Formatter &out,
67 const std::string &name,
68 const std::string &parcelObj,
69 bool parcelObjIsPointer,
70 bool isReader,
71 ErrorMode mode,
72 bool needsCast) const;
73
Andreas Huber85eabdb2016-08-25 11:24:49 -070074 void emitJavaFieldReaderWriter(
75 Formatter &out,
76 const std::string &blobName,
77 const std::string &fieldName,
78 const std::string &offset,
79 bool isReader) const override;
80
Zhuoyao Zhang5158db42016-08-10 10:25:20 -070081 status_t emitVtsTypeDeclarations(Formatter &out) const override;
82
Andreas Huber85eabdb2016-08-25 11:24:49 -070083 void getAlignmentAndSize(size_t *align, size_t *size) const override;
84
Yifan Hong57886972016-08-17 10:42:15 -070085 Kind getKind() const;
86
Andreas Huberc9410c72016-07-28 12:18:40 -070087private:
88 Kind mKind;
89
90 DISALLOW_COPY_AND_ASSIGN(ScalarType);
91};
92
93} // namespace android
94
95#endif // SCALAR_TYPE_H_