1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Fix undefined reference in SAJSON.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sandu Liviu Catalin 2021-07-16 21:37:01 +03:00
parent 197a6cd622
commit b4fa4091df
2 changed files with 9 additions and 6 deletions

View File

@ -138,12 +138,17 @@ constexpr inline size_t make_element(tag t, size_t value) {
// header. This trick courtesy of Rich Geldreich's Purple JSON parser. // header. This trick courtesy of Rich Geldreich's Purple JSON parser.
template <typename unused = void> template <typename unused = void>
struct globals_struct { struct globals_struct {
static const unsigned char parse_flags[256];
};
typedef globals_struct<> globals;
// clang-format off // clang-format off
// bit 0 (1) - set if: plain ASCII string character // bit 0 (1) - set if: plain ASCII string character
// bit 1 (2) - set if: whitespace // bit 1 (2) - set if: whitespace
// bit 4 (0x10) - set if: 0-9 e E . // bit 4 (0x10) - set if: 0-9 e E .
constexpr static const uint8_t parse_flags[256] = { template <typename unused>
const unsigned char globals_struct<unused>::parse_flags[256] = {
// 0 1 2 3 4 5 6 7 8 9 A B C D E F // 0 1 2 3 4 5 6 7 8 9 A B C D E F
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, // 0 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, // 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1
@ -162,15 +167,13 @@ struct globals_struct {
}; };
// clang-format on // clang-format on
};
typedef globals_struct<> globals;
constexpr inline bool is_plain_string_character(char c) { inline bool is_plain_string_character(char c) {
// return c >= 0x20 && c <= 0x7f && c != 0x22 && c != 0x5c; // return c >= 0x20 && c <= 0x7f && c != 0x22 && c != 0x5c;
return (globals::parse_flags[static_cast<unsigned char>(c)] & 1) != 0; return (globals::parse_flags[static_cast<unsigned char>(c)] & 1) != 0;
} }
constexpr inline bool is_whitespace(char c) { inline bool is_whitespace(char c) {
// return c == '\r' || c == '\n' || c == '\t' || c == ' '; // return c == '\r' || c == '\n' || c == '\t' || c == ' ';
return (globals::parse_flags[static_cast<unsigned char>(c)] & 2) != 0; return (globals::parse_flags[static_cast<unsigned char>(c)] & 2) != 0;
} }

View File

@ -2,6 +2,6 @@
namespace sajson { namespace sajson {
namespace internal { namespace internal {
template <> const uint8_t globals_struct<void>::parse_flags[256]; //template <> const uint8_t globals_struct<void>::parse_flags[256];
} }
} }