Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group encoding/decoding source code into src/runtime #733

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ find_package(JSONToolkit REQUIRED)

# Runtime
if(JSONBINPACK_RUNTIME OR JSONBINPACK_CLI OR JSONBINPACK_COMPILER)
add_subdirectory(src/numeric)
add_subdirectory(src/encoding)
add_subdirectory(src/encoder)
add_subdirectory(src/decoder)
add_subdirectory(src/runtime)
endif()

# Compiler
Expand Down Expand Up @@ -67,10 +64,7 @@ if(JSONBINPACK_TESTS)
enable_testing()

if(JSONBINPACK_RUNTIME OR JSONBINPACK_CLI OR JSONBINPACK_COMPILER)
add_subdirectory(test/numeric)
add_subdirectory(test/encoding)
add_subdirectory(test/encoder)
add_subdirectory(test/decoder)
add_subdirectory(test/runtime)
endif()

if(JSONBINPACK_COMPILER OR JSONBINPACK_CLI)
Expand Down
3 changes: 1 addition & 2 deletions src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::mapper)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::parser)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::schemas)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::encoder)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::decoder)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsonbinpack::runtime)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsontoolkit::json)
target_link_libraries(sourcemeta_jsonbinpack_cli PRIVATE sourcemeta::jsontoolkit::jsonschema)

Expand Down
2 changes: 1 addition & 1 deletion src/cli/command_decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "resolver.h"

#include <sourcemeta/jsonbinpack/canonicalizer.h>
#include <sourcemeta/jsonbinpack/decoder.h>
#include <sourcemeta/jsonbinpack/mapper.h>
#include <sourcemeta/jsonbinpack/parser.h>
#include <sourcemeta/jsonbinpack/runtime.h>

#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>
Expand Down
2 changes: 1 addition & 1 deletion src/cli/command_encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "resolver.h"

#include <sourcemeta/jsonbinpack/canonicalizer.h>
#include <sourcemeta/jsonbinpack/encoder.h>
#include <sourcemeta/jsonbinpack/mapper.h>
#include <sourcemeta/jsonbinpack/parser.h>
#include <sourcemeta/jsonbinpack/runtime.h>

#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>
Expand Down
16 changes: 0 additions & 16 deletions src/decoder/CMakeLists.txt

This file was deleted.

39 changes: 0 additions & 39 deletions src/decoder/include/sourcemeta/jsonbinpack/decoder_varint.h

This file was deleted.

18 changes: 0 additions & 18 deletions src/decoder/include/sourcemeta/jsonbinpack/decoder_zigzag.h

This file was deleted.

16 changes: 0 additions & 16 deletions src/encoder/CMakeLists.txt

This file was deleted.

30 changes: 0 additions & 30 deletions src/encoder/include/sourcemeta/jsonbinpack/encoder_varint.h

This file was deleted.

19 changes: 0 additions & 19 deletions src/encoder/include/sourcemeta/jsonbinpack/encoder_zigzag.h

This file was deleted.

14 changes: 0 additions & 14 deletions src/encoding/CMakeLists.txt

This file was deleted.

8 changes: 0 additions & 8 deletions src/numeric/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sourcemeta_jsonbinpack_add_compile_options(PRIVATE sourcemeta_jsonbinpack_parser
target_link_libraries(sourcemeta_jsonbinpack_parser PUBLIC
sourcemeta::jsontoolkit::json)
target_link_libraries(sourcemeta_jsonbinpack_parser PRIVATE
sourcemeta::jsonbinpack::encoding)
sourcemeta::jsonbinpack::runtime)
2 changes: 1 addition & 1 deletion src/parser/include/sourcemeta/jsonbinpack/parser.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_H_
#define SOURCEMETA_JSONBINPACK_PARSER_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

