hidl-gen: remove references to AIDL

git grep -l _aidl_ . | xargs sed -i -e 's/_aidl_/_hidl_/g'

b/30778629 Generated code has many references to AIDL

Change-Id: I3172e7da7acd6ba8c8c332be7316317b0eb59136
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/ArrayType.cpp b/ArrayType.cpp
index d855c31..732f2e6 100644
--- a/ArrayType.cpp
+++ b/ArrayType.cpp
@@ -43,7 +43,7 @@
     std::string baseExtra;
     std::string baseType = mElementType->getCppType(&baseExtra);
 
-    const std::string parentName = "_aidl_" + name + "_parent";
+    const std::string parentName = "_hidl_" + name + "_parent";
 
     out << "size_t " << parentName << ";\n\n";
 
@@ -64,13 +64,13 @@
 
         out.indent();
 
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
 
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = "
+        out << "_hidl_err = "
             << parcelObjDeref
             << "writeBuffer("
             << name
@@ -116,22 +116,22 @@
     std::string baseExtra;
     std::string baseType = mElementType->getCppType(&baseExtra);
 
-    out << "for (size_t _aidl_index = 0; _aidl_index < "
+    out << "for (size_t _hidl_index = 0; _hidl_index < "
         << mDimension
-        << "; ++_aidl_index) {\n";
+        << "; ++_hidl_index) {\n";
 
     out.indent();
 
     mElementType->emitReaderWriterEmbedded(
             out,
-            name + "[_aidl_index]",
+            name + "[_hidl_index]",
             false /* nameIsPointer */,
             parcelObj,
             parcelObjIsPointer,
             isReader,
             mode,
             parentName,
-            offsetText + " + _aidl_index * sizeof(" + baseType + ")");
+            offsetText + " + _hidl_index * sizeof(" + baseType + ")");
 
     out.unindent();
 
