Add a bitfield type.

It is possible to say
enum MyEnum : int8_t {...};
...
bitfield<MyEnum>
in HIDL. In the above example, bitfield<MyEnum>
simply translates to int8_t.

Change mutating |= and &= to allow only (e.g.)
int8_t s = 0;
s |= MyEnum::VAL1;

Bug: 31702236
Test: hidl_test
Change-Id: I8d79975bb48e1ffd3af4726a52ef3678dac60115
diff --git a/EnumType.h b/EnumType.h
index 09ad24d..6842fc1 100644
--- a/EnumType.h
+++ b/EnumType.h
@@ -93,7 +93,12 @@
 
     void emitEnumBitwiseOperator(
             Formatter &out,
-            bool mutating,
+            bool lhsIsEnum,
+            bool rhsIsEnum,
+            const std::string &op) const;
+
+    void emitBitFieldBitwiseAssignmentOperator(
+            Formatter &out,
             const std::string &op) const;
 
     std::vector<EnumValue *> mValues;
@@ -124,6 +129,51 @@
     DISALLOW_COPY_AND_ASSIGN(EnumValue);
 };
 
+struct BitFieldType : public TemplatedType {
+
+    std::string typeName() const override;
+
+    void addNamedTypesToSet(std::set<const FQName> &set) const override;
+
+    bool isCompatibleElementType(Type *elementType) const override;
+
+    const ScalarType *resolveToScalarType() const override;
+
+    std::string getCppType(StorageMode mode,
+                           bool specifyNamespaces) const override;
+
+    std::string getJavaType(bool forInitializer) const override;
+
+    std::string getJavaSuffix() const override;
+
+    std::string getJavaWrapperType() const override;
+
+    std::string getVtsType() const override;
+
+    status_t emitVtsTypeDeclarations(Formatter &out) const override;
+
+    status_t emitVtsAttributeType(Formatter &out) const override;
+
+    void getAlignmentAndSize(size_t *align, size_t *size) const override;
+
+    void emitReaderWriter(
+        Formatter &out,
+        const std::string &name,
+        const std::string &parcelObj,
+        bool parcelObjIsPointer,
+        bool isReader,
+        ErrorMode mode) const override;
+
+    void emitJavaFieldReaderWriter(
+        Formatter &out,
+        size_t depth,
+        const std::string &parcelName,
+        const std::string &blobName,
+        const std::string &fieldName,
+        const std::string &offset,
+        bool isReader) const override;
+};
+
 }  // namespace android
 
 #endif  // ENUM_TYPE_H_