Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using namespace support #22

Open
agladilin opened this issue Jun 20, 2023 · 0 comments
Open

using namespace support #22

agladilin opened this issue Jun 20, 2023 · 0 comments

Comments

@agladilin
Copy link

agladilin commented Jun 20, 2023

Could you add the code below in order to support the using namespace directive?

diff --git a/pub/cppwriter.h b/pub/cppwriter.h
index 5b9e3a81..e2541d48 100644
--- a/pub/cppwriter.h
+++ b/pub/cppwriter.h
@@ -66,6 +66,9 @@ public:
   virtual void emitUsingDecl(const CppUsingDecl* usingDecl,
                              std::ostream&       stm,
                              CppIndent           indentation = CppIndent()) const;
+  virtual void emitUsingNamespaceDecl(const CppUsingNamespaceDecl* usingDecl,
+                                      std::ostream&                stm,
+                                      CppIndent                    indentation = CppIndent()) const;
   virtual void emitTypedefList(const CppTypedefList* typedefList,
                                std::ostream&         stm,
                                CppIndent             indentation = CppIndent()) const;
diff --git a/src/cppwriter.cpp b/src/cppwriter.cpp
index 89034bcd..2ed6a738 100644
--- a/src/cppwriter.cpp
+++ b/src/cppwriter.cpp
@@ -106,6 +106,8 @@ void CppWriter::emit(const CppObj* cppObj, std::ostream& stm, CppIndent indentat
       return emitDocComment((CppDocComment*) cppObj, stm, indentation);
     case CppObjType::kUsingDecl:
       return emitUsingDecl((CppUsingDecl*) cppObj, stm, indentation);
+    case CppObjType::kUsingNamespaceDecl:
+      return emitUsingNamespaceDecl((CppUsingNamespaceDecl*) cppObj, stm, indentation);
     case CppObjType::kTypedefName:
       return emitTypedef((CppTypedefName*) cppObj, stm, indentation);
     case CppObjType::kTypedefNameList:
@@ -411,6 +413,13 @@ void CppWriter::emitUsingDecl(const CppUsingDecl* usingDecl,
   stm << ";\n";
 }
 
+void CppWriter::emitUsingNamespaceDecl(const CppUsingNamespaceDecl* usingDecl,
+                                       std::ostream&                stm,
+                                       CppIndent                    indentation /* = CppIndent()*/) const
+{
+  stm << indentation << "using namespace " << usingDecl->name_ << ";\n";
+}
+
 void CppWriter::emitTypedefList(const CppTypedefList* typedefList,
                                 std::ostream&         stm,
                                 CppIndent             indentation /* = CppIndent()*/) const
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant