Added knowledge of namespacing into generation.

This is the first step in making code aware of namespacing. Currently,
the solution to generate symbols which are properly namespaced is to
post-process text after it is being outputed by a Formatter. Ideally
objects will know what namespace they are in and be able to print
themselves out accordingly. This change specifically will allow
generated code to remove namespaces from symbols that don't need
to be qualified entirely without relying on post-processing to remove
the namespace.

Change-Id: Ie535d05a64eb3d6c7d3b5451abdaa289c574170f
diff --git a/generateCpp.cpp b/generateCpp.cpp
index 9cfb938..3668fd6 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -224,7 +224,8 @@
             out << "using "
                 << method->name()
                 << "_cb = std::function<void("
-                << Method::GetArgSignature(method->results())
+                << Method::GetArgSignature(method->results(),
+                                           true /* specify namespaces */)
                 << ")>;\n";
         }
 
@@ -248,7 +249,8 @@
 
             out << method->name()
                 << "("
-                << Method::GetArgSignature(method->args());
+                << Method::GetArgSignature(method->args(),
+                                           true /* specify namespaces */);
 
             if (returnsValue && elidedReturn == nullptr) {
                 if (!method->args().empty()) {
@@ -415,10 +417,13 @@
 
 status_t AST::generateStubMethod(Formatter &out,
                                  const std::string &className,
-                                 const Method *method) const {
+                                 const Method *method,
+                                 bool specifyNamespaces) const {
     out << "inline ";
 
-    method->generateCppSignature(out, className);
+    method->generateCppSignature(out,
+                                 className,
+                                 specifyNamespaces);
 
     const bool returnsValue = !method->results().empty();
     const TypedVar *elidedReturn = method->canElideCallback();
@@ -453,9 +458,12 @@
 
 status_t AST::generateProxyMethod(Formatter &out,
                                   const std::string &className,
-                                  const Method *method) const {
+                                  const Method *method,
+                                  bool specifyNamespaces) const {
 
-    method->generateCppSignature(out, className);
+    method->generateCppSignature(out,
+                                 className,
+                                 specifyNamespaces);
     out << " override;\n";
 
     return OK;
@@ -464,7 +472,8 @@
 status_t AST::generateMethods(
         Formatter &out,
         const std::string &className,
-        MethodLocation type) const {
+        MethodLocation type,
+        bool specifyNamespaces) const {
 
     const Interface *iface = mRootScope->getInterface();
 
@@ -487,12 +496,14 @@
                 case STUB_HEADER:
                     err = generateStubMethod(out,
                                              className,
-                                             method);
+                                             method,
+                                             specifyNamespaces);
                     break;
                 case PROXY_HEADER:
                     err = generateProxyMethod(out,
                                               className,
-                                              method);
+                                              method,
+                                              specifyNamespaces);
                     break;
                 default:
                     err = UNKNOWN_ERROR;
@@ -578,7 +589,8 @@
 
     generateMethods(out,
                     "" /* class name */,
-                    MethodLocation::STUB_HEADER);
+                    MethodLocation::STUB_HEADER,
+                    true /* specify namespaces */);
     out.unindent();
 
     out << "};\n\n";
@@ -652,7 +664,8 @@
 
     generateMethods(out,
                     "" /* class name */,
-                    MethodLocation::PROXY_HEADER);
+                    MethodLocation::PROXY_HEADER,
+                    true /* generate specify namespaces */);
 
     out.unindent();
 
@@ -816,7 +829,9 @@
         const Interface *superInterface = *it;
 
         for (const auto &method : superInterface->methods()) {
-            method->generateCppSignature(out, klassName);
+            method->generateCppSignature(out,
+                                         klassName,
+                                         true /* specify namespaces */);
 
             const bool returnsValue = !method->results().empty();
             const TypedVar *elidedReturn = method->canElideCallback();