ArrayType.h revision 4c865b72b320a46f326a335cfd326b66b0e10f67
1/* 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 17#ifndef ARRAY_TYPE_H_ 18 19#define ARRAY_TYPE_H_ 20 21#include "Type.h" 22 23#include <string> 24 25namespace android { 26 27struct ArrayType : public Type { 28 ArrayType(Type *elementType, const char *dimension); 29 30 std::string getCppType(StorageMode mode, 31 std::string *extra, 32 bool specifyNamespaces) const override; 33 34 void addNamedTypesToSet(std::set<const FQName> &set) const override; 35 36 std::string getJavaType( 37 std::string *extra, bool forInitializer) const override; 38 39 void emitReaderWriter( 40 Formatter &out, 41 const std::string &name, 42 const std::string &parcelObj, 43 bool parcelObjIsPointer, 44 bool isReader, 45 ErrorMode mode) const override; 46 47 void emitReaderWriterEmbedded( 48 Formatter &out, 49 size_t depth, 50 const std::string &name, 51 bool nameIsPointer, 52 const std::string &parcelObj, 53 bool parcelObjIsPointer, 54 bool isReader, 55 ErrorMode mode, 56 const std::string &parentName, 57 const std::string &offsetText) const override; 58 59 bool needsEmbeddedReadWrite() const override; 60 61 void emitJavaReaderWriter( 62 Formatter &out, 63 const std::string &parcelObj, 64 const std::string &argName, 65 bool isReader) const override; 66 67 void emitJavaFieldInitializer( 68 Formatter &out, const std::string &fieldName) const override; 69 70 void emitJavaFieldReaderWriter( 71 Formatter &out, 72 size_t depth, 73 const std::string &blobName, 74 const std::string &fieldName, 75 const std::string &offset, 76 bool isReader) const override; 77 78 status_t emitVtsTypeDeclarations(Formatter &out) const override; 79 80 bool isJavaCompatible() const override; 81 82 void getAlignmentAndSize(size_t *align, size_t *size) const override; 83 84private: 85 Type *mElementType; 86 std::string mDimension; 87 88 DISALLOW_COPY_AND_ASSIGN(ArrayType); 89}; 90 91} // namespace android 92 93#endif // ARRAY_TYPE_H_ 94 95