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 REF_TYPE_H_ 18 19 #define REF_TYPE_H_ 20 21 #include <vector> 22 23 #include "Reference.h" 24 #include "Type.h" 25 26 namespace android { 27 28 struct RefType : public TemplatedType { 29 RefType(Scope* parent); 30 31 std::string templatedTypeName() const override; 32 33 bool isCompatibleElementType(const Type* elementType) const override; 34 35 std::vector<const Reference<Type>*> getStrongReferences() const override; 36 37 std::string getCppType(StorageMode mode, 38 bool specifyNamespaces) const override; 39 40 std::string getVtsType() const override; 41 std::string getVtsValueName() const override; 42 43 void emitReaderWriter( 44 Formatter &out, 45 const std::string &name, 46 const std::string &parcelObj, 47 bool parcelObjIsPointer, 48 bool isReader, 49 ErrorMode mode) const override; 50 51 void emitResolveReferences( 52 Formatter &out, 53 const std::string &name, 54 bool nameIsPointer, 55 const std::string &parcelObj, 56 bool parcelObjIsPointer, 57 bool isReader, 58 ErrorMode mode) const override; 59 60 void emitResolveReferencesEmbedded( 61 Formatter &out, 62 size_t depth, 63 const std::string &name, 64 const std::string &sanitizedName, 65 bool nameIsPointer, 66 const std::string &parcelObj, 67 bool parcelObjIsPointer, 68 bool isReader, 69 ErrorMode mode, 70 const std::string &parentName, 71 const std::string &offsetText) const override; 72 73 bool needsEmbeddedReadWrite() const override; 74 bool deepNeedsResolveReferences(std::unordered_set<const Type*>* visited) const override; 75 bool resultNeedsDeref() const override; 76 77 bool deepIsJavaCompatible(std::unordered_set<const Type*>* visited) const override; 78 bool deepContainsPointer(std::unordered_set<const Type*>* visited) const override; 79 80 private: 81 DISALLOW_COPY_AND_ASSIGN(RefType); 82 }; 83 84 } // namespace android 85 86 #endif // REF_TYPE_H_ 87 88