diff --git a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp index 4b0a4d751f..6085efca8a 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp +++ b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp @@ -31,20 +31,8 @@ using namespace antlr4; using namespace antlr4::atn; using namespace antlrcpp; -LexerATNSimulator::SimState::~SimState() { -} - void LexerATNSimulator::SimState::reset() { - index = INVALID_INDEX; - line = 0; - charPos = INVALID_INDEX; - dfaState = nullptr; // Don't delete. It's just a reference. -} - -void LexerATNSimulator::SimState::InitializeInstanceFields() { - index = INVALID_INDEX; - line = 0; - charPos = INVALID_INDEX; + *this = SimState(); } LexerATNSimulator::LexerATNSimulator(const ATN &atn, std::vector &decisionToDFA, diff --git a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h index 1f4b999fc6..678fe0d438 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h +++ b/runtime/Cpp/runtime/src/atn/LexerATNSimulator.h @@ -17,27 +17,14 @@ namespace atn { /// "dup" of ParserInterpreter class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator { protected: - class SimState { - public: - virtual ~SimState(); - - protected: - size_t index; - size_t line; - size_t charPos; - dfa::DFAState *dfaState; - virtual void reset(); - friend class LexerATNSimulator; - - private: - void InitializeInstanceFields(); - - public: - SimState() { - InitializeInstanceFields(); - } - }; + struct ANTLR4CPP_PUBLIC SimState final { + size_t index = INVALID_INDEX; + size_t line = 0; + size_t charPos = INVALID_INDEX; + dfa::DFAState *dfaState = nullptr; + void reset(); + }; public: static constexpr size_t MIN_DFA_EDGE = 0; diff --git a/runtime/Cpp/runtime/src/dfa/DFAState.h b/runtime/Cpp/runtime/src/dfa/DFAState.h index fddf4e80e2..5a43ccac55 100755 --- a/runtime/Cpp/runtime/src/dfa/DFAState.h +++ b/runtime/Cpp/runtime/src/dfa/DFAState.h @@ -37,7 +37,7 @@ namespace dfa { /// class ANTLR4CPP_PUBLIC DFAState final { public: - class PredPrediction final { + class ANTLR4CPP_PUBLIC PredPrediction final { public: Ref pred; // never null; at least SemanticContext.NONE int alt; diff --git a/runtime/Cpp/runtime/src/support/CPPUtils.h b/runtime/Cpp/runtime/src/support/CPPUtils.h index 48f1bbb66d..2eb1a36037 100644 --- a/runtime/Cpp/runtime/src/support/CPPUtils.h +++ b/runtime/Cpp/runtime/src/support/CPPUtils.h @@ -5,20 +5,18 @@ #pragma once -#include - #include "antlr4-common.h" namespace antlrcpp { - std::string join(const std::vector &strings, const std::string &separator); - std::map toMap(const std::vector &keys); - std::string escapeWhitespace(std::string str, bool escapeSpaces); - std::string toHexString(const int t); - std::string arrayToString(const std::vector &data); - std::string replaceString(const std::string &s, const std::string &from, const std::string &to); - std::vector split(const std::string &s, const std::string &sep, int count); - std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true); + ANTLR4CPP_PUBLIC std::string join(const std::vector &strings, const std::string &separator); + ANTLR4CPP_PUBLIC std::map toMap(const std::vector &keys); + ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string str, bool escapeSpaces); + ANTLR4CPP_PUBLIC std::string toHexString(const int t); + ANTLR4CPP_PUBLIC std::string arrayToString(const std::vector &data); + ANTLR4CPP_PUBLIC std::string replaceString(const std::string &s, const std::string &from, const std::string &to); + ANTLR4CPP_PUBLIC std::vector split(const std::string &s, const std::string &sep, int count); + ANTLR4CPP_PUBLIC std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true); // Using RAII + a lambda to implement a "finally" replacement. template @@ -62,6 +60,6 @@ namespace antlrcpp { } // Get the error text from an exception pointer or the current exception. - std::string what(std::exception_ptr eptr = std::current_exception()); + ANTLR4CPP_PUBLIC std::string what(std::exception_ptr eptr = std::current_exception()); } // namespace antlrcpp diff --git a/runtime/Cpp/runtime/src/support/StringUtils.h b/runtime/Cpp/runtime/src/support/StringUtils.h index 24923049ab..aee0d46d6e 100644 --- a/runtime/Cpp/runtime/src/support/StringUtils.h +++ b/runtime/Cpp/runtime/src/support/StringUtils.h @@ -9,8 +9,8 @@ namespace antlrcpp { - std::string escapeWhitespace(std::string_view in); + ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in); - std::string& escapeWhitespace(std::string& out, std::string_view in); + ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in); } diff --git a/runtime/Cpp/runtime/src/support/Unicode.h b/runtime/Cpp/runtime/src/support/Unicode.h index f847ce2462..f0f84375ad 100644 --- a/runtime/Cpp/runtime/src/support/Unicode.h +++ b/runtime/Cpp/runtime/src/support/Unicode.h @@ -5,9 +5,11 @@ #pragma once +#include "antlr4-common.h" + namespace antlrcpp { - class Unicode final { + class ANTLR4CPP_PUBLIC Unicode final { public: static constexpr char32_t REPLACEMENT_CHARACTER = 0xfffd; @@ -17,10 +19,10 @@ namespace antlrcpp { private: Unicode() = delete; - Unicode(const Unicode&) = delete; - + Unicode(Unicode&&) = delete; Unicode& operator=(const Unicode&) = delete; + Unicode& operator=(Unicode&&) = delete; }; } diff --git a/runtime/Cpp/runtime/src/support/Utf8.h b/runtime/Cpp/runtime/src/support/Utf8.h index 67de236612..e4828441cd 100644 --- a/runtime/Cpp/runtime/src/support/Utf8.h +++ b/runtime/Cpp/runtime/src/support/Utf8.h @@ -10,9 +10,11 @@ #include #include +#include "antlr4-common.h" + namespace antlrcpp { - class Utf8 final { + class ANTLR4CPP_PUBLIC Utf8 final { public: // Decodes the next code point, returning the decoded code point and the number // of code units (a.k.a. bytes) consumed. In the event that an invalid code unit @@ -43,10 +45,10 @@ namespace antlrcpp { private: Utf8() = delete; - Utf8(const Utf8&) = delete; - + Utf8(Utf8&&) = delete; Utf8& operator=(const Utf8&) = delete; + Utf8& operator=(Utf8&&) = delete; }; }