]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: libproc_macro: Remove internal named namespaces
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 25 Apr 2023 11:19:00 +0000 (13:19 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:16 +0000 (18:34 +0100)
Either move the elements from their namespace up to the procmacro
namespace or make the namespace anonymous.

libgrust/ChangeLog:

* libproc_macro/group.cc (Group::make_group): Remove
internal namespace.
(Group::drop): Likewise.
* libproc_macro/group.h (enum Delimiter): Make members
upercase.
(struct Group):
* libproc_macro/ident.cc (Ident::drop): Remove internal
namespace.
* libproc_macro/ident.h (Ident__clone): Likewise.
* libproc_macro/literal.cc (Literal::make_isize):
Likewise.
* libproc_macro/literal.h (union LiteralPayload):
Likewise.
(Literal__from_string): Likewise.
* libproc_macro/punct.cc (Punct::make_punct): Likewise.
* libproc_macro/punct.h (enum Spacing): Make members
uppercase.
* libproc_macro/tokenstream.cc (TokenStream::make_tokenstream):
Remove internal namespace.
(TokenStream::grow): Likewise.
(TokenStream::push): Likewise.
(TokenSream__push): Likewise.
(TokenStream__clone): Likewise.
(TokenStream__drop): Likewise.
* libproc_macro/tokenstream.h (struct TokenStream):
Likewise.
(TokenSream__push): Likewise.
(TokenStream__drop): Likewise.
* libproc_macro/tokentree.cc (TokenTree::make_tokentree):
Likewise.
(TokenTree::drop): Likewise.
* libproc_macro/tokentree.h (union TokenTreePayload):
Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
12 files changed:
libgrust/libproc_macro/group.cc
libgrust/libproc_macro/group.h
libgrust/libproc_macro/ident.cc
libgrust/libproc_macro/ident.h
libgrust/libproc_macro/literal.cc
libgrust/libproc_macro/literal.h
libgrust/libproc_macro/punct.cc
libgrust/libproc_macro/punct.h
libgrust/libproc_macro/tokenstream.cc
libgrust/libproc_macro/tokenstream.h
libgrust/libproc_macro/tokentree.cc
libgrust/libproc_macro/tokentree.h

index 9394387f6367a54ba270d7a8e845dbbb71677382..74c1959800e6167af7e843bfae5a8fd20c2710df 100644 (file)
 #include "group.h"
 
 namespace ProcMacro {
-namespace Group {
 
 Group
-Group::make_group (TokenStream::TokenStream stream, Delimiter delim)
+Group::make_group (TokenStream stream, Delimiter delim)
 {
   return {delim, stream};
 }
@@ -37,5 +36,4 @@ Group::drop (Group *g)
   TokenStream::TokenStream::drop (&g->stream);
 }
 
-} // namespace Group
 } // namespace ProcMacro
index 51913253550dc1297aea120bcb1a8933d26c01cf..26680b07848b8c0e718123ad3c920bb2b790c926 100644 (file)
 #include "tokenstream.h"
 
 namespace ProcMacro {
-namespace Group {
 
 enum Delimiter
 {
-  Parenthesis,
-  Brace,
-  Bracket,
-  None,
+  PARENTHESIS,
+  BRACE,
+  BRACKET,
+  NONE,
 };
 
 struct Group
 {
   Delimiter delimiter;
-  TokenStream::TokenStream stream;
+  TokenStream stream;
 
 public:
-  static Group make_group (TokenStream::TokenStream stream, Delimiter delim);
+  static Group make_group (TokenStream stream, Delimiter delim);
 
   static void drop (Group *g);
 };
 
-} // namespace Group
 } // namespace ProcMacro
 
 #endif /* ! GROUP_H */
index 6fe8676d45f17981600f7405529dd848c0e9d4a5..c21483605ff30c265778a3cce2cb0418adde1b82 100644 (file)
@@ -24,7 +24,6 @@
 #include <cstring>
 
 namespace ProcMacro {
-namespace Ident {
 
 extern "C" {
 
@@ -84,5 +83,4 @@ Ident::drop (Ident *ident)
   ident->len = 0;
 }
 
-} // namespace Ident
 } // namespace ProcMacro
index 0c89185f30669bd8e8a1fb8a8bf98a88ec7dc983..82a154c20ccc2340a3626c86d61997193b5c8dc1 100644 (file)
@@ -27,7 +27,6 @@
 #include <string>
 
 namespace ProcMacro {
-namespace Ident {
 
 struct Ident
 {
@@ -61,7 +60,6 @@ Ident
 Ident__clone (const Ident *ident);
 }
 
-} // namespace Ident
 } // namespace ProcMacro
 
 #endif /* ! IDENT_H */
