From 76394af71ad4f3dcef4df6e7451a2d5f8d5dd2fe Mon Sep 17 00:00:00 2001
From: Mike Lischke
Date: Wed, 19 Apr 2017 14:13:01 +0200
Subject: [PATCH] Channel parameter in c-tor is now a size_t - fixes #1827.
A bit cleanup on the way.
---
runtime/Cpp/runtime/src/CommonTokenStream.cpp | 11 ++----
runtime/Cpp/runtime/src/CommonTokenStream.h | 34 ++++++++-----------
2 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/runtime/Cpp/runtime/src/CommonTokenStream.cpp b/runtime/Cpp/runtime/src/CommonTokenStream.cpp
index 9a28847a1..3d9ec9bf2 100755
--- a/runtime/Cpp/runtime/src/CommonTokenStream.cpp
+++ b/runtime/Cpp/runtime/src/CommonTokenStream.cpp
@@ -9,12 +9,11 @@
using namespace antlr4;
-CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : BufferedTokenStream(tokenSource) {
- InitializeInstanceFields();
+CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : CommonTokenStream(tokenSource, Token::DEFAULT_CHANNEL) {
}
-CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, int channel) : BufferedTokenStream(tokenSource) {
- this->channel = channel;
+CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel)
+: BufferedTokenStream(tokenSource), channel(channel) {
}
ssize_t CommonTokenStream::adjustSeekIndex(size_t i) {
@@ -77,7 +76,3 @@ int CommonTokenStream::getNumberOfOnChannelTokens() {
}
return n;
}
-
-void CommonTokenStream::InitializeInstanceFields() {
- channel = Token::DEFAULT_CHANNEL;
-}
diff --git a/runtime/Cpp/runtime/src/CommonTokenStream.h b/runtime/Cpp/runtime/src/CommonTokenStream.h
index 384017bd0..628a986f7 100755
--- a/runtime/Cpp/runtime/src/CommonTokenStream.h
+++ b/runtime/Cpp/runtime/src/CommonTokenStream.h
@@ -34,16 +34,6 @@ namespace antlr4 {
* channel.
*/
class ANTLR4CPP_PUBLIC CommonTokenStream : public BufferedTokenStream {
- protected:
- /**
- * Specifies the channel to use for filtering tokens.
- *
- *
- * The default value is {@link Token#DEFAULT_CHANNEL}, which matches the
- * default channel assigned to tokens created by the lexer.
- */
- size_t channel;
-
public:
/**
* Constructs a new {@link CommonTokenStream} using the specified token
@@ -63,21 +53,27 @@ namespace antlr4 {
* @param tokenSource The token source.
* @param channel The channel to use for filtering tokens.
*/
- CommonTokenStream(TokenSource *tokenSource, int channel);
+ CommonTokenStream(TokenSource *tokenSource, size_t channel);
- protected:
- virtual ssize_t adjustSeekIndex(size_t i) override;
-
- virtual Token* LB(size_t k) override;
-
- public:
virtual Token* LT(ssize_t k) override;
/// Count EOF just once.
virtual int getNumberOfOnChannelTokens();
+
+ protected:
+ /**
+ * Specifies the channel to use for filtering tokens.
+ *
+ *
+ * The default value is {@link Token#DEFAULT_CHANNEL}, which matches the
+ * default channel assigned to tokens created by the lexer.
+ */
+ size_t channel;
+
+ virtual ssize_t adjustSeekIndex(size_t i) override;
+
+ virtual Token* LB(size_t k) override;
- private:
- void InitializeInstanceFields();
};
} // namespace antlr4