move read/writeEmbedded[References]From/ToParcel out

from hidl_string, hidl_vec, and structs.

* Add a hwtypes.h in the autogenerated files, which
  contains the read/writeEmbeddedFrom/ToParcel
  methods for structs defined in types.h.

* Fixes the hack that remove the warnings when compiling
  the generated code (useParentInEmitResolveReferencesEmbedded())
  and add one more hack (useNameInEmitReaderWriterEmbedded())

* Some clean-up on Scope.cpp (add a forEachType function)

Test: mma
Test: hidl_test

Bug: 32756130

Change-Id: Icfd116b5d92fef78d257337c3f2ef02071f7600b
diff --git a/CompoundType.cpp b/CompoundType.cpp
index 2715f50..a07882d 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -193,7 +193,8 @@
             parentName,
             offsetText,
             fullName(),
-            "" /* childName */);
+            "" /* childName */,
+            "" /* namespace */);
 }
 
 void CompoundType::emitJavaReaderWriter(
@@ -294,26 +295,33 @@
     const std::string parcelObjPointer =
         parcelObjIsPointer ? parcelObj : ("&" + parcelObj);
 
-    const std::string nameDeref = name + (nameIsPointer ? "->" : ".");
+    const std::string nameDerefed = nameIsPointer ? ("*" + name) : name;
     const std::string namePointer = nameIsPointer ? name : ("&" + name);
 
     out << "_hidl_err = ";
 
     if (isReader) {
-        out << "const_cast<"
-            << fullName()
-            << " *"
-            << ">("
-            << namePointer
-            << ")->readEmbeddedReferenceFromParcel(\n";
+        out << "readEmbeddedReferenceFromParcel(\n";
     } else {
-        out << nameDeref
-            << "writeEmbeddedReferenceToParcel(\n";
+        out << "writeEmbeddedReferenceToParcel(\n";
     }
 
     out.indentBlock(2, [&]{
-        out << (isReader ? parcelObjDeref : parcelObjPointer)
-            << ",\n"
+        if (isReader) {
+            out << "const_cast<"
+                << fullName()
+                << " *"
+                << ">("
+                << namePointer
+                << "),\n"
+                << parcelObjDeref;
+        } else {
+            out << nameDerefed
+                << ",\n"
+                << parcelObjPointer;
+        }
+
+        out << ",\n"
             << parentName
             << ",\n"
             << offsetText
@@ -340,14 +348,23 @@
             << ";\n";
     }
 
+    out.unindent();
+    out << "};\n\n";
+
+    return OK;
+}
+
+
+status_t CompoundType::emitGlobalHwDeclarations(Formatter &out) const  {
     if (needsEmbeddedReadWrite()) {
-        out << "\n::android::status_t readEmbeddedFromParcel(\n";
+        out << "::android::status_t readEmbeddedFromParcel(\n";
 
         out.indent(2);
 
-        out << "const ::android::hardware::Parcel &parcel,\n"
-                  << "size_t parentHandle,\n"
-                  << "size_t parentOffset);\n\n";
+        out << fullName() << " *obj,\n"
+            << "const ::android::hardware::Parcel &parcel,\n"
+            << "size_t parentHandle,\n"
+            << "size_t parentOffset);\n\n";
 
         out.unindent(2);
 
@@ -355,30 +372,29 @@
 
         out.indent(2);
 
-        out << "::android::hardware::Parcel *parcel,\n"
-                  << "size_t parentHandle,\n"
-                  << "size_t parentOffset) const;\n";
+        out << "const " << fullName() << " &obj,\n"
+            << "::android::hardware::Parcel *parcel,\n"
+            << "size_t parentHandle,\n"
+            << "size_t parentOffset);\n\n";
 
         out.unindent(2);
     }
 
     if(needsResolveReferences()) {
-        out << "\n";
         out << "::android::status_t readEmbeddedReferenceFromParcel(\n";
         out.indent(2);
-        out << "const ::android::hardware::Parcel &parcel,\n"
-            << "size_t parentHandle, size_t parentOffset);\n";
+        out << fullName() << " *obj,\n"
+            << "const ::android::hardware::Parcel &parcel,\n"
+            << "size_t parentHandle, size_t parentOffset);\n\n";
         out.unindent(2);
         out << "::android::status_t writeEmbeddedReferenceToParcel(\n";
         out.indent(2);
-        out << "::android::hardware::Parcel *,\n"
-            << "size_t parentHandle, size_t parentOffset) const;\n";
+        out << "const " << fullName() << " &obj,\n"
+            << "::android::hardware::Parcel *,\n"
+            << "size_t parentHandle, size_t parentOffset);\n\n";
         out.unindent(2);
     }
 
-    out.unindent();
-    out << "};\n\n";
-
     return OK;
 }
 
@@ -583,28 +599,39 @@
 
 void CompoundType::emitStructReaderWriter(
         Formatter &out, const std::string &prefix, bool isReader) const {
+
+    std::string space = prefix.empty() ? "" : (prefix + "::");
+
     out << "::android::status_t "
-              << (prefix.empty() ? "" : (prefix + "::"))
-              << localName()
-              << (isReader ? "::readEmbeddedFromParcel"
-                           : "::writeEmbeddedToParcel")
-              << "(\n";
+        << (isReader ? "readEmbeddedFromParcel"
+                     : "writeEmbeddedToParcel")
+        << "(\n";
 
     out.indent(2);
 
+    bool useName = false;
+    for (const auto &field : *mFields) {
+        if (field->type().useNameInEmitReaderWriterEmbedded(isReader)) {
+            useName = true;
+            break;
+        }
+    }
+    std::string name = useName ? "obj" : "/* obj */";
+    // if not useName, then obj  should not be used at all,
+    // then the #error should not be emitted.
+    std::string error = useName ? "" : "\n#error\n";
+
     if (isReader) {
+        out << space << localName() << " *" << name << ",\n";
         out << "const ::android::hardware::Parcel &parcel,\n";
     } else {
+        out << "const " << space << localName() << " &" << name << ",\n";
         out << "::android::hardware::Parcel *parcel,\n";
     }
 
     out << "size_t parentHandle,\n"
         << "size_t parentOffset)";
 
-    if (!isReader) {
-        out << " const";
-    }
-
     out << " {\n";
 
     out.unindent(2);
@@ -620,7 +647,7 @@
         field->type().emitReaderWriterEmbedded(
                 out,
                 0 /* depth */,
-                field->name(),
+                name + (isReader ? "->" : ".") + field->name() + error,
                 field->name() /* sanitizedName */,
                 false /* nameIsPointer */,
                 "parcel",
@@ -646,10 +673,8 @@
 
 void CompoundType::emitResolveReferenceDef(
         Formatter &out, const std::string prefix, bool isReader) const {
-    out << "::android::status_t "
-              << (prefix.empty() ? "" : (prefix + "::"))
-              << localName();
-
+    out << "::android::status_t ";
+    const std::string space(prefix.empty() ? "" : (prefix + "::"));
 
     bool useParent = false;
     for (const auto &field : *mFields) {
@@ -663,18 +688,20 @@
     std::string parentOffsetName = useParent ? "parentOffset" : "/* parentOffset */";
 
     if (isReader) {
-        out << "::readEmbeddedReferenceFromParcel(\n";
+        out << "readEmbeddedReferenceFromParcel(\n";
         out.indent(2);
-        out << "const ::android::hardware::Parcel &parcel,\n"
+        out << space + localName() + " *obj,\n"
+            << "const ::android::hardware::Parcel &parcel,\n"
             << "size_t " << parentHandleName << ", "
             << "size_t " << parentOffsetName << ")\n";
         out.unindent(2);
     } else {
-        out << "::writeEmbeddedReferenceToParcel(\n";
+        out << "writeEmbeddedReferenceToParcel(\n";
         out.indent(2);
-        out << "::android::hardware::Parcel *parcel,\n"
+        out << "const " << space + localName() + " &obj,\n"
+            << "::android::hardware::Parcel *parcel,\n"
             << "size_t " << parentHandleName << ", "
-            << "size_t " << parentOffsetName << ") const\n";
+            << "size_t " << parentOffsetName << ")\n";
         out.unindent(2);
     }
 
@@ -684,6 +711,7 @@
 
     out << "::android::status_t _hidl_err = ::android::OK;\n\n";
 
+    const std::string nameDeref(isReader ? "obj->" : "obj.");
     // if not useParent, then parentName and offsetText
     // should not be used at all, then the #error should not be emitted.
     std::string error = useParent ? "" : "\n#error\n";
@@ -696,7 +724,7 @@
         field->type().emitResolveReferencesEmbedded(
             out,
             0 /* depth */,
-            field->name(),
+            nameDeref + field->name(),
             field->name() /* sanitizedName */,
             false,    // nameIsPointer
             "parcel", // const std::string &parcelObj,
diff --git a/CompoundType.h b/CompoundType.h
index baef137..df558d7 100644
--- a/CompoundType.h
+++ b/CompoundType.h
@@ -109,6 +109,7 @@
             bool isReader) const override;
 
     status_t emitTypeDeclarations(Formatter &out) const override;
+    status_t emitGlobalHwDeclarations(Formatter &out) const override;
 
     status_t emitTypeDefinitions(
             Formatter &out, const std::string prefix) const override;
diff --git a/HandleType.cpp b/HandleType.cpp
index a3e4a7d..3ff0f89 100644
--- a/HandleType.cpp
+++ b/HandleType.cpp
@@ -74,6 +74,10 @@
     }
 }
 
+bool HandleType::useNameInEmitReaderWriterEmbedded(bool isReader) const {
+    return !isReader;
+}
+
 void HandleType::emitReaderWriterEmbedded(
         Formatter &out,
         size_t /* depth */,
diff --git a/HandleType.h b/HandleType.h
index 527c930..d3805f6 100644
--- a/HandleType.h
+++ b/HandleType.h
@@ -56,6 +56,8 @@
 
     bool isJavaCompatible() const override;
 
+    bool useNameInEmitReaderWriterEmbedded(bool isReader) const override;
+
     void getAlignmentAndSize(size_t *align, size_t *size) const override;
 };
 
diff --git a/PredefinedType.cpp b/PredefinedType.cpp
index ba2842b..fb015a4 100644
--- a/PredefinedType.cpp
+++ b/PredefinedType.cpp
@@ -21,18 +21,25 @@
 
 namespace android {
 
-PredefinedType::PredefinedType(const char *name)
-    : mName(name) {
+PredefinedType::PredefinedType(const char *nsp, const char *name)
+    : mNamespace(nsp), mName(name) {
 }
 
 void PredefinedType::addNamedTypesToSet(std::set<const FQName> &) const {
     // do nothing
 }
+
+std::string PredefinedType::fullName() const {
+    return mNamespace +
+            (mNamespace.empty() ? "" : "::") +
+            mName;
+}
+
 std::string PredefinedType::getCppType(
         StorageMode mode,
         bool) const {
 
-    const std::string base = mName;
+    const std::string base = fullName();
 
     switch (mode) {
         case StorageMode_Stack:
@@ -63,7 +70,7 @@
     if (isReader) {
         out << name
             << " = (const "
-            << mName
+            << fullName()
             << " *)"
             << parcelObjDeref
             << "readBuffer("
@@ -132,8 +139,9 @@
             mode,
             parentName,
             offsetText,
-            mName,
-            "" /* childName */);
+            fullName(),
+            "" /* childName */,
+            mNamespace);
 }
 
 bool PredefinedType::isJavaCompatible() const {
diff --git a/PredefinedType.h b/PredefinedType.h
index cbfbcf9..a3f2e81 100644
--- a/PredefinedType.h
+++ b/PredefinedType.h
@@ -23,10 +23,12 @@
 namespace android {
 
 struct PredefinedType : public Type {
-    PredefinedType(const char *name);
+    PredefinedType(const char *nsp, const char *name);
 
     void addNamedTypesToSet(std::set<const FQName> &set) const override;
 
+    std::string fullName() const;
+
     std::string getCppType(
             StorageMode mode,
             bool specifyNamespaces) const override;
@@ -58,6 +60,7 @@
     bool resultNeedsDeref() const override;
 
 private:
+    std::string mNamespace;
     std::string mName;
 
     DISALLOW_COPY_AND_ASSIGN(PredefinedType);
diff --git a/RefType.cpp b/RefType.cpp
index 16b24b6..dd5b0d2 100644
--- a/RefType.cpp
+++ b/RefType.cpp
@@ -158,7 +158,7 @@
             out,
             0 /* depth */,
             name,
-            name /* sanitizedName */,
+            sanitizedName,
             true /* nameIsPointer */, // for element type, name is a pointer.
             parcelObj,
             parcelObjIsPointer,
@@ -188,9 +188,6 @@
     out << "}\n\n";
 }
 
-
-
-
 bool RefType::needsResolveReferences() const {
     return true;
 }
diff --git a/Scope.cpp b/Scope.cpp
index 061bc6f..df8651b 100644
--- a/Scope.cpp
+++ b/Scope.cpp
@@ -116,9 +116,9 @@
     return false;
 }
 
-status_t Scope::emitTypeDeclarations(Formatter &out) const {
+status_t Scope::forEachType(std::function<status_t(Type *)> func) const {
     for (size_t i = 0; i < mTypes.size(); ++i) {
-        status_t err = mTypes[i]->emitTypeDeclarations(out);
+        status_t err = func(mTypes[i]);
 
         if (err != OK) {
             return err;
@@ -128,42 +128,36 @@
     return OK;
 }
 
+status_t Scope::emitTypeDeclarations(Formatter &out) const {
+    return forEachType([&](Type *type) {
+        return type->emitTypeDeclarations(out);
+    });
+}
+
 status_t Scope::emitGlobalTypeDeclarations(Formatter &out) const {
-    for (size_t i = 0; i < mTypes.size(); ++i) {
-        status_t err = mTypes[i]->emitGlobalTypeDeclarations(out);
+    return forEachType([&](Type *type) {
+        return type->emitGlobalTypeDeclarations(out);
+    });
+}
 
-        if (err != OK) {
-            return err;
-        }
-    }
-
-    return OK;
+status_t Scope::emitGlobalHwDeclarations(Formatter &out) const {
+    return forEachType([&](Type *type) {
+        return type->emitGlobalHwDeclarations(out);
+    });
 }
 
 status_t Scope::emitJavaTypeDeclarations(
         Formatter &out, bool atTopLevel) const {
-    for (size_t i = 0; i < mTypes.size(); ++i) {
-        status_t err = mTypes[i]->emitJavaTypeDeclarations(out, atTopLevel);
-
-        if (err != OK) {
-            return err;
-        }
-    }
-
-    return OK;
+    return forEachType([&](Type *type) {
+        return type->emitJavaTypeDeclarations(out, atTopLevel);
+    });
 }
 
 status_t Scope::emitTypeDefinitions(
         Formatter &out, const std::string prefix) const {
-    for (size_t i = 0; i < mTypes.size(); ++i) {
-        status_t err = mTypes[i]->emitTypeDefinitions(out, prefix);
-
-        if (err != OK) {
-            return err;
-        }
-    }
-
-    return OK;
+    return forEachType([&](Type *type) {
+        return type->emitTypeDefinitions(out, prefix);
+    });
 }
 
 const std::vector<NamedType *> &Scope::getSubTypes() const {
@@ -171,13 +165,9 @@
 }
 
 status_t Scope::emitVtsTypeDeclarations(Formatter &out) const {
-    for (size_t i = 0; i < mTypes.size(); ++i) {
-        status_t status = mTypes[i]->emitVtsTypeDeclarations(out);
-        if (status != OK) {
-            return status;
-        }
-    }
-    return OK;
+    return forEachType([&](Type *type) {
+        return type->emitVtsTypeDeclarations(out);
+    });
 }
 
 bool Scope::isJavaCompatible() const {
@@ -192,9 +182,10 @@
 
 void Scope::appendToExportedTypesVector(
         std::vector<const Type *> *exportedTypes) const {
-    for (const NamedType *type : mTypes) {
+    forEachType([&](Type *type) {
         type->appendToExportedTypesVector(exportedTypes);
-    }
+        return OK;
+    });
 }
 
 LocalIdentifier::LocalIdentifier(){}
diff --git a/Scope.h b/Scope.h
index 4fb57ed..0b34182 100644
--- a/Scope.h
+++ b/Scope.h
@@ -52,6 +52,7 @@
 
     status_t emitTypeDeclarations(Formatter &out) const override;
     status_t emitGlobalTypeDeclarations(Formatter &out) const override;
+    status_t emitGlobalHwDeclarations(Formatter &out) const override;
 
     status_t emitJavaTypeDeclarations(
             Formatter &out, bool atTopLevel) const override;
@@ -72,6 +73,8 @@
     std::vector<NamedType *> mTypes;
     std::map<std::string, size_t> mTypeIndexByName;
 
+    status_t forEachType(std::function<status_t(Type *)> func) const;
+
     DISALLOW_COPY_AND_ASSIGN(Scope);
 };
 
diff --git a/StringType.cpp b/StringType.cpp
index 6001fac..e449369 100644
--- a/StringType.cpp
+++ b/StringType.cpp
@@ -140,7 +140,8 @@
             parentName,
             offsetText,
             "::android::hardware::hidl_string",
-            "" /* childName */);
+            "" /* childName */,
+            "::android::hardware");
 }
 
 void StringType::emitJavaFieldInitializer(
diff --git a/Type.cpp b/Type.cpp
index d7ae31a..47cea08 100644
--- a/Type.cpp
+++ b/Type.cpp
@@ -154,7 +154,11 @@
 }
 
 bool Type::useParentInEmitResolveReferencesEmbedded() const {
-    return true;
+    return needsResolveReferences();
+}
+
+bool Type::useNameInEmitReaderWriterEmbedded(bool) const {
+    return needsEmbeddedReadWrite();
 }
 
 void Type::emitReaderWriterEmbedded(
@@ -273,32 +277,40 @@
         const std::string &parentName,
         const std::string &offsetText,
         const std::string &typeName,
-        const std::string &childName) const {
-    const std::string parcelObjDeref =
+        const std::string &childName,
+        const std::string &funcNamespace) const {
+
+        const std::string parcelObjDeref =
         parcelObjIsPointer ? ("*" + parcelObj) : parcelObj;
 
     const std::string parcelObjPointer =
         parcelObjIsPointer ? parcelObj : ("&" + parcelObj);
 
-    const std::string nameDeref = name + (nameIsPointer ? "->" : ".");
+    const std::string nameDerefed = nameIsPointer ? ("*" + name) : name;
     const std::string namePointer = nameIsPointer ? name : ("&" + name);
 
     out << "_hidl_err = ";
 
+    if (!funcNamespace.empty()) {
+        out << funcNamespace << "::";
+    }
+
+    out << (isReader ? "readEmbeddedFromParcel(\n" : "writeEmbeddedToParcel(\n");
+
+    out.indent();
+    out.indent();
+
     if (isReader) {
         out << "const_cast<"
             << typeName
             << " *>("
             << namePointer
-            << ")->readEmbeddedFromParcel(\n";
+            << "),\n";
     } else {
-        out << nameDeref
-            << "writeEmbeddedToParcel(\n";
+        out << nameDerefed
+            << ",\n";
     }
 
-    out.indent();
-    out.indent();
-
     out << (isReader ? parcelObjDeref : parcelObjPointer)
         << ",\n"
         << parentName
@@ -326,6 +338,10 @@
     return OK;
 }
 
+status_t Type::emitGlobalHwDeclarations(Formatter &) const {
+    return OK;
+}
+
 status_t Type::emitTypeDefinitions(
         Formatter &, const std::string) const {
     return OK;
diff --git a/Type.h b/Type.h
index 7c1cca0..4f90232 100644
--- a/Type.h
+++ b/Type.h
@@ -144,6 +144,8 @@
 
     virtual bool useParentInEmitResolveReferencesEmbedded() const;
 
+    virtual bool useNameInEmitReaderWriterEmbedded(bool isReader) const;
+
     virtual void emitJavaReaderWriter(
             Formatter &out,
             const std::string &parcelObj,
@@ -169,6 +171,10 @@
     // at global scope, i.e. enum class operators.
     virtual status_t emitGlobalTypeDeclarations(Formatter &out) const;
 
+    // Emit any declarations pertaining to this type that have to be
+    // at global scope for transport, e.g. read/writeEmbeddedTo/FromParcel
+    virtual status_t emitGlobalHwDeclarations(Formatter &out) const;
+
     virtual status_t emitTypeDefinitions(
             Formatter &out, const std::string prefix) const;
 
@@ -214,7 +220,8 @@
             const std::string &parentName,
             const std::string &offsetText,
             const std::string &typeName,
-            const std::string &childName) const;
+            const std::string &childName,
+            const std::string &funcNamespace) const;
 
     void emitJavaReaderWriterWithSuffix(
             Formatter &out,
diff --git a/VectorType.cpp b/VectorType.cpp
index a804b5f..b3e7235 100644
--- a/VectorType.cpp
+++ b/VectorType.cpp
@@ -265,7 +265,8 @@
             parentName,
             offsetText,
             baseType,
-            childName);
+            childName,
+            "::android::hardware");
 
     if (!mElementType->needsEmbeddedReadWrite()) {
         return;
diff --git a/generateCpp.cpp b/generateCpp.cpp
index c14119a..b659f7b 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -313,22 +313,25 @@
 
 status_t AST::generateHwBinderHeader(const std::string &outputPath) const {
     std::string ifaceName;
-    if(!AST::isInterface(&ifaceName)) {
-        // types.hal does not get an HwBinder header.
-        return OK;
+    bool isInterface = AST::isInterface(&ifaceName);
+    const Interface *iface = nullptr;
+    std::string baseName{};
+    std::string klassName{};
+
+    if(isInterface) {
+        iface = mRootScope->getInterface();
+        baseName = iface->getBaseName();
+        klassName = "IHw" + baseName;
+    } else {
+        klassName = "hwtypes";
     }
 
-    const Interface *iface = mRootScope->getInterface();
-    const std::string baseName = iface->getBaseName();
-
-    const std::string klassName = "IHw" + baseName;
-
     std::string path = outputPath;
     path.append(mCoordinator->convertPackageRootToPath(mPackage));
     path.append(mCoordinator->getPackagePath(mPackage, true /* relative */));
     path.append(klassName + ".h");
 
-    FILE* file = fopen(path.c_str(), "w");
+    FILE *file = fopen(path.c_str(), "w");
 
     if (file == NULL) {
         return -errno;
@@ -341,16 +344,20 @@
     out << "#ifndef " << guard << "\n";
     out << "#define " << guard << "\n\n";
 
-    generateCppPackageInclude(out, mPackage, ifaceName);
+    if (isInterface) {
+        generateCppPackageInclude(out, mPackage, ifaceName);
+    } else {
+        generateCppPackageInclude(out, mPackage, "types");
+    }
 
     out << "\n";
 
     for (const auto &item : mImportedNames) {
         if (item.name() == "types") {
-            continue;
+            generateCppPackageInclude(out, item, "hwtypes");
+        } else {
+            generateCppPackageInclude(out, item, "Bn" + item.getInterfaceBaseName());
         }
-
-        generateCppPackageInclude(out, item, "Bn" + item.getInterfaceBaseName());
     }
 
     out << "\n";
@@ -363,26 +370,34 @@
     out << "\n";
 
     enterLeaveNamespace(out, true /* enter */);
-    out << "\n";
 
-    out << "struct "
-        << klassName
-        << " : public "
-        << ifaceName;
+    if (isInterface) {
+        out << "\n";
 
-    const Interface *superType = iface->superType();
+        out << "struct "
+            << klassName
+            << " : public "
+            << ifaceName;
 
-    out << ", public ::android::hardware::IInterface";
+        const Interface *superType = iface->superType();
 
-    out << " {\n";
+        out << ", public ::android::hardware::IInterface";
 
-    out.indent();
+        out << " {\n";
 
-    out << "DECLARE_HWBINDER_META_INTERFACE(" << baseName << ");\n\n";
+        out.indent();
 
-    out.unindent();
+        out << "DECLARE_HWBINDER_META_INTERFACE(" << baseName << ");\n\n";
 
-    out << "};\n\n";
+        out.unindent();
+
+        out << "};\n\n";
+    }
+
+    status_t err = mRootScope->emitGlobalHwDeclarations(out);
+    if (err != OK) {
+        return err;
+    }
 
     enterLeaveNamespace(out, false /* enter */);
 
@@ -740,6 +755,7 @@
         }
     } else {
         generateCppPackageInclude(out, mPackage, "types");
+        generateCppPackageInclude(out, mPackage, "hwtypes");
     }
 
     out << "\n";
diff --git a/hidl-gen_l.ll b/hidl-gen_l.ll
index f8f37e0..ab743d5 100644
--- a/hidl-gen_l.ll
+++ b/hidl-gen_l.ll
@@ -111,8 +111,8 @@
 "handle"		{ yylval->type = new HandleType; return token::TYPE; }
 "string"		{ yylval->type = new StringType; return token::TYPE; }
 
-"MQDescriptorSync" { yylval->type = new PredefinedType("::android::hardware::MQDescriptorSync"); return token::TYPE; }
-"MQDescriptorUnsync" { yylval->type = new PredefinedType("::android::hardware::MQDescriptorUnsync"); return token::TYPE; }
+"MQDescriptorSync" { yylval->type = new PredefinedType("::android::hardware", "MQDescriptorSync"); return token::TYPE; }
+"MQDescriptorUnsync" { yylval->type = new PredefinedType("::android::hardware", "MQDescriptorUnsync"); return token::TYPE; }
 
 "("			{ return('('); }
 ")"			{ return(')'); }