index 13b97a9417d50f0a746d5080f5c3e0b5024477f4..39474ce3120afac93b06a9da56dabbd4330726e3 100644 (file)
@@ -25,7 +25,6 @@
 #include <cstdlib>
 
 namespace ProcMacro {
-namespace Literal {
 
 void
 Literal::drop (Literal *lit)
@@ -289,5 +288,4 @@ Literal::make_isize (std::int64_t value, bool suffixed)
   return {ISIZE, payload};
 }
 
-} // namespace Literal
 } // namespace ProcMacro
index 15d40e066202b502da86ba457e0888d906ecf264..f48b534e3f0383083567a966f1e016ba681565d9 100644 (file)
@@ -28,7 +28,6 @@
 #include <vector>
 
 namespace ProcMacro {
-namespace Literal {
 enum UnsignedTag
 {
   UNSIGNED_8,
@@ -187,10 +186,11 @@ public:
   static Literal make_usize (std::uint64_t value, bool suffixed = false);
   static Literal make_isize (std::int64_t value, bool suffixed = false);
 
+  static void drop (Literal *lit);
+
+private:
   static Literal make_unsigned (UnsignedSuffixPayload p);
   static Literal make_signed (SignedSuffixPayload p);
-
-  static void drop (Literal *lit);
 };
 
 extern "C" {
@@ -207,7 +207,6 @@ bool
 Literal__from_string (const unsigned char *str, std::uint64_t len,
                      Literal *lit);
 }
-} // namespace Literal
 } // namespace ProcMacro
 
 #endif /* ! LITERAL_H */
index 762d6424f94bbd351e0e8091782f4a5cec6c3df8..78d25f9ebdb92a9363897eae05544471fea89d6a 100644 (file)
@@ -24,7 +24,6 @@
 #include <cstdlib>
 
 namespace ProcMacro {
-namespace Punct {
 
 Punct
 Punct::make_punct (std::uint32_t ch, Spacing spacing)
@@ -32,5 +31,4 @@ Punct::make_punct (std::uint32_t ch, Spacing spacing)
   return {ch, spacing};
 }
 
-} // namespace Punct
 } // namespace ProcMacro
index b9098b1e279e7a902e61bed5ced36d56fa3d6ef2..f3a1c1bd1ecb7f249d560b1e38063e141dba6aa1 100644 (file)
 #include <cstdint>
 
 namespace ProcMacro {
-namespace Punct {
 
 enum Spacing
 {
-  Alone,
-  Joint
+  ALONE,
+  JOINT
 };
 
 struct Punct
@@ -40,10 +39,9 @@ struct Punct
   Spacing spacing;
 
 public:
-  static Punct make_punct (std::uint32_t ch, Spacing spacing = Spacing::Alone);
+  static Punct make_punct (std::uint32_t ch, Spacing spacing = Spacing::ALONE);
 };
 
-} // namespace Punct
 } // namespace ProcMacro
 
 #endif /* ! PUNCT_H */
