Skip to content

Commit 464f481

Browse files
committed
Define namespaces inside generic files
1 parent af8b52e commit 464f481

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+245
-311
lines changed

src/arm64/dom_parser_implementation.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -101,55 +101,61 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
101101
return is_third_byte ^ is_fourth_byte;
102102
}
103103

104+
} // namespace SIMDJSON_IMPLEMENTATION
105+
} // namespace simdjson
106+
104107
#include "generic/stage1/buf_block_reader.h"
105108
#include "generic/stage1/json_string_scanner.h"
106109
#include "generic/stage1/json_scanner.h"
110+
#include "generic/stage1/json_minifier.h"
111+
#include "generic/stage1/find_next_document_index.h"
112+
#include "generic/stage1/utf8_lookup4_algorithm.h"
113+
#include "generic/stage1/json_structural_indexer.h"
114+
115+
//
116+
// Stage 2
117+
//
118+
119+
#include "arm64/stringparsing.h"
120+
#include "arm64/numberparsing.h"
121+
#include "generic/stage2/logger.h"
122+
#include "generic/stage2/atomparsing.h"
123+
#include "generic/stage2/structural_iterator.h"
124+
#include "generic/stage2/structural_parser.h"
125+
126+
//
127+
// Implementation-specific overrides
128+
//
129+
namespace simdjson {
130+
namespace SIMDJSON_IMPLEMENTATION {
107131

108132
namespace stage1 {
133+
109134
really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
110135
// On ARM, we don't short-circuit this if there are no backslashes, because the branch gives us no
111136
// benefit and therefore makes things worse.
112137
// if (!backslash) { uint64_t escaped = prev_escaped; prev_escaped = 0; return escaped; }
113138
return find_escaped_branchless(backslash);
114139
}
115-
}
116140

117-
#include "generic/stage1/json_minifier.h"
141+
} // namespace stage1
142+
118143
WARN_UNUSED error_code implementation::minify(const uint8_t *buf, size_t len, uint8_t *dst, size_t &dst_len) const noexcept {
119144
return arm64::stage1::json_minifier::minify<64>(buf, len, dst, dst_len);
120145
}
121146

122-
#include "generic/stage1/find_next_document_index.h"
123-
#include "generic/stage1/utf8_lookup4_algorithm.h"
124-
#include "generic/stage1/json_structural_indexer.h"
125147
WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool streaming) noexcept {
126148
this->buf = _buf;
127149
this->len = _len;
128150
return arm64::stage1::json_structural_indexer::index<64>(buf, len, *this, streaming);
129151
}
152+
130153
#include "generic/stage1/utf8_validator.h"
154+
131155
WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) const noexcept {
132156
return simdjson::arm64::stage1::generic_validate_utf8(buf,len);
133157
}
134158

135-
} // namespace SIMDJSON_IMPLEMENTATION
136-
} // namespace simdjson
137-
138-
//
139-
// Stage 2
140-
//
141-
142-
#include "arm64/stringparsing.h"
143-
#include "arm64/numberparsing.h"
144-
145-
namespace simdjson {
146-
namespace SIMDJSON_IMPLEMENTATION {
147-
148-
#include "generic/stage2/logger.h"
149-
#include "generic/stage2/atomparsing.h"
150-
#include "generic/stage2/structural_iterator.h"
151-
#include "generic/stage2/structural_parser.h"
152-
153159
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
154160
error_code err = stage1(_buf, _len, false);
155161
if (err) { return err; }
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
#ifndef SIMDJSON_ARM64_DOM_PARSER_IMPLEMENTATION_H
22
#define SIMDJSON_ARM64_DOM_PARSER_IMPLEMENTATION_H
33

4-
#include "simdjson.h"
5-
#include "isadetection.h"
6-
7-
namespace simdjson {
8-
namespace arm64 {
9-
104
#include "generic/dom_parser_implementation.h"
115

12-
} // namespace arm64
13-
} // namespace simdjson
14-
156
#endif // SIMDJSON_ARM64_DOM_PARSER_IMPLEMENTATION_H

src/arm64/numberparsing.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
2828
return uint32_t((val & 0x0000FFFF0000FFFF) * 42949672960001 >> 32);
2929
}
3030

31+
} // namespace arm64
32+
} // namespace simdjson
33+
3134
#define SWAR_NUMBER_PARSING
3235

3336
#include "generic/stage2/numberparsing.h"
3437

35-
} // namespace arm64
36-
} // namespace simdjson
37-
3838
#endif // SIMDJSON_ARM64_NUMBERPARSING_H

src/arm64/stringparsing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
4444
};
4545
}
4646

47-
#include "generic/stage2/stringparsing.h"
48-
4947
} // namespace arm64
5048
} // namespace simdjson
5149

50+
#include "generic/stage2/stringparsing.h"
51+
5252
#endif // SIMDJSON_ARM64_STRINGPARSING_H

src/fallback/dom_parser_implementation.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
//
55
// Stage 1
66
//
7+
#include "generic/stage1/find_next_document_index.h"
8+
79
namespace simdjson {
810
namespace SIMDJSON_IMPLEMENTATION {
9-
1011
namespace stage1 {
1112

12-
#include "generic/stage1/find_next_document_index.h"
13-
1413
class structural_scanner {
1514
public:
1615

@@ -180,7 +179,6 @@ really_inline error_code scan() {
180179

181180
} // namespace stage1
182181

183-
184182
WARN_UNUSED error_code dom_parser_implementation::stage1(const uint8_t *_buf, size_t _len, bool partial) noexcept {
185183
this->buf = _buf;
186184
this->len = _len;
@@ -316,15 +314,14 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
316314
//
317315
#include "fallback/stringparsing.h"
318316
#include "fallback/numberparsing.h"
319-
320-
namespace simdjson {
321-
namespace SIMDJSON_IMPLEMENTATION {
322-
323317
#include "generic/stage2/logger.h"
324318
#include "generic/stage2/atomparsing.h"
325319
#include "generic/stage2/structural_iterator.h"
326320
#include "generic/stage2/structural_parser.h"
327321

322+
namespace simdjson {
323+
namespace SIMDJSON_IMPLEMENTATION {
324+
328325
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
329326
error_code err = stage1(_buf, _len, false);
330327
if (err) { return err; }
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
#ifndef SIMDJSON_FALLBACK_DOM_PARSER_IMPLEMENTATION_H
22
#define SIMDJSON_FALLBACK_DOM_PARSER_IMPLEMENTATION_H
33

4-
#include "simdjson.h"
5-
#include "isadetection.h"
6-
7-
namespace simdjson {
8-
namespace fallback {
9-
104
#include "generic/dom_parser_implementation.h"
115

12-
} // namespace fallback
13-
} // namespace simdjson
14-
156
#endif // SIMDJSON_FALLBACK_DOM_PARSER_IMPLEMENTATION_H

src/fallback/numberparsing.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void found_float(double result, const uint8_t *buf);
1515
#endif
1616

1717
namespace simdjson {
18-
namespace fallback {
18+
namespace SIMDJSON_IMPLEMENTATION {
1919
static really_inline uint32_t parse_eight_digits_unrolled(const char *chars) {
2020
uint32_t result = 0;
2121
for (int i=0;i<8;i++) {
@@ -27,12 +27,10 @@ static really_inline uint32_t parse_eight_digits_unrolled(const uint8_t *chars)
2727
return parse_eight_digits_unrolled((const char *)chars);
2828
}
2929

30-
#define SWAR_NUMBER_PARSING
30+
} // namespace SIMDJSON_IMPLEMENTATION
31+
} // namespace simdjson
3132

33+
#define SWAR_NUMBER_PARSING
3234
#include "generic/stage2/numberparsing.h"
3335

34-
} // namespace fallback
35-
36-
} // namespace simdjson
37-
3836
#endif // SIMDJSON_FALLBACK_NUMBERPARSING_H

src/fallback/stringparsing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ really_inline backslash_and_quote backslash_and_quote::copy_and_find(const uint8
2727
return { src[0] };
2828
}
2929

30-
#include "generic/stage2/stringparsing.h"
31-
3230
} // namespace fallback
3331
} // namespace simdjson
3432

33+
#include "generic/stage2/stringparsing.h"
34+
3535
#endif // SIMDJSON_FALLBACK_STRINGPARSING_H

src/generic/dom_parser_implementation.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#include "simdjson.h"
2+
#include "isadetection.h"
3+
4+
namespace simdjson {
5+
namespace SIMDJSON_IMPLEMENTATION {
6+
17
// expectation: sizeof(scope_descriptor) = 64/8.
28
struct scope_descriptor {
39
uint32_t tape_index; // where, on the tape, does the scope ([,{) begins
@@ -38,9 +44,15 @@ class dom_parser_implementation final : public internal::dom_parser_implementati
3844
WARN_UNUSED error_code set_max_depth(size_t max_depth) noexcept final;
3945
};
4046

47+
} // namespace SIMDJSON_IMPLEMENTATION
48+
} // namespace simdjson
49+
4150
#include "generic/stage1/allocate.h"
4251
#include "generic/stage2/allocate.h"
4352

53+
namespace simdjson {
54+
namespace SIMDJSON_IMPLEMENTATION {
55+
4456
really_inline dom_parser_implementation::dom_parser_implementation() {}
4557

4658
// Leaving these here so they can be inlined if so desired
@@ -57,3 +69,6 @@ WARN_UNUSED error_code dom_parser_implementation::set_max_depth(size_t max_depth
5769
_max_depth = max_depth;
5870
return SUCCESS;
5971
}
72+
73+
} // namespace SIMDJSON_IMPLEMENTATION
74+
} // namespace simdjson

src/generic/stage1/allocate.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
namespace simdjson {
2+
namespace SIMDJSON_IMPLEMENTATION {
13
namespace stage1 {
24
namespace allocate {
35

@@ -15,3 +17,5 @@ really_inline error_code set_capacity(internal::dom_parser_implementation &parse
1517

1618
} // namespace allocate
1719
} // namespace stage1
20+
} // namespace SIMDJSON_IMPLEMENTATION
21+
} // namespace simdjson

0 commit comments

Comments
 (0)