Remove extra from getCppType.

The argument is used for array type originally. We
now use hidl_array instead of T[], so there is no
need to use extra.

Renamed the convenience getCppType to getCppStackType
to avoid casting to (Type *) before using this
method (which makes it inconvenient)

Also fixes:
* RefType::getCppType ignores specifyNamespaces
* ConstantExpression.cpp emits a C-style cast instead
  of static_cast

Bug: 32559427

Test: mma passes
Test: hidl_test

Change-Id: I7e2e31c34c1ca1aa83c4a5a4dbdf7fd6b9aff30c
diff --git a/generateCpp.cpp b/generateCpp.cpp
index f834f78..6c721da 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -250,9 +250,8 @@
 
             const TypedVar *elidedReturn = method->canElideCallback();
             if (elidedReturn) {
-                std::string extra;
                 out << "virtual ::android::hardware::Return<";
-                out << elidedReturn->type().getCppResultType(&extra) << "> ";
+                out << elidedReturn->type().getCppResultType() << "> ";
             } else {
                 out << "virtual ::android::hardware::Return<void> ";
             }
@@ -285,18 +284,14 @@
 
         if (!iface->isRootType()) {
             out << "// cast static functions\n";
-            std::string childTypeExtra;
-            std::string childTypeResult = iface->getCppResultType(&childTypeExtra);
-            childTypeResult += childTypeExtra;
+            std::string childTypeResult = iface->getCppResultType();
 
             for (const Interface *superType : iface->superTypeChain()) {
-                std::string superTypeExtra;
                 out << "static "
                     << childTypeResult
                     << " castFrom("
-                    << superType->getCppArgumentType(&superTypeExtra)
+                    << superType->getCppArgumentType()
                     << " parent"
-                    << superTypeExtra
                     << ");\n";
             }
         }
@@ -837,12 +832,9 @@
     for (const auto &arg : args) {
         const Type &type = arg->type();
 
-        std::string extra;
-        out << type.getCppResultType(&extra)
+        out << type.getCppResultType()
             << " "
-            << (forResults ? "_hidl_out_" : "")
-            << arg->name()
-            << extra
+            << (forResults ? "_hidl_out_" : "") + arg->name()
             << ";\n";
     }
 
@@ -1033,10 +1025,9 @@
     }
 
     if (elidedReturn != nullptr) {
-        std::string extra;
         out << "_hidl_status.setFromStatusT(_hidl_err);\n";
         out << "return ::android::hardware::Return<";
-        out << elidedReturn->type().getCppResultType(&extra)
+        out << elidedReturn->type().getCppResultType()
             << ">(_hidl_out_" << elidedReturn->name() << ");\n\n";
     } else {
         out << "_hidl_status.setFromStatusT(_hidl_err);\n";
@@ -1049,8 +1040,7 @@
     out << "_hidl_status.setFromStatusT(_hidl_err);\n";
     out << "return ::android::hardware::Return<";
     if (elidedReturn != nullptr) {
-        std::string extra;
-        out << method->results().at(0)->type().getCppResultType(&extra);
+        out << method->results().at(0)->type().getCppResultType();
     } else {
         out << "void";
     }
@@ -1276,11 +1266,12 @@
     const TypedVar *elidedReturn = method->canElideCallback();
 
     if (elidedReturn != nullptr) {
-        std::string extra;
-
-        out << elidedReturn->type().getCppResultType(&extra) << " ";
-        out << elidedReturn->name() << " = ";
-        out << method->name() << "(";
+        out << elidedReturn->type().getCppResultType()
+            << " "
+            << elidedReturn->name()
+            << " = "
+            << method->name()
+            << "(";
 
         bool first = true;
         for (const auto &arg : method->args()) {
@@ -1561,22 +1552,16 @@
 
     // generate castFrom functions
     if (!iface->isRootType()) {
-        std::string childTypeExtra;
-        std::string childTypeResult = iface->getCppResultType(&childTypeExtra);
-        childTypeResult += childTypeExtra;
+        std::string childTypeResult = iface->getCppResultType();
 
         for (const Interface *superType : iface->superTypeChain()) {
-            std::string superTypeExtra;
             out << "// static \n"
                 << childTypeResult
                 << " I"
                 << iface->getBaseName()
                 << "::castFrom("
-                << superType->getCppArgumentType(&superTypeExtra)
-                << " parent"
-                << superTypeExtra
-                << ")";
-            out << " {\n";
+                << superType->getCppArgumentType()
+                << " parent) {\n";
             out.indent();
             out << "return ::android::hardware::castInterface<";
             out << "I" << iface->getBaseName() << ", "