diff --git a/CompoundType.cpp b/CompoundType.cpp
index da256e1..e7a0225 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -65,7 +65,7 @@
         bool parcelObjIsPointer,
         bool isReader,
         ErrorMode mode) const {
-    const std::string parentName = "_aidl_" + name + "_parent";
+    const std::string parentName = "_hidl_" + name + "_parent";
 
     out << "size_t " << parentName << ";\n\n";
 
@@ -89,13 +89,13 @@
 
         out.indent();
 
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
 
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = "
+        out << "_hidl_err = "
             << parcelObjDeref
             << "writeBuffer(&"
             << name
@@ -248,7 +248,7 @@
     out.unindent();
     out.indent();
 
-    out << "::android::status_t _aidl_err = ::android::OK;\n\n";
+    out << "::android::status_t _hidl_err = ::android::OK;\n\n";
 
     for (const auto &field : *mFields) {
         if (!field->type().needsEmbeddedReadWrite()) {
@@ -272,9 +272,9 @@
     }
 
     out.unindent();
-    out << "_aidl_error:\n";
+    out << "_hidl_error:\n";
     out.indent();
-    out << "return _aidl_err;\n";
+    out << "return _hidl_err;\n";
 
     out.unindent();
     out << "}\n\n";
diff --git a/HandleType.cpp b/HandleType.cpp
index a2288a9..7ad2368 100644
--- a/HandleType.cpp
+++ b/HandleType.cpp
@@ -34,13 +34,13 @@
 
         out.indent();
 
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
 
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = ";
+        out << "_hidl_err = ";
         out << parcelObjDeref
             << "writeNativeHandleNoDup("
             << name
@@ -61,7 +61,7 @@
         const std::string &parentName,
         const std::string &offsetText) const {
     if (isReader) {
-        const std::string ptrName = "_aidl_" + name  + "_ptr";
+        const std::string ptrName = "_hidl_" + name  + "_ptr";
 
         out << "const native_handle_t *"
             << ptrName
@@ -86,12 +86,12 @@
             << " == nullptr) {\n";
 
         out.indent();
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = "
+        out << "_hidl_err = "
             << parcelObj
             << (parcelObjIsPointer ? "->" : ".")
             << "writeEmbeddedNativeHandle(\n";
diff --git a/Interface.cpp b/Interface.cpp
index 158f874..a9b27af 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -50,12 +50,12 @@
         parcelObj + (parcelObjIsPointer ? "->" : ".");
 
     if (isReader) {
-        const std::string binderName = "_aidl_" + name + "_binder";
+        const std::string binderName = "_hidl_" + name + "_binder";
 
         out << "::android::sp<::android::hardware::IBinder> "
             << binderName << ";\n";
 
-        out << "_aidl_err = ";
+        out << "_hidl_err = ";
         out << parcelObjDeref
             << "readNullableStrongBinder(&"
             << binderName
@@ -70,7 +70,7 @@
             << binderName
             << ");\n";
     } else {
-        out << "_aidl_err = ";
+        out << "_hidl_err = ";
         out << parcelObjDeref
             << "writeStrongBinder("
             << fullName()
diff --git a/ScalarType.cpp b/ScalarType.cpp
index f308a72..b15734b 100644
--- a/ScalarType.cpp
+++ b/ScalarType.cpp
@@ -83,7 +83,7 @@
     const std::string parcelObjDeref =
         parcelObj + (parcelObjIsPointer ? "->" : ".");
 
-    out << "_aidl_err = "
+    out << "_hidl_err = "
         << parcelObjDeref
         << (isReader ? "read" : "write")
         << kSuffix[mKind]
diff --git a/StringType.cpp b/StringType.cpp
index 6f9bc21..5411e91 100644
--- a/StringType.cpp
+++ b/StringType.cpp
@@ -30,7 +30,7 @@
         bool parcelObjIsPointer,
         bool isReader,
         ErrorMode mode) const {
-    const std::string parentName = "_aidl_" + name + "_parent";
+    const std::string parentName = "_hidl_" + name + "_parent";
     out << "size_t " << parentName << ";\n\n";
 
     const std::string parcelObjDeref =
@@ -51,13 +51,13 @@
 
         out.indent();
 
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
 
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = "
+        out << "_hidl_err = "
             << parcelObjDeref
             << "writeBuffer(&"
             << name
diff --git a/Type.cpp b/Type.cpp
index 6d0e4e8..bec4655 100644
--- a/Type.cpp
+++ b/Type.cpp
@@ -72,25 +72,25 @@
     switch (mode) {
         case ErrorMode_Ignore:
         {
-            out << "/* _aidl_err ignored! */\n\n";
+            out << "/* _hidl_err ignored! */\n\n";
             break;
         }
 
         case ErrorMode_Goto:
         {
-            out << "if (_aidl_err != ::android::OK) { goto _aidl_error; }\n\n";
+            out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
             break;
         }
 
         case ErrorMode_Break:
         {
-            out << "if (_aidl_err != ::android::OK) { break; }\n\n";
+            out << "if (_hidl_err != ::android::OK) { break; }\n\n";
             break;
         }
 
         case ErrorMode_Return:
         {
-            out << "if (_aidl_err != ::android::OK) { return _aidl_err; }\n\n";
+            out << "if (_hidl_err != ::android::OK) { return _hidl_err; }\n\n";
             break;
         }
     }
@@ -100,7 +100,7 @@
     switch (mode) {
         case ErrorMode_Goto:
         {
-            out << "goto _aidl_error;\n";
+            out << "goto _hidl_error;\n";
             break;
         }
 
@@ -112,13 +112,13 @@
 
         case ErrorMode_Ignore:
         {
-            out << "/* ignoring _aidl_error! */";
+            out << "/* ignoring _hidl_error! */";
             break;
         }
 
         case ErrorMode_Return:
         {
-            out << "return _aidl_err;\n";
+            out << "return _hidl_err;\n";
             break;
         }
     }
@@ -145,7 +145,7 @@
     const std::string nameDeref = name + (nameIsPointer ? "->" : ".");
     const std::string namePointer = nameIsPointer ? name : ("&" + name);
 
-    out << "_aidl_err = ";
+    out << "_hidl_err = ";
 
     if (isReader) {
         out << "const_cast<"
diff --git a/VectorType.cpp b/VectorType.cpp
index 055b5a3..fcfda4b 100644
--- a/VectorType.cpp
+++ b/VectorType.cpp
@@ -40,7 +40,7 @@
     std::string baseExtra;
     std::string baseType = mElementType->getCppType(&baseExtra);
 
-    const std::string parentName = "_aidl_" + name + "_parent";
+    const std::string parentName = "_hidl_" + name + "_parent";
 
     out << "size_t " << parentName << ";\n\n";
 
@@ -61,13 +61,13 @@
 
         out.indent();
 
-        out << "_aidl_err = ::android::UNKNOWN_ERROR;\n";
+        out << "_hidl_err = ::android::UNKNOWN_ERROR;\n";
         handleError2(out, mode);
 
         out.unindent();
         out << "}\n\n";
     } else {
-        out << "_aidl_err = "
+        out << "_hidl_err = "
             << parcelObjDeref
             << "writeBuffer(&"
             << name
@@ -105,7 +105,7 @@
     std::string baseExtra;
     std::string baseType = Type::getCppType(&baseExtra);
 
-    const std::string childName = "_aidl_" + name + "_child";
+    const std::string childName = "_hidl_" + name + "_child";
     out << "size_t " << childName << ";\n\n";
 
     emitReaderWriterEmbeddedForTypeName(
@@ -129,22 +129,22 @@
 
     baseType = mElementType->getCppType(&baseExtra);
 
-    out << "for (size_t _aidl_index = 0; _aidl_index < "
+    out << "for (size_t _hidl_index = 0; _hidl_index < "
         << nameDeref
-        << "size(); ++_aidl_index) {\n";
+        << "size(); ++_hidl_index) {\n";
 
     out.indent();
 
     mElementType->emitReaderWriterEmbedded(
             out,
-            (nameIsPointer ? "(*" + name + ")" : name) + "[_aidl_index]",
+            (nameIsPointer ? "(*" + name + ")" : name) + "[_hidl_index]",
             false /* nameIsPointer */,
             parcelObj,
             parcelObjIsPointer,
             isReader,
             mode,
             childName,
-            "_aidl_index * sizeof(" + baseType + ")");
+            "_hidl_index * sizeof(" + baseType + ")");
 
     out.unindent();
 
diff --git a/generateCpp.cpp b/generateCpp.cpp
index f871fd8..a8f95a6 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -249,7 +249,7 @@
                     out << ", ";
                 }
 
-                out << method->name() << "_cb _aidl_cb = nullptr";
+                out << method->name() << "_cb _hidl_cb = nullptr";
             }
 
             out << ") = 0;\n";
@@ -330,11 +330,11 @@
     out << "::android::status_t onTransact(\n";
     out.indent();
     out.indent();
-    out << "uint32_t _aidl_code,\n";
-    out << "const ::android::hardware::Parcel &_aidl_data,\n";
-    out << "::android::hardware::Parcel *_aidl_reply,\n";
-    out << "uint32_t _aidl_flags = 0,\n";
-    out << "TransactCallback _aidl_cb = nullptr) override;\n";
+    out << "uint32_t _hidl_code,\n";
+    out << "const ::android::hardware::Parcel &_hidl_data,\n";
+    out << "::android::hardware::Parcel *_hidl_reply,\n";
+    out << "uint32_t _hidl_flags = 0,\n";
+    out << "TransactCallback _hidl_cb = nullptr) override;\n";
     out.unindent();
     out.unindent();
 
@@ -404,7 +404,7 @@
 
     out << "explicit Bp"
         << baseName
-        << "(const ::android::sp<::android::hardware::IBinder> &_aidl_impl);"
+        << "(const ::android::sp<::android::hardware::IBinder> &_hidl_impl);"
         << "\n\n";
 
     const Interface *iface = mRootScope->getInterface();
@@ -435,7 +435,7 @@
                     out << ", ";
                 }
 
-                out << method->name() << "_cb _aidl_cb";
+                out << method->name() << "_cb _hidl_cb";
             }
 
             out << ") override;\n";
@@ -565,7 +565,7 @@
     out << klassName
         << "::"
         << klassName
-        << "(const ::android::sp<::android::hardware::IBinder> &_aidl_impl)\n";
+        << "(const ::android::sp<::android::hardware::IBinder> &_hidl_impl)\n";
 
     out.indent();
     out.indent();
@@ -573,7 +573,7 @@
     out << ": BpInterface"
         << "<I"
         << baseName
-        << ">(_aidl_impl) {\n";
+        << ">(_hidl_impl) {\n";
 
     out.unindent();
     out.unindent();
@@ -605,51 +605,51 @@
                     out << ", ";
                 }
 
