Add toString to Java code

* toString is mainly for debugging purposes.
* For structs and interfaces, add Object.toString.
* For enums, add MyEnum.toString(int) and MyEnum.dumpBitfield(int).

Use them as follows:
* For enums, use the static method E.toString(int).
* For bitfields, use the static method E.dumpBitfield(int).
* For all arrays, use java.utils.Arrays.deepToString(o)
* For everything else, use one of the following:
    * o.toString(), if o is not null
    * Object.toString(o)
    * String.valueOf(o)
* Note that for array / vec of enums / bitfields, the raw integer
  value is dumped.

Bug: 33459772
Test: hidl_test_java

Change-Id: Ifb1ed519770b907e0a4e345b2c3109dc322a23b2
diff --git a/EnumType.h b/EnumType.h
index e259297..b853054 100644
--- a/EnumType.h
+++ b/EnumType.h
@@ -26,6 +26,7 @@
 namespace android {
 
 struct EnumValue;
+struct BitFieldType;
 
 struct EnumType : public Scope {
     EnumType(const char *localName,
@@ -56,6 +57,9 @@
 
     std::string getVtsType() const override;
 
+    // Return the type that corresponds to bitfield<T>.
+    BitFieldType *getBitfieldType() const;
+
     void emitReaderWriter(
             Formatter &out,
             const std::string &name,
@@ -83,6 +87,11 @@
     status_t emitVtsTypeDeclarations(Formatter &out) const override;
     status_t emitVtsAttributeType(Formatter &out) const override;
 
+    void emitJavaDump(
+            Formatter &out,
+            const std::string &streamName,
+            const std::string &name) const override;
+
     void getAlignmentAndSize(size_t *align, size_t *size) const override;
 
     void appendToExportedTypesVector(
@@ -106,6 +115,7 @@
 
     std::vector<EnumValue *> mValues;
     Type *mStorageType;
+    BitFieldType *mBitfieldType;
 
     DISALLOW_COPY_AND_ASSIGN(EnumType);
 };
@@ -159,6 +169,8 @@
 
     std::string getVtsType() const override;
 
+    EnumType *getEnumType() const;
+
     status_t emitVtsAttributeType(Formatter &out) const override;
 
     void getAlignmentAndSize(size_t *align, size_t *size) const override;
@@ -176,6 +188,11 @@
             const std::string &streamName,
             const std::string &name) const override;
 
+    void emitJavaDump(
+            Formatter &out,
+            const std::string &streamName,
+            const std::string &name) const override;
+
     void emitJavaFieldReaderWriter(
         Formatter &out,
         size_t depth,