Skip to content

Commit d2fa086

Browse files
myd7349lemire
authored andcommitted
Fix C4146 build error on UWP with MSVC (simdjson#113)
* Fix C4146 build error on UWP with MSVC * Regenerate single header version * Fix typo in parsedjson.h * Regenerate single header version
1 parent 5dc47ac commit d2fa086

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

include/simdjson/numberparsing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
331331
return false; // overflow
332332
}
333333
}
334-
int64_t signed_answer = negative ? -i : i;
334+
int64_t signed_answer = negative ? -static_cast<int64_t>(i) : static_cast<int64_t>(i);
335335
pj.write_tape_s64(signed_answer);
336336
#ifdef JSON_TEST_NUMBERS // for unit testing
337337
foundInteger(signed_answer, buf + offset);

include/simdjson/parsedjson.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct ParsedJson {
3030
ParsedJson(ParsedJson && p);
3131

3232
// if needed, allocate memory so that the object is able to process JSON
33-
// documents having up to len butes and maxdepth "depth"
33+
// documents having up to len bytes and maxdepth "depth"
3434
WARN_UNUSED
3535
bool allocateCapacity(size_t len, size_t maxdepth = DEFAULTMAXDEPTH);
3636

singleheader/amalgamation_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on Wed 6 Mar 11:05:32 AEDT 2019. Do not edit! */
1+
/* auto-generated on Fri Mar 8 19:04:53 PST 2019. Do not edit! */
22

33
#include <iostream>
44
#include "simdjson.h"

singleheader/simdjson.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on Wed 6 Mar 11:05:32 AEDT 2019. Do not edit! */
1+
/* auto-generated on Fri Mar 8 19:04:53 PST 2019. Do not edit! */
22
#include "simdjson.h"
33

44
/* used for http://dmalloc.com/ Dmalloc - Debug Malloc Library */
@@ -1626,31 +1626,30 @@ uint8_t ParsedJson::iterator::get_scope_type() const {
16261626
}
16271627

16281628
bool ParsedJson::iterator::move_forward() {
1629-
if(location + 1 >= tape_length) {
1630-
return false; // we are at the end!
1631-
}
1632-
// we are entering a new scope
1633-
if ((current_type == '[') || (current_type == '{')){
1634-
depth++;
1635-
depthindex[depth].start_of_scope = location;
1636-
depthindex[depth].scope_type = current_type;
1637-
}
1638-
location = location + 1;
1639-
current_val = pj.tape[location];
1640-
current_type = (current_val >> 56);
1641-
// if we encounter a scope closure, we need to move up
1642-
while ((current_type == ']') || (current_type == '}')) {
16431629
if(location + 1 >= tape_length) {
16441630
return false; // we are at the end!
16451631
}
1646-
depth--;
1647-
if(depth == 0) {
1648-
return false; // should not be necessary
1632+
1633+
if ((current_type == '[') || (current_type == '{')){
1634+
// We are entering a new scope
1635+
depth++;
1636+
depthindex[depth].start_of_scope = location;
1637+
depthindex[depth].scope_type = current_type;
1638+
} else if ((current_type == ']') || (current_type == '}')) {
1639+
// Leaving a scope.
1640+
depth--;
1641+
if(depth == 0) {
1642+
// Should not be necessary
1643+
return false;
1644+
}
1645+
} else if ((current_type == 'd') || (current_type == 'l')) {
1646+
// d and l types use 2 locations on the tape, not just one.
1647+
location += 1;
16491648
}
1650-
location = location + 1;
1649+
1650+
location += 1;
16511651
current_val = pj.tape[location];
16521652
current_type = (current_val >> 56);
1653-
}
16541653
return true;
16551654
}
16561655

singleheader/simdjson.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on Wed 6 Mar 11:05:32 AEDT 2019. Do not edit! */
1+
/* auto-generated on Fri Mar 8 19:04:53 PST 2019. Do not edit! */
22
/* begin file include/simdjson/simdjson_version.h */
33
// /include/simdjson/simdjson_version.h automatically generated by release.py, do not change by hand
44
#ifndef SIMDJSON_INCLUDE_SIMDJSON_VERSION
@@ -36571,7 +36571,7 @@ static never_inline bool parse_large_integer(const uint8_t *const buf,
3657136571
return false; // overflow
3657236572
}
3657336573
}
36574-
int64_t signed_answer = negative ? -i : i;
36574+
int64_t signed_answer = negative ? -static_cast<int64_t>(i) : static_cast<int64_t>(i);
3657536575
pj.write_tape_s64(signed_answer);
3657636576
#ifdef JSON_TEST_NUMBERS // for unit testing
3657736577
foundInteger(signed_answer, buf + offset);

0 commit comments

Comments
 (0)