index 68e72666691532bb60ea7a224e435c304cb8e93b..12d454316012b0abe26786e0e56989fa117aff22 100644 (file)
 #include <cstring>
 
 namespace ProcMacro {
-namespace TokenStream {
 
 TokenStream
-TokenStream::make_tokenstream (std::vector<TokenTree::TokenTree> vec)
+TokenStream::make_tokenstream (std::vector<TokenTree> vec)
 {
   auto stream = make_tokenstream (vec.size ());
   for (auto tt : vec)
@@ -42,7 +41,7 @@ TokenStream::make_tokenstream (std::vector<TokenTree::TokenTree> vec)
 TokenStream
 TokenStream::make_tokenstream (std::uint64_t capacity)
 {
-  auto *data = new TokenTree::TokenTree[capacity];
+  auto *data = new TokenTree[capacity];
   return {data, 0, capacity};
 }
 
@@ -50,14 +49,14 @@ void
 TokenStream::grow (std::uint64_t delta)
 {
   auto new_capacity = capacity + delta;
-  auto *new_data = new TokenTree::TokenTree[new_capacity];
+  auto *new_data = new TokenTree[new_capacity];
   std::memcpy (new_data, data, size);
   delete[] data;
   data = new_data;
 }
 
 void
-TokenStream::push (TokenTree::TokenTree tree)
+TokenStream::push (TokenTree tree)
 {
   if (size == capacity)
     grow (capacity);
@@ -90,7 +89,7 @@ TokenStream__with_capacity (std::uint64_t capacity)
 }
 
 extern "C" void
-TokenSream__push (TokenStream *stream, TokenTree::TokenTree tree)
+TokenSream__push (TokenStream *stream, TokenTree tree)
 {
   stream->push (tree);
 }
@@ -106,7 +105,7 @@ TokenStream__from_string (unsigned char *str, std::uint64_t len,
 extern "C" TokenStream
 TokenStream__clone (const TokenStream *ts)
 {
-  auto *data = new TokenTree::TokenTree[ts->capacity];
+  auto *data = new TokenTree[ts->capacity];
   std::memcpy (data, ts->data, ts->size);
   return {data, ts->size, ts->capacity};
 }
@@ -117,5 +116,4 @@ TokenStream__drop (TokenStream *stream)
   TokenStream::drop (stream);
 }
 
-} // namespace TokenStream
 } // namespace ProcMacro
index ac88f8047e3c1361bdefea261eefd6d43028fad5..2c2231d5cdad1c4746cdeb58ca059e0d71315424 100644 (file)
 #include <vector>
 
 namespace ProcMacro {
-namespace TokenTree {
 struct TokenTree;
-}
-
-namespace TokenStream {
-
-const std::int64_t DEFAULT_CAPACITY = 0;
 
 struct TokenStream
 {
-  TokenTree::TokenTree *data;
+  TokenTree *data;
   std::uint64_t size;
   std::uint64_t capacity;
 
 public:
   void grow (std::uint64_t delta);
-  void push (TokenTree::TokenTree tree);
+  void push (TokenTree tree);
 
   TokenStream clone () const;
 
-  static TokenStream make_tokenstream (std::vector<TokenTree::TokenTree> vec);
-  static TokenStream make_tokenstream (std::uint64_t capacity
-                                      = DEFAULT_CAPACITY);
+  static TokenStream make_tokenstream (std::vector<TokenTree> vec);
+  static TokenStream make_tokenstream (std::uint64_t capacity = 1);
 
   static void drop (TokenStream *stream);
 };
@@ -61,7 +54,7 @@ extern "C" TokenStream
 TokenStream__with_capacity (std::uint64_t capacity);
 
 extern "C" void
-TokenSream__push (TokenStream *stream, TokenTree::TokenTree tree);
+TokenSream__push (TokenStream *stream, TokenTree tree);
 
 extern "C" bool
 TokenStream__from_string (unsigned char *str, std::uint64_t len,
@@ -73,7 +66,6 @@ TokenStream__clone (const TokenStream *ts);
 extern "C" void
 TokenStream__drop (TokenStream *stream);
 
-} // namespace TokenStream
 } // namespace ProcMacro
 
 #endif /* ! TOKENSTREAM_H */
index 408828ba1f2e96de5dbaf584a816e91dac14e59c..b034a8c33e2e912565ad4938f6c5d63ff0cf09b3 100644 (file)
 #include "tokentree.h"
 
 namespace ProcMacro {
-namespace TokenTree {
 
 TokenTree
-TokenTree::make_tokentree (Group::Group group)
+TokenTree::make_tokentree (Group group)
 {
   TokenTreePayload payload;
   payload.group = group;
@@ -34,7 +33,7 @@ TokenTree::make_tokentree (Group::Group group)
 }
 
 TokenTree
-TokenTree::make_tokentree (Ident::Ident ident)
+TokenTree::make_tokentree (Ident ident)
 {
   TokenTreePayload payload;
   payload.ident = ident;
@@ -42,7 +41,7 @@ TokenTree::make_tokentree (Ident::Ident ident)
 }
 
 TokenTree
-TokenTree::make_tokentree (Punct::Punct punct)
+TokenTree::make_tokentree (Punct punct)
 {
   TokenTreePayload payload;
   payload.punct = punct;
@@ -50,7 +49,7 @@ TokenTree::make_tokentree (Punct::Punct punct)
 }
 
 TokenTree
-TokenTree::make_tokentree (Literal::Literal literal)
+TokenTree::make_tokentree (Literal literal)
 {
   TokenTreePayload payload;
   payload.literal = literal;
@@ -76,5 +75,4 @@ TokenTree::drop (TokenTree *tt)
     }
 }
 
-} // namespace TokenTree
 } // namespace ProcMacro
index ada1557efd9e1e18737a2b5edf32aa3170840281..1a50ecf34474ae1cee2c12f4d17fc7942b978495 100644 (file)
@@ -29,7 +29,6 @@
 #include "literal.h"
 
 namespace ProcMacro {
-namespace TokenTree {
 
 enum TokenTreeTag
 {
@@ -41,10 +40,10 @@ enum TokenTreeTag
 
 union TokenTreePayload
 {
-  Group::Group group;
-  Ident::Ident ident;
-  Punct::Punct punct;
-  Literal::Literal literal;
+  Group group;
+  Ident ident;
+  Punct punct;
+  Literal literal;
 };
 
 struct TokenTree
@@ -53,15 +52,14 @@ struct TokenTree
   TokenTreePayload payload;
 
 public:
-  static TokenTree make_tokentree (Group::Group group);
-  static TokenTree make_tokentree (Ident::Ident ident);
-  static TokenTree make_tokentree (Punct::Punct punct);
-  static TokenTree make_tokentree (Literal::Literal literal);
+  static TokenTree make_tokentree (Group group);
+  static TokenTree make_tokentree (Ident ident);
+  static TokenTree make_tokentree (Punct punct);
+  static TokenTree make_tokentree (Literal literal);
 
   static void drop (TokenTree *tt);
 };
 
-} // namespace TokenTree
 } // namespace ProcMacro
 
 #endif /* ! TOKENTREE_H */