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 VECTOR_TYPE_H_ 18 19 #define VECTOR_TYPE_H_ 20 21 #include <vector> 22 23 #include "Reference.h" 24 #include "Type.h" 25 26 namespace android { 27 28 struct VectorType : public TemplatedType { 29 VectorType(Scope* parent); 30 31 bool isVector() const override; 32 bool isVectorOfBinders() const; 33 34 std::string templatedTypeName() const override; 35 bool isCompatibleElementType(const Type* elementType) const override; 36 37 std::vector<const Reference<Type>*> getStrongReferences() const override; 38 39 bool deepCanCheckEquality(std::unordered_set<const Type*>* visited) const override; 40 41 std::string getCppType( 42 StorageMode mode, 43 bool specifyNamespaces) const override; 44 45 std::string getJavaType(bool forInitializer) const override; 46 std::string getJavaTypeClass() const override; 47 48 std::string getVtsType() const override; 49 std::string getVtsValueName() const override; 50 51 void emitReaderWriter( 52 Formatter &out, 53 const std::string &name, 54 const std::string &parcelObj, 55 bool parcelObjIsPointer, 56 bool isReader, 57 ErrorMode mode) const override; 58 59 void emitReaderWriterEmbedded( 60 Formatter &out, 61 size_t depth, 62 const std::string &name, 63 const std::string &sanitizedName, 64 bool nameIsPointer, 65 const std::string &parcelObj, 66 bool parcelObjIsPointer, 67 bool isReader, 68 ErrorMode mode, 69 const std::string &parentName, 70 const std::string &offsetText) const override; 71 72 void emitJavaReaderWriter( 73 Formatter &out, 74 const std::string &parcelObj, 75 const std::string &argName, 76 bool isReader) const override; 77 78 void emitJavaFieldInitializer( 79 Formatter &out, const std::string &fieldName) const override; 80 81 void emitJavaFieldDefaultInitialValue( 82 Formatter &out, const std::string &declaredFieldName) const override; 83 84 void emitJavaFieldReaderWriter( 85 Formatter &out, 86 size_t depth, 87 const std::string &parcelName, 88 const std::string &blobName, 89 const std::string &fieldName, 90 const std::string &offset, 91 bool isReader) const override; 92 93 static void EmitJavaFieldReaderWriterForElementType( 94 Formatter &out, 95 size_t depth, 96 const Type *elementType, 97 const std::string &parcelName, 98 const std::string &blobName, 99 const std::string &fieldName, 100 const std::string &offset, 101 bool isReader); 102 103 bool needsEmbeddedReadWrite() const override; 104 bool resultNeedsDeref() const override; 105 106 bool deepIsJavaCompatible(std::unordered_set<const Type*>* visited) const override; 107 bool deepContainsPointer(std::unordered_set<const Type*>* visited) const override; 108 109 void getAlignmentAndSize(size_t *align, size_t *size) const override; 110 static void getAlignmentAndSizeStatic(size_t *align, size_t *size); 111 private: 112 113 void emitReaderWriterForVectorOfBinders( 114 Formatter &out, 115 const std::string &name, 116 const std::string &parcelObj, 117 bool parcelObjIsPointer, 118 bool isReader, 119 ErrorMode mode) const; 120 121 DISALLOW_COPY_AND_ASSIGN(VectorType); 122 }; 123 124 } // namespace android 125 126 #endif // VECTOR_TYPE_H_ 127 128