mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
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>
This commit is contained in:
parent
e112189800
commit
b1a8cb2fbf
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user