-                out << method->name() << "_cb _aidl_cb";
+                out << method->name() << "_cb _hidl_cb";
             }
 
             out << ") {\n";
 
             out.indent();
 
-            out << "::android::hardware::Parcel _aidl_data;\n";
-            out << "::android::hardware::Parcel _aidl_reply;\n";
-            out << "::android::status_t _aidl_err;\n\n";
-            out << "::android::hardware::Status _aidl_status;\n";
+            out << "::android::hardware::Parcel _hidl_data;\n";
+            out << "::android::hardware::Parcel _hidl_reply;\n";
+            out << "::android::status_t _hidl_err;\n\n";
+            out << "::android::hardware::Status _hidl_status;\n";
 
-            out << "_aidl_err = _aidl_data.writeInterfaceToken("
+            out << "_hidl_err = _hidl_data.writeInterfaceToken("
                 << superInterface->fullName()
                 << "::getInterfaceDescriptor());\n";
 
-            out << "if (_aidl_err != ::android::OK) { goto _aidl_error; }\n\n";
+            out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
 
             for (const auto &arg : method->args()) {
                 emitCppReaderWriter(
                         out,
-                        "_aidl_data",
+                        "_hidl_data",
                         false /* parcelObjIsPointer */,
                         arg,
                         false /* reader */,
                         Type::ErrorMode_Goto);
             }
 