namespace sourcemeta::jsonbinpack {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/v1_any.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ANY_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_ANY_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

namespace sourcemeta::jsonbinpack::parser::v1 {
Expand Down
3 changes: 1 addition & 2 deletions src/parser/v1_array.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ARRAY_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_ARRAY_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/encoding_wrap.h>
#include <sourcemeta/jsonbinpack/parser.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

#include <algorithm> // std::transform
Expand Down
2 changes: 1 addition & 1 deletion src/parser/v1_enum.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_ENUM_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_ENUM_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

#include <cassert> // assert
Expand Down
2 changes: 1 addition & 1 deletion src/parser/v1_integer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_INTEGER_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_INTEGER_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

#include <cassert> // assert
Expand Down
2 changes: 1 addition & 1 deletion src/parser/v1_number.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_NUMBER_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_NUMBER_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

namespace sourcemeta::jsonbinpack::parser::v1 {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/v1_string.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SOURCEMETA_JSONBINPACK_PARSER_V1_STRING_H_
#define SOURCEMETA_JSONBINPACK_PARSER_V1_STRING_H_

#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/jsontoolkit/json.h>

#include <cassert> // assert
Expand Down
16 changes: 16 additions & 0 deletions src/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
noa_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime
FOLDER "JSON BinPack/Runtime"
PRIVATE_HEADERS
decoder.h decoder_basic.h
encoder.h encoder_basic.h encoder_context.h encoder_real.h
encoding.h encoding_tag.h encoding_wrap.h
zigzag.h varint.h numeric.h)

if(JSONBINPACK_INSTALL)
noa_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME runtime)
endif()

sourcemeta_jsonbinpack_add_compile_options(INTERFACE sourcemeta_jsonbinpack_runtime)

target_link_libraries(sourcemeta_jsonbinpack_runtime INTERFACE
sourcemeta::jsontoolkit::json)
8 changes: 8 additions & 0 deletions src/runtime/include/sourcemeta/jsonbinpack/runtime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_H_
#define SOURCEMETA_JSONBINPACK_RUNTIME_H_

#include <sourcemeta/jsonbinpack/runtime_decoder.h>
#include <sourcemeta/jsonbinpack/runtime_encoder.h>
#include <sourcemeta/jsonbinpack/runtime_encoding.h>

#endif
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#ifndef SOURCEMETA_JSONBINPACK_DECODER_H_
#define SOURCEMETA_JSONBINPACK_DECODER_H_
#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_H_
#define SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_H_

/// @defgroup decoder Decoder
/// @brief A set of procedures to deserialize a bit-string given a Encoding
/// Schema

#include <sourcemeta/jsonbinpack/decoder_basic.h>
#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/encoding_tag.h>
#include <sourcemeta/jsonbinpack/encoding_wrap.h>
#include <sourcemeta/jsonbinpack/numeric.h>
#include <sourcemeta/jsonbinpack/runtime_decoder_basic.h>
#include <sourcemeta/jsonbinpack/runtime_encoding.h>
#include <sourcemeta/jsonbinpack/runtime_encoding_tag.h>
#include <sourcemeta/jsonbinpack/runtime_encoding_wrap.h>
#include <sourcemeta/jsonbinpack/runtime_numeric.h>

#include <sourcemeta/jsontoolkit/json.h>

#include <cassert> // assert
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef SOURCEMETA_JSONBINPACK_DECODER_BASIC_H_
#define SOURCEMETA_JSONBINPACK_DECODER_BASIC_H_
#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_BASIC_H_
#define SOURCEMETA_JSONBINPACK_RUNTIME_DECODER_BASIC_H_

#include <sourcemeta/jsonbinpack/decoder_varint.h>
#include <sourcemeta/jsonbinpack/decoder_zigzag.h>
#include <sourcemeta/jsonbinpack/runtime_varint.h>
#include <sourcemeta/jsonbinpack/runtime_zigzag.h>

#include <cassert> // assert
#include <cmath> // std::ceil
Expand Down Expand Up @@ -56,12 +56,12 @@ template <typename CharT, typename Traits> class BasicDecoder {
}

inline auto get_varint() -> std::uint64_t {
return decoder::varint(this->stream);
return varint_decode(this->stream);
}

inline auto get_varint_zigzag() -> std::int64_t {
const std::uint64_t value = decoder::varint(this->stream);
return decoder::zigzag(value);
const std::uint64_t value = varint_decode(this->stream);
return zigzag_decode(value);
}

inline auto has_more_data() const noexcept -> bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#ifndef SOURCEMETA_JSONBINPACK_ENCODER_H_
#define SOURCEMETA_JSONBINPACK_ENCODER_H_
#ifndef SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_H_
#define SOURCEMETA_JSONBINPACK_RUNTIME_ENCODER_H_

/// @defgroup encoder Encoder
/// @brief A set of procedures to serialize a JSON document given a Encoding
/// Schema

#include <sourcemeta/jsonbinpack/encoder_basic.h>
#include <sourcemeta/jsonbinpack/encoder_real.h>
#include <sourcemeta/jsonbinpack/encoding.h>
#include <sourcemeta/jsonbinpack/encoding_tag.h>
#include <sourcemeta/jsonbinpack/encoding_wrap.h>
#include <sourcemeta/jsonbinpack/numeric.h>
#include <sourcemeta/jsonbinpack/runtime_encoder_basic.h>
#include <sourcemeta/jsonbinpack/runtime_encoder_real.h>
#include <sourcemeta/jsonbinpack/runtime_encoding.h>
#include <sourcemeta/jsonbinpack/runtime_encoding_tag.h>
#include <sourcemeta/jsonbinpack/runtime_encoding_wrap.h>
#include <sourcemeta/jsonbinpack/runtime_numeric.h>

#include <sourcemeta/jsontoolkit/json.h>

#include <cmath> // std::abs
Expand Down
Loading
Loading