[fidlcat] Compute fidl_codec::Type for char and zx_uint128_t

Adds kChar to fidl_codec.

Computes fidl_codec::StructType for kUint128Hexa.

Change-Id: I7cf2bedab86c0e0c2d378cdc94700bb2cdeda497
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/405133
Reviewed-by: Vincent Belliard <vbelliard@google.com>
Testability-Review: Vincent Belliard <vbelliard@google.com>
Commit-Queue: Nima Joharizadeh <nimaj@google.com>
diff --git a/src/lib/fidl_codec/wire_types.cc b/src/lib/fidl_codec/wire_types.cc
index 84d7efd..77ff3e5 100644
--- a/src/lib/fidl_codec/wire_types.cc
+++ b/src/lib/fidl_codec/wire_types.cc
@@ -193,7 +193,14 @@
 
 void BoolType::Visit(TypeVisitor* visitor) const { visitor->VisitBoolType(this); };
 
-std::string Int8Type::Name() const { return "int8"; }
+std::string Int8Type::Name() const {
+  switch (kind_) {
+    case Kind::kDecimal:
+      return "int8";
+    case Kind::kChar:
+      return "char";
+  }
+}
 
 void Int8Type::PrettyPrint(const Value* value, PrettyPrinter& printer) const {
   uint64_t absolute;
@@ -202,6 +209,7 @@
     printer << Red << "invalid" << ResetColor;
   } else {
     switch (kind_) {
+      case Kind::kChar:
       case Kind::kDecimal:
         printer << Blue;
         if (negative) {
diff --git a/src/lib/fidl_codec/wire_types.h b/src/lib/fidl_codec/wire_types.h
index c8a5f4d..393659c 100644
--- a/src/lib/fidl_codec/wire_types.h
+++ b/src/lib/fidl_codec/wire_types.h
@@ -156,7 +156,7 @@
 
 class Int8Type : public IntegralType<int8_t> {
  public:
-  enum class Kind { kDecimal };
+  enum class Kind { kChar, kDecimal };
 
   explicit Int8Type(Kind kind = Kind::kDecimal) : kind_(kind) {}
 
diff --git a/tools/fidlcat/lib/syscall_decoder_dispatcher.cc b/tools/fidlcat/lib/syscall_decoder_dispatcher.cc
index 6120792..8845e53 100644
--- a/tools/fidlcat/lib/syscall_decoder_dispatcher.cc
+++ b/tools/fidlcat/lib/syscall_decoder_dispatcher.cc
@@ -21,6 +21,8 @@
 
 namespace fidlcat {
 
+std::unique_ptr<fidl_codec::Struct> uint128_struct_definition = nullptr;
+
 std::unique_ptr<fidl_codec::Type> SyscallTypeToFidlCodecType(fidlcat::SyscallType syscall_type) {
   switch (syscall_type) {
     case SyscallType::kBool:
@@ -29,6 +31,8 @@
       return std::make_unique<fidl_codec::Uint32Type>(fidl_codec::Uint32Type::Kind::kBtiPerm);
     case SyscallType::kCachePolicy:
       return std::make_unique<fidl_codec::Uint32Type>(fidl_codec::Uint32Type::Kind::kCachePolicy);
+    case SyscallType::kChar:
+      return std::make_unique<fidl_codec::Int8Type>(fidl_codec::Int8Type::Kind::kChar);
     case SyscallType::kClock:
       return std::make_unique<fidl_codec::Uint32Type>(fidl_codec::Uint32Type::Kind::kClock);
     case SyscallType::kDuration:
@@ -91,6 +95,15 @@
       return std::make_unique<fidl_codec::Uint64Type>();
     case SyscallType::kUint64Hexa:
       return std::make_unique<fidl_codec::Uint64Type>(fidl_codec::Uint64Type::Kind::kHexaDecimal);
+    case SyscallType::kUint128Hexa:
+      if (uint128_struct_definition == nullptr) {
+        uint128_struct_definition = std::make_unique<fidl_codec::Struct>("zx.uint128");
+        uint128_struct_definition->AddMember("low",
+                                             SyscallTypeToFidlCodecType(SyscallType::kUint64Hexa));
+        uint128_struct_definition->AddMember("high",
+                                             SyscallTypeToFidlCodecType(SyscallType::kUint64Hexa));
+      }
+      return std::make_unique<fidl_codec::StructType>(*uint128_struct_definition, false);
     case SyscallType::kUintptr:
       return std::make_unique<fidl_codec::Uint64Type>(fidl_codec::Uint64Type::Kind::kUintptr);
     case SyscallType::kVaddr: