Skip to content

Commit

Permalink
Fix some compile errors for new decode_str
Browse files Browse the repository at this point in the history
  • Loading branch information
Antares0982 committed Jan 1, 2025
1 parent 0f819fa commit bf1b2cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
19 changes: 9 additions & 10 deletions src/decode/decode_str.inl.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "pyyjson.h"
#define COMPILE_UCS_LEVEL PYYJSON_STRING_TYPE_UCS4
#if COMPILE_UCS_LEVEL == 0
# define COMPILE_READ_UCS_LEVEL 1
#else
# define COMPILE_READ_UCS_LEVEL COMPILE_UCS_LEVEL
#endif
#include "encode/encode_simd_utils.inl.h"
// #include "encode/encode_simd_utils.inl.h"
#include "simd/simd_impl.h"
//
#include "commondef/r_in.inl.h"
Expand Down Expand Up @@ -141,8 +140,7 @@ force_inline void check_max_char_in_loop(
}
if (need_mask) {
// need a mask
mask = load_head_mask(index);
SIMD_VAR = SIMD_AND(mask, SIMD_VAR);
SIMD_VAR = SIMD_AND(load_head_mask(index), SIMD_VAR);
}
switch (cur_max_char_type) {
case PYYJSON_STRING_TYPE_ASCII: { // TODO
Expand Down Expand Up @@ -237,7 +235,7 @@ force_inline bool verify_escape_hex(DECODE_SRC_INFO *decode_src_info) {
return true;
}

struct SpecialCharReadResult {
typedef struct SpecialCharReadResult {
u32 value;
ReadStrScanFlag flag;
} SpecialCharReadResult;
Expand All @@ -260,7 +258,7 @@ force_noinline u32 DECODE_ESCAPE_UNICODE(DECODE_SRC_INFO *restrict decode_src_in

decode_src_info->src++;
if (unlikely(!verify_escape_hex(decode_src_info) || !READ_TO_HEX_U16(decode_src_info->src, &hi))) {
if (unlikely(!PyErr_Occured())) {
if (unlikely(!PyErr_Occurred())) {
PyErr_SetString(JSONDecodeError, "Invalid escape sequence in string");
}
return (u32)0xffffffff;
Expand Down Expand Up @@ -320,10 +318,11 @@ force_inline SpecialCharReadResult DO_SPECIAL(DECODE_SRC_INFO *restrict decode_s
return result;
} else if (u < ControlMax) {
// invalid
return StrInvalid;
result.flag = StrInvalid;
return result;
} else {
assert(false);
Py_UNREAHCABLE();
Py_UNREACHABLE();
}
}

Expand Down Expand Up @@ -447,7 +446,7 @@ force_inline void READ_STR_IN_LOOP(
if (write_as > COMPILE_READ_UCS_LEVEL) { // compile time determined
if (write_as == 2) { // compile time determined
assert(decode_unicode_info->unicode_ucs2);
PYYJSON_CONCAT3(write_simd_impl, COMPILE_READ_UCS_LEVEL, 2)(get_ucs2_writer(decode_unicode_info), SIMD_VAR)
PYYJSON_CONCAT3(write_simd_impl, COMPILE_READ_UCS_LEVEL, 2)(get_ucs2_writer(decode_unicode_info), SIMD_VAR);
} else {
assert(write_as == 4);
assert(decode_unicode_info->unicode_ucs4);
Expand Down Expand Up @@ -481,7 +480,7 @@ force_inline void READ_STR_IN_LOOP(
return;
}
if (unlikely(escape_result.flag == StrInvalid)) {
assert(PyErr_Occured());
assert(PyErr_Occurred());
read_state->scan_flag = StrInvalid;
return;
}
Expand Down
6 changes: 0 additions & 6 deletions src/encode/encode_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
#include <stddef.h>


#define _Quote (34)
#define _Slash (92)
#define _MinusOne (-1)
#define ControlMax (32)


#define CONTROL_SEQ_ESCAPE_PREFIX _Slash, 'u', '0', '0'
#define CONTROL_SEQ_ESCAPE_SUFFIX '\0', '\0'
#define CONTROL_SEQ_ESCAPE_MIDDLE CONTROL_SEQ_ESCAPE_SUFFIX, CONTROL_SEQ_ESCAPE_SUFFIX
Expand Down
6 changes: 6 additions & 0 deletions src/pyyjson.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ static_assert(false, "false");
} \
} while (0)

/* Some constants. */
#define _Quote (34)
#define _Slash (92)
#define _MinusOne (-1)
#define ControlMax (32)


/*==============================================================================
* 128-bit Integer Utils
Expand Down

0 comments on commit bf1b2cf

Please sign in to comment.