ScalarType.h revision f5cc2f74e86504f7904a0a24e7fcc00fa19cd579
11aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber/* 21aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Copyright (C) 2016 The Android Open Source Project 31aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 41aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License"); 51aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * you may not use this file except in compliance with the License. 61aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * You may obtain a copy of the License at 71aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 81aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * http://www.apache.org/licenses/LICENSE-2.0 91aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * 101aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * Unless required by applicable law or agreed to in writing, software 111aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS, 121aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * See the License for the specific language governing permissions and 141aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber * limitations under the License. 151aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber */ 161aec397b1fdea7db4120dbe55b6995bb2a9d9138Andreas Huber 17c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#ifndef SCALAR_TYPE_H_ 18c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 19c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#define SCALAR_TYPE_H_ 20c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 21c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#include "Type.h" 22c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 23c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Hubernamespace android { 24c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 25c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberstruct ScalarType : public Type { 26c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber enum Kind { 27c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_BOOL, 28c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_INT8, 29c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_UINT8, 30c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_INT16, 31c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_UINT16, 32c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_INT32, 33c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_UINT32, 34c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_INT64, 35c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_UINT64, 36c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_FLOAT, 37c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber KIND_DOUBLE, 38c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber }; 39c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 40c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber ScalarType(Kind kind); 41c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 42abf73eef7f23f0b0ba0fe85694dcd511f4e69962Yifan Hong bool isScalar() const override; 43abf73eef7f23f0b0ba0fe85694dcd511f4e69962Yifan Hong 449df5244c1dd4508cc2e25f8a04d363903912d19cSteven Moreland bool isElidableType() const override; 45737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber const ScalarType *resolveToScalarType() const override; 46737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber 47c6752dcea3b5dae1e99960b5beb6af394280b393Yifan Hong bool canCheckEquality() const override; 48c6752dcea3b5dae1e99960b5beb6af394280b393Yifan Hong 4930bb6a869be0f3f82497b7b11c71ec9d47652ed0Steven Moreland std::string typeName() const override; 508d3ac0c6112e02e3a705fd4f9d82e523f10b4287Andreas Huber bool isValidEnumStorageType() const; 518d3ac0c6112e02e3a705fd4f9d82e523f10b4287Andreas Huber 52979e099f1163ff75beed5776cd01fb409b90a0cdSteven Moreland void addNamedTypesToSet(std::set<const FQName> &set) const override; 53979e099f1163ff75beed5776cd01fb409b90a0cdSteven Moreland 544c865b72b320a46f326a335cfd326b66b0e10f67Andreas Huber std::string getCppType( 554c865b72b320a46f326a335cfd326b66b0e10f67Andreas Huber StorageMode mode, 564c865b72b320a46f326a335cfd326b66b0e10f67Andreas Huber bool specifyNamespaces) const override; 574c865b72b320a46f326a335cfd326b66b0e10f67Andreas Huber 584ed1347cd29e6e07acad368891bb03078c798abaYifan Hong std::string getJavaType(bool forInitializer) const override; 59881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 6085eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber std::string getJavaWrapperType() const override; 612831d5145675ead9f2fb767bf5fe4ae56b88349fAndreas Huber std::string getJavaSuffix() const override; 622831d5145675ead9f2fb767bf5fe4ae56b88349fAndreas Huber 63c5ea9f589cc7cce0b5e97bd4ac6a8561eb313a02Zhuoyao Zhang std::string getVtsType() const override; 64c5ea9f589cc7cce0b5e97bd4ac6a8561eb313a02Zhuoyao Zhang std::string getVtsScalarType() const; 65c5ea9f589cc7cce0b5e97bd4ac6a8561eb313a02Zhuoyao Zhang 66881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber void emitReaderWriter( 67881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber Formatter &out, 68881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber const std::string &name, 69881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber const std::string &parcelObj, 70881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber bool parcelObjIsPointer, 71881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber bool isReader, 72881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber ErrorMode mode) const override; 73881227d860c59471eee31d39946e96ce2daa35d6Andreas Huber 74737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber void emitReaderWriterWithCast( 75737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber Formatter &out, 76737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber const std::string &name, 77737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber const std::string &parcelObj, 78737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber bool parcelObjIsPointer, 79737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber bool isReader, 80737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber ErrorMode mode, 81737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber bool needsCast) const; 82737080baf85882c45bb322ee2191ae5fd9e1283aAndreas Huber 83f5cc2f74e86504f7904a0a24e7fcc00fa19cd579Yifan Hong void emitHexDump( 84f5cc2f74e86504f7904a0a24e7fcc00fa19cd579Yifan Hong Formatter &out, 85f5cc2f74e86504f7904a0a24e7fcc00fa19cd579Yifan Hong const std::string &streamName, 86f5cc2f74e86504f7904a0a24e7fcc00fa19cd579Yifan Hong const std::string &name) const; 87f5cc2f74e86504f7904a0a24e7fcc00fa19cd579Yifan Hong 8885eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber void emitJavaFieldReaderWriter( 8985eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber Formatter &out, 904c865b72b320a46f326a335cfd326b66b0e10f67Andreas Huber size_t depth, 91709b62dbda6184770bb34470ff550e02c1643e67Andreas Huber const std::string &parcelName, 9285eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber const std::string &blobName, 9385eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber const std::string &fieldName, 9485eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber const std::string &offset, 9585eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber bool isReader) const override; 9685eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber 975158db484e5ab302368f191d75d5b1334c270e52Zhuoyao Zhang status_t emitVtsTypeDeclarations(Formatter &out) const override; 985158db484e5ab302368f191d75d5b1334c270e52Zhuoyao Zhang 9985eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber void getAlignmentAndSize(size_t *align, size_t *size) const override; 10085eabdbe56720dcdcf130e5ca83129d47b143768Andreas Huber 1015788697381666844eeb23e04e5c6f83ec6ec8b44Yifan Hong Kind getKind() const; 1025788697381666844eeb23e04e5c6f83ec6ec8b44Yifan Hong 103c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huberprivate: 104c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber Kind mKind; 105c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 106c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber DISALLOW_COPY_AND_ASSIGN(ScalarType); 107c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber}; 108c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 109c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber} // namespace android 110c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber 111c9410c7e62a33fd7599b2f3e025093a2d171577eAndreas Huber#endif // SCALAR_TYPE_H_ 112