Skip to content

Commit adec47c

Browse files
authored
[C++] Add ANTLR4CPP_PUBLIC attributes to various symbols (#3588)
1 parent c68e127 commit adec47c

File tree

7 files changed

+30
-53
lines changed

7 files changed

+30
-53
lines changed

runtime/Cpp/runtime/src/atn/LexerATNSimulator.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,8 @@ using namespace antlr4;
3030
using namespace antlr4::atn;
3131
using namespace antlrcpp;
3232

33-
LexerATNSimulator::SimState::~SimState() {
34-
}
35-
3633
void LexerATNSimulator::SimState::reset() {
37-
index = INVALID_INDEX;
38-
line = 0;
39-
charPos = INVALID_INDEX;
40-
dfaState = nullptr; // Don't delete. It's just a reference.
41-
}
42-
43-
void LexerATNSimulator::SimState::InitializeInstanceFields() {
44-
index = INVALID_INDEX;
45-
line = 0;
46-
charPos = INVALID_INDEX;
34+
*this = SimState();
4735
}
4836

4937
LexerATNSimulator::LexerATNSimulator(const ATN &atn, std::vector<dfa::DFA> &decisionToDFA,

runtime/Cpp/runtime/src/atn/LexerATNSimulator.h

+7-20
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,14 @@ namespace atn {
1717
/// "dup" of ParserInterpreter
1818
class ANTLR4CPP_PUBLIC LexerATNSimulator : public ATNSimulator {
1919
protected:
20-
class SimState {
21-
public:
22-
virtual ~SimState();
23-
24-
protected:
25-
size_t index;
26-
size_t line;
27-
size_t charPos;
28-
dfa::DFAState *dfaState;
29-
virtual void reset();
30-
friend class LexerATNSimulator;
31-
32-
private:
33-
void InitializeInstanceFields();
34-
35-
public:
36-
SimState() {
37-
InitializeInstanceFields();
38-
}
39-
};
20+
struct ANTLR4CPP_PUBLIC SimState final {
21+
size_t index = INVALID_INDEX;
22+
size_t line = 0;
23+
size_t charPos = INVALID_INDEX;
24+
dfa::DFAState *dfaState = nullptr;
4025

26+
void reset();
27+
};
4128

4229
public:
4330
static constexpr size_t MIN_DFA_EDGE = 0;

runtime/Cpp/runtime/src/dfa/DFAState.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace dfa {
3737
/// </summary>
3838
class ANTLR4CPP_PUBLIC DFAState final {
3939
public:
40-
class PredPrediction final {
40+
class ANTLR4CPP_PUBLIC PredPrediction final {
4141
public:
4242
Ref<const atn::SemanticContext> pred; // never null; at least SemanticContext.NONE
4343
int alt;

runtime/Cpp/runtime/src/support/CPPUtils.h

+9-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55

66
#pragma once
77

8-
#include <shared_mutex>
9-
108
#include "antlr4-common.h"
119

1210
namespace antlrcpp {
1311

14-
std::string join(const std::vector<std::string> &strings, const std::string &separator);
15-
std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
16-
std::string escapeWhitespace(std::string str, bool escapeSpaces);
17-
std::string toHexString(const int t);
18-
std::string arrayToString(const std::vector<std::string> &data);
19-
std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
20-
std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
21-
std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
12+
ANTLR4CPP_PUBLIC std::string join(const std::vector<std::string> &strings, const std::string &separator);
13+
ANTLR4CPP_PUBLIC std::map<std::string, size_t> toMap(const std::vector<std::string> &keys);
14+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string str, bool escapeSpaces);
15+
ANTLR4CPP_PUBLIC std::string toHexString(const int t);
16+
ANTLR4CPP_PUBLIC std::string arrayToString(const std::vector<std::string> &data);
17+
ANTLR4CPP_PUBLIC std::string replaceString(const std::string &s, const std::string &from, const std::string &to);
18+
ANTLR4CPP_PUBLIC std::vector<std::string> split(const std::string &s, const std::string &sep, int count);
19+
ANTLR4CPP_PUBLIC std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
2220

2321
// Using RAII + a lambda to implement a "finally" replacement.
2422
template <typename OnEnd>
@@ -62,6 +60,6 @@ namespace antlrcpp {
6260
}
6361

6462
// Get the error text from an exception pointer or the current exception.
65-
std::string what(std::exception_ptr eptr = std::current_exception());
63+
ANTLR4CPP_PUBLIC std::string what(std::exception_ptr eptr = std::current_exception());
6664

6765
} // namespace antlrcpp

runtime/Cpp/runtime/src/support/StringUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
namespace antlrcpp {
1111

12-
std::string escapeWhitespace(std::string_view in);
12+
ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in);
1313

14-
std::string& escapeWhitespace(std::string& out, std::string_view in);
14+
ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in);
1515

1616
}

runtime/Cpp/runtime/src/support/Unicode.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
#pragma once
77

8+
#include "antlr4-common.h"
9+
810
namespace antlrcpp {
911

10-
class Unicode final {
12+
class ANTLR4CPP_PUBLIC Unicode final {
1113
public:
1214
static constexpr char32_t REPLACEMENT_CHARACTER = 0xfffd;
1315

@@ -17,10 +19,10 @@ namespace antlrcpp {
1719

1820
private:
1921
Unicode() = delete;
20-
2122
Unicode(const Unicode&) = delete;
22-
23+
Unicode(Unicode&&) = delete;
2324
Unicode& operator=(const Unicode&) = delete;
25+
Unicode& operator=(Unicode&&) = delete;
2426
};
2527

2628
}

runtime/Cpp/runtime/src/support/Utf8.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
#include <string_view>
1111
#include <tuple>
1212

13+
#include "antlr4-common.h"
14+
1315
namespace antlrcpp {
1416

15-
class Utf8 final {
17+
class ANTLR4CPP_PUBLIC Utf8 final {
1618
public:
1719
// Decodes the next code point, returning the decoded code point and the number
1820
// of code units (a.k.a. bytes) consumed. In the event that an invalid code unit
@@ -43,10 +45,10 @@ namespace antlrcpp {
4345

4446
private:
4547
Utf8() = delete;
46-
4748
Utf8(const Utf8&) = delete;
48-
49+
Utf8(Utf8&&) = delete;
4950
Utf8& operator=(const Utf8&) = delete;
51+
Utf8& operator=(Utf8&&) = delete;
5052
};
5153

5254
}

0 commit comments

Comments
 (0)