-            out << "_aidl_err = remote()->transact(I"
+            out << "_hidl_err = remote()->transact(I"
                       << baseName
                       << "::"
                       << upcase(method->name())
-                      << ", _aidl_data, &_aidl_reply);\n";
+                      << ", _hidl_data, &_hidl_reply);\n";
 
-            out << "if (_aidl_err != ::android::OK) { goto _aidl_error; }\n\n";
+            out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
 
-            out << "_aidl_err = _aidl_status.readFromParcel(_aidl_reply);\n";
-            out << "if (_aidl_err != ::android::OK) { goto _aidl_error; }\n\n";
+            out << "_hidl_err = _hidl_status.readFromParcel(_hidl_reply);\n";
+            out << "if (_hidl_err != ::android::OK) { goto _hidl_error; }\n\n";
 
-            out << "if (!_aidl_status.isOk()) { return _aidl_status; }\n\n";
+            out << "if (!_hidl_status.isOk()) { return _hidl_status; }\n\n";
 
             for (const auto &arg : method->results()) {
                 emitCppReaderWriter(
                         out,
-                        "_aidl_reply",
+                        "_hidl_reply",
                         false /* parcelObjIsPointer */,
                         arg,
                         true /* reader */,
@@ -657,9 +657,9 @@
             }
 
             if (returnsValue) {
-                out << "if (_aidl_cb != nullptr) {\n";
+                out << "if (_hidl_cb != nullptr) {\n";
                 out.indent();
-                out << "_aidl_cb(";
+                out << "_hidl_cb(";
 
                 bool first = true;
                 for (const auto &arg : method->results()) {
@@ -681,10 +681,10 @@
             }
 
             out.unindent();
-            out << "_aidl_error:\n";
+            out << "_hidl_error:\n";
             out.indent();
-            out << "_aidl_status.setFromStatusT(_aidl_err);\n"
-                      << "return _aidl_status;\n";
+            out << "_hidl_status.setFromStatusT(_hidl_err);\n"
+                      << "return _hidl_status;\n";
 
             out.unindent();
             out << "}\n\n";
@@ -711,17 +711,17 @@
     out.indent();
     out.indent();
 
-    out << "uint32_t _aidl_code,\n"
-        << "const ::android::hardware::Parcel &_aidl_data,\n"
-        << "::android::hardware::Parcel *_aidl_reply,\n"
-        << "uint32_t _aidl_flags,\n"
-        << "TransactCallback _aidl_cb) {\n";
+    out << "uint32_t _hidl_code,\n"
+        << "const ::android::hardware::Parcel &_hidl_data,\n"
+        << "::android::hardware::Parcel *_hidl_reply,\n"
+        << "uint32_t _hidl_flags,\n"
+        << "TransactCallback _hidl_cb) {\n";
 
     out.unindent();
 
-    out << "::android::status_t _aidl_err = ::android::OK;\n\n";
+    out << "::android::status_t _hidl_err = ::android::OK;\n\n";
 
-    out << "switch (_aidl_code) {\n";
+    out << "switch (_hidl_code) {\n";
     out.indent();
 
     const Interface *iface = mRootScope->getInterface();
@@ -766,8 +766,8 @@
     out.indent();
     out.indent();
 
-    out << "_aidl_code, _aidl_data, _aidl_reply, "
-        << "_aidl_flags, _aidl_cb);\n";
+    out << "_hidl_code, _hidl_data, _hidl_reply, "
+        << "_hidl_flags, _hidl_cb);\n";
 
     out.unindent();
     out.unindent();
@@ -778,15 +778,15 @@
     out.unindent();
     out << "}\n\n";
 
-    out << "if (_aidl_err == ::android::UNEXPECTED_NULL) {\n";
+    out << "if (_hidl_err == ::android::UNEXPECTED_NULL) {\n";
     out.indent();
-    out << "_aidl_err = ::android::hardware::Status::fromExceptionCode(\n";
+    out << "_hidl_err = ::android::hardware::Status::fromExceptionCode(\n";
     out.indent();
     out.indent();
     out << "::android::hardware::Status::EX_NULL_POINTER)\n";
     out.indent();
     out.indent();
-    out << ".writeToParcel(_aidl_reply);\n";
+    out << ".writeToParcel(_hidl_reply);\n";
     out.unindent();
     out.unindent();
     out.unindent();
@@ -795,7 +795,7 @@
     out.unindent();
     out << "}\n\n";
 
-    out << "return _aidl_err;\n";
+    out << "return _hidl_err;\n";
 
     out.unindent();
     out << "}\n\n";
@@ -805,12 +805,12 @@
 
 status_t AST::generateStubSourceForMethod(
         Formatter &out, const Interface *iface, const Method *method) const {
-    out << "if (!_aidl_data.enforceInterface("
+    out << "if (!_hidl_data.enforceInterface("
         << iface->fullName()
         << "::getInterfaceDescriptor())) {\n";
 
     out.indent();
-    out << "_aidl_err = ::android::BAD_TYPE;\n";
+    out << "_hidl_err = ::android::BAD_TYPE;\n";
     out << "break;\n";
     out.unindent();
     out << "}\n\n";
@@ -818,7 +818,7 @@
     for (const auto &arg : method->args()) {
         emitCppReaderWriter(
                 out,
-                "_aidl_data",
+                "_hidl_data",
                 false /* parcelObjIsPointer */,
                 arg,
                 true /* reader */,
@@ -828,10 +828,10 @@
     const bool returnsValue = !method->results().empty();
 
     if (returnsValue) {
-        out << "bool _aidl_callbackCalled = false;\n\n";
+        out << "bool _hidl_callbackCalled = false;\n\n";
     }
 
-    out << "::android::hardware::Status _aidl_status(\n";
+    out << "::android::hardware::Status _hidl_status(\n";
     out.indent();
     out.indent();
     out << method->name() << "(";
@@ -871,22 +871,22 @@
 
         out << ") {\n";
         out.indent();
-        out << "_aidl_callbackCalled = true;\n\n";
+        out << "_hidl_callbackCalled = true;\n\n";
 
         out << "::android::hardware::Status::ok()"
-                  << ".writeToParcel(_aidl_reply);\n\n";
+                  << ".writeToParcel(_hidl_reply);\n\n";
 
         for (const auto &arg : method->results()) {
             emitCppReaderWriter(
                     out,
-                    "_aidl_reply",
+                    "_hidl_reply",
                     true /* parcelObjIsPointer */,
                     arg,
                     false /* reader */,
                     Type::ErrorMode_Ignore);
         }
 
-        out << "_aidl_cb(*_aidl_reply);\n";
+        out << "_hidl_cb(*_hidl_reply);\n";
 
         out.unindent();
         out << "}\n";
@@ -897,11 +897,11 @@
     out << "));\n\n";
 
     if (returnsValue) {
-        out << "if (!_aidl_callbackCalled) {\n";
+        out << "if (!_hidl_callbackCalled) {\n";
         out.indent();
     }
 
-    out << "_aidl_err = _aidl_status.writeToParcel(_aidl_reply);\n";
+    out << "_hidl_err = _hidl_status.writeToParcel(_hidl_reply);\n";
 
     if (returnsValue) {
         out.unindent();