Update hidl-gen support for vts.

* Support the new Enum type (based on scalar_data)
* Support sub_struct/sub_union defined within compound type.
* Code cleanup: use getVtsType() instead of hard code ones.

Test: make hidl-gen, locally run make hidl_gen_test.
Bug: 30762234
Change-Id: I9a21b5757e0a9fc6cd1bf829ab123565a7990ad5
diff --git a/ScalarType.cpp b/ScalarType.cpp
index 9065e13..b89001f 100644
--- a/ScalarType.cpp
+++ b/ScalarType.cpp
@@ -113,6 +113,28 @@
     return kSuffix[mKind];
 }
 
+std::string ScalarType::getVtsType() const {
+    return "TYPE_SCALAR";
+}
+
+std::string ScalarType::getVtsScalarType() const {
+    static const char * const kName[] = {
+            "bool_t",
+            "int8_t",
+            "uint8_t",
+            "int16_t",
+            "uint16_t",
+            "int32_t",
+            "uint32_t",
+            "int64_t",
+            "uint64_t",
+            "float_t",
+            "double_t"
+    };
+
+    return kName[mKind];
+}
+
 void ScalarType::emitReaderWriter(
         Formatter &out,
         const std::string &name,
@@ -211,20 +233,8 @@
 }
 
 status_t ScalarType::emitVtsTypeDeclarations(Formatter &out) const {
-    static const char *const kName[] = {
-            "bool_t",
-            "int8_t",
-            "uint8_t",
-            "int16_t",
-            "uint16_t",
-            "int32_t",
-            "uint32_t",
-            "int64_t",
-            "uint64_t",
-            "float_t",
-            "double_t"
-    };
-    out << "type: TYPE_SCALAR\n"<< "scalar_type: \""<< kName[mKind]<< "\"\n";
+    out << "type: " << getVtsType() << "\n";
+    out << "scalar_type: \"" << getVtsScalarType() << "\"\n";
     return OK;
 }