diff --git a/.appveyor.yml b/.appveyor.yml index 4f06f4d8d..905dbf5df 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -17,6 +17,6 @@ environment: build_script: - mkdir build - cd build - - ps: cmake -DSIMDJSON_BUILD_STATIC="$env:SIMDJSON_BUILD_STATIC" -DCMAKE_GENERATOR_PLATFORM=x64 .. + - ps: cmake -DSIMDJSON_BUILD_STATIC="$env:SIMDJSON_BUILD_STATIC" -DCMAKE_BUILD_TYPE=Release -DCMAKE_GENERATOR_PLATFORM=x64 .. - cmake --build . - ctest --verbose diff --git a/include/simdjson/jsonparser.h b/include/simdjson/jsonparser.h index 217f1d636..d7d7dfd7f 100644 --- a/include/simdjson/jsonparser.h +++ b/include/simdjson/jsonparser.h @@ -17,18 +17,6 @@ #endif namespace simdjson { -// The function that users are expected to call is json_parse. -// We have more than one such function because we want to support several -// instruction sets. - -// function pointer type for json_parse -using json_parse_functype = int(const uint8_t *buf, size_t len, ParsedJson &pj, - bool realloc_if_needed); - -// Pointer that holds the json_parse implementation corresponding to the -// available SIMD instruction set -extern json_parse_functype *json_parse_ptr; - // json_parse_implementation is the generic function, it is specialized for // various architectures, e.g., as // json_parse_implementation or @@ -42,7 +30,7 @@ int json_parse_implementation(const uint8_t *buf, size_t len, ParsedJson &pj, bool reallocated = false; if (realloc_if_needed) { #if ALLOW_SAME_PAGE_BUFFER_OVERRUN - // realloc is needed if the end of the memory crosses a page +// realloc is needed if the end of the memory crosses a page #ifdef _MSC_VER SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); @@ -110,10 +98,8 @@ int json_parse_implementation(const uint8_t *buf, size_t len, ParsedJson &pj, // realloc_if_needed is false, all bytes at and after buf + len are ignored // (can be garbage). The ParsedJson object can be reused. -inline int json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, - bool realloc_if_needed = true) { - return json_parse_ptr(buf, len, pj, realloc_if_needed); -} +int json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, + bool realloc_if_needed = true); // Parse a document found in buf. // @@ -139,11 +125,8 @@ inline int json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, // buf should be readable up to buf + len + SIMDJSON_PADDING if // realloc_if_needed is false, all bytes at and after buf + len are ignored // (can be garbage). The ParsedJson object can be reused. -inline int json_parse(const char *buf, size_t len, ParsedJson &pj, - bool realloc_if_needed = true) { - return json_parse_ptr(reinterpret_cast(buf), len, pj, - realloc_if_needed); -} +int json_parse(const char *buf, size_t len, ParsedJson &pj, + bool realloc_if_needed = true); // We do not want to allow implicit conversion from C string to std::string. int json_parse(const char *buf, ParsedJson &pj) = delete; diff --git a/src/jsonparser.cpp b/src/jsonparser.cpp index 9e263749e..49d8877d9 100644 --- a/src/jsonparser.cpp +++ b/src/jsonparser.cpp @@ -5,6 +5,29 @@ namespace simdjson { +// The function that users are expected to call is json_parse. +// We have more than one such function because we want to support several +// instruction sets. + +// function pointer type for json_parse +using json_parse_functype = int(const uint8_t *buf, size_t len, ParsedJson &pj, + bool realloc_if_needed); + +// Pointer that holds the json_parse implementation corresponding to the +// available SIMD instruction set +extern json_parse_functype *json_parse_ptr; + +int json_parse(const uint8_t *buf, size_t len, ParsedJson &pj, + bool realloc_if_needed) { + return json_parse_ptr(buf, len, pj, realloc_if_needed); +} + +int json_parse(const char *buf, size_t len, ParsedJson &pj, + bool realloc_if_needed) { + return json_parse_ptr(reinterpret_cast(buf), len, pj, + realloc_if_needed); +} + Architecture find_best_supported_implementation() { constexpr uint32_t haswell_flags = instruction_set::AVX2 | instruction_set::PCLMULQDQ | diff --git a/style/run-clang-format.py b/style/run-clang-format.py index 3d0cca0a9..0ff9dbe1d 100755 --- a/style/run-clang-format.py +++ b/style/run-clang-format.py @@ -322,4 +322,5 @@ def main(): if __name__ == '__main__': - sys.exit(main()) + #sys.exit(main()) + main() # we don't want a hard failure on a style check. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c2b131406..e73efd176 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,4 +12,14 @@ add_cpp_test(pointercheck) # add_executable(singleheader ./singleheadertest.cpp ${PROJECT_SOURCE_DIR}/singleheader/simdjson.cpp) # target_compile_definitions(singleheader PRIVATE JSON_TEST_PATH="${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json") # target_link_libraries(singleheader ${SIMDJSON_LIB_NAME}) -# add_test(singleheader singleheader) \ No newline at end of file +# add_test(singleheader singleheader) + +if(MSVC) + add_custom_command(TARGET basictests POST_BUILD # Adds a post-build event + COMMAND ${CMAKE_COMMAND} -E echo "$" + COMMAND ${CMAKE_COMMAND} -E echo "$" + COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake -E copy_if_different..." + "$" # <--this is in-file + "$") # <--this is out-file path +endif() +