Pointer support and embedded types in HIDL.

* Pointers work per transaction. Don't work
  across transactions.
* ref<T> in HIDL translates to T const* in C++.
* No Java support.
* Embedded types like ref<vec<vec<int32_t>>>
  or vec<ref<T>> is supported. Pointers to
  pointers like ref<ref<ref<T>>> is supported.
* Array of pointers and pointer to array supported.
* Pointer inside a union is NOT supported.

Test: `mma`
Test: `make hidl_test && adb sync && adb shell hidl_test`
      Note that this only works with a kernel patch.

Bug: 31300815
Bug: 31349114

Change-Id: I15b74ca74a801009cc8bdc7132bd53d0185dbcbf
diff --git a/Type.h b/Type.h
index 5a82718..ce0d78f 100644
--- a/Type.h
+++ b/Type.h
@@ -118,6 +118,28 @@
             const std::string &parentName,
             const std::string &offsetText) const;
 
+    virtual void emitResolveReferences(
+            Formatter &out,
+            const std::string &name,
+            bool nameIsPointer,
+            const std::string &parcelObj,
+            bool parcelObjIsPointer,
+            bool isReader,
+            ErrorMode mode) const;
+
+    virtual void emitResolveReferencesEmbedded(
+            Formatter &out,
+            size_t depth,
+            const std::string &name,
+            const std::string &sanitizedName,
+            bool nameIsPointer,
+            const std::string &parcelObj,
+            bool parcelObjIsPointer,
+            bool isReader,
+            ErrorMode mode,
+            const std::string &parentName,
+            const std::string &offsetText) const;
+
     virtual void emitJavaReaderWriter(
             Formatter &out,
             const std::string &parcelObj,
@@ -146,6 +168,7 @@
             Formatter &out, bool atTopLevel) const;
 
     virtual bool needsEmbeddedReadWrite() const;
+    virtual bool needsResolveReferences() const;
     virtual bool resultNeedsDeref() const;
 
     // Generates type declaration for vts proto file.
@@ -194,6 +217,16 @@
     DISALLOW_COPY_AND_ASSIGN(Type);
 };
 
+/* Base type for VectorType and RefType. */
+struct TemplatedType : public Type {
+    void setElementType(Type *elementType);
+protected:
+    TemplatedType();
+    Type *mElementType;
+private:
+    DISALLOW_COPY_AND_ASSIGN(TemplatedType);
+};
+
 }  // namespace android
 
 #endif  // TYPE_H_