aboutsummaryrefslogtreecommitdiff
path: root/libgrust
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-04-25 13:19:00 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:34:16 +0100
commitb1a8cb2fbf63f9579c96e26fdac3ce611461c58b (patch)
tree7a4eacad717a24dbf6e7dee69100345a7167e168 /libgrust
parente112189800b7af8e1c3ef35f8de55c0c58dec740 (diff)
gccrs: libproc_macro: Remove internal named namespaces
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>
Diffstat (limited to 'libgrust')
-rw-r--r--libgrust/libproc_macro/group.cc4
-rw-r--r--libgrust/libproc_macro/group.h14
-rw-r--r--libgrust/libproc_macro/ident.cc2
-rw-r--r--libgrust/libproc_macro/ident.h2
-rw-r--r--libgrust/libproc_macro/literal.cc2
-rw-r--r--libgrust/libproc_macro/literal.h7
-rw-r--r--libgrust/libproc_macro/punct.cc2
-rw-r--r--libgrust/libproc_macro/punct.h8
-rw-r--r--libgrust/libproc_macro/tokenstream.cc14
-rw-r--r--libgrust/libproc_macro/tokenstream.h18
-rw-r--r--libgrust/libproc_macro/tokentree.cc10
-rw-r--r--libgrust/libproc_macro/tokentree.h18
12 files changed, 36 insertions, 65 deletions
diff --git a/libgrust/libproc_macro/group.cc b/libgrust/libproc_macro/group.cc
index 9394387f636..74c1959800e 100644
--- a/libgrust/libproc_macro/group.cc
+++ b/libgrust/libproc_macro/group.cc
@@ -23,10 +23,9 @@
#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
diff --git a/libgrust/libproc_macro/group.h b/libgrust/libproc_macro/group.h
index 51913253550..26680b07848 100644
--- a/libgrust/libproc_macro/group.h
+++ b/libgrust/libproc_macro/group.h
@@ -26,28 +26,26 @@
#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 */
diff --git a/libgrust/libproc_macro/ident.cc b/libgrust/libproc_macro/ident.cc
index 6fe8676d45f..c21483605ff 100644
--- a/libgrust/libproc_macro/ident.cc
+++ b/libgrust/libproc_macro/ident.cc
@@ -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
diff --git a/libgrust/libproc_macro/ident.h b/libgrust/libproc_macro/ident.h
index 0c89185f306..82a154c20cc 100644
--- a/libgrust/libproc_macro/ident.h
+++ b/libgrust/libproc_macro/ident.h
@@ -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 */
diff --git a/libgrust/libproc_macro/literal.cc b/libgrust/libproc_macro/literal.cc
index 13b97a9417d..39474ce3120 100644
--- a/libgrust/libproc_macro/literal.cc
+++ b/libgrust/libproc_macro/literal.cc
@@ -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
diff --git a/libgrust/libproc_macro/literal.h b/libgrust/libproc_macro/literal.h
index 15d40e06620..f48b534e3f0 100644
--- a/libgrust/libproc_macro/literal.h
+++ b/libgrust/libproc_macro/literal.h
@@ -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 */
diff --git a/libgrust/libproc_macro/punct.cc b/libgrust/libproc_macro/punct.cc
index 762d6424f94..78d25f9ebdb 100644
--- a/libgrust/libproc_macro/punct.cc
+++ b/libgrust/libproc_macro/punct.cc
@@ -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
diff --git a/libgrust/libproc_macro/punct.h b/libgrust/libproc_macro/punct.h
index b9098b1e279..f3a1c1bd1ec 100644
--- a/libgrust/libproc_macro/punct.h
+++ b/libgrust/libproc_macro/punct.h
@@ -26,12 +26,11 @@
#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 */
diff --git a/libgrust/libproc_macro/tokenstream.cc b/libgrust/libproc_macro/tokenstream.cc
index 68e72666691..12d45431601 100644
--- a/libgrust/libproc_macro/tokenstream.cc
+++ b/libgrust/libproc_macro/tokenstream.cc
@@ -26,10 +26,9 @@
#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
diff --git a/libgrust/libproc_macro/tokenstream.h b/libgrust/libproc_macro/tokenstream.h
index ac88f8047e3..2c2231d5cda 100644
--- a/libgrust/libproc_macro/tokenstream.h
+++ b/libgrust/libproc_macro/tokenstream.h
@@ -27,29 +27,22 @@
#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 */
diff --git a/libgrust/libproc_macro/tokentree.cc b/libgrust/libproc_macro/tokentree.cc
index 408828ba1f2..b034a8c33e2 100644
--- a/libgrust/libproc_macro/tokentree.cc
+++ b/libgrust/libproc_macro/tokentree.cc
@@ -23,10 +23,9 @@
#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
diff --git a/libgrust/libproc_macro/tokentree.h b/libgrust/libproc_macro/tokentree.h
index ada1557efd9..1a50ecf3447 100644
--- a/libgrust/libproc_macro/tokentree.h
+++ b/libgrust/libproc_macro/tokentree.h
@@ -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 */