forked from Harrm/scale-codec
-
Notifications
You must be signed in to change notification settings - Fork 7
Feature: support for coding of aggregates #32
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7b622a7
feature: coding of aggregate
xDimon 2b2969e
refactor: use concepts
xDimon 397f5db
fix: incomplete concepts
xDimon 6baec5c
fix: SomeSpan concept
xDimon 9a01004
update: version of used hunter
xDimon c4c2383
fix: CI
xDimon fdc1663
fix: CI
xDimon b81ba08
fix: CI
xDimon f325334
update: hunter and qtils
xDimon eb74ac4
refactor: used macros
xDimon 3bb4394
fix: try to fix CI (update macos)
xDimon c997a5c
update: qtils
xDimon a401adc
refactor: rename as_decomposed
xDimon 0a74ea0
feature: generate aggregate.hpp in according MAX_AGGREGATE_FIELDS cma…
xDimon 7eaee7f
update: qtils
xDimon c5349eb
update: qtils
xDimon 8a0e43c
fix: redundant decay_t using
xDimon 965bf3f
feature: custom discomposing
xDimon 9ea5b57
fix: review issues
xDimon 4d35097
don't overwrite aggregate.hpp
turuslan 5769acc
fix constructible on macos
turuslan f89839d
Revert "don't overwrite aggregate.hpp"
turuslan 88988d4
don't overwrite aggregate.hpp
turuslan 1461bb4
fix makefile
turuslan fb0a319
update: qtils
xDimon 6bdc80b
configure_file definitions
turuslan 08122a3
update: qtils
xDimon 7a418d9
update: qtils hunter config
xDimon 04bea1a
update: qtils
xDimon 2dde730
update: qtils
xDimon 6dbe202
update: qtils
xDimon e31f904
refactor: complete support fixed-width and compact integers
xDimon c30e4a7
feature: CompactReflection for coding int value as compact
xDimon 9576c5d
fix: review issues
xDimon 312aaae
update: qtils
xDimon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Template for a custom hunter configuration Useful when there is a need for a | ||
| # non-default version or arguments of a dependency, or when a project not | ||
| # registered in soramitsu-hunter should be added. | ||
| # | ||
| # hunter_config( | ||
| # package-name | ||
| # VERSION 0.0.0-package-version | ||
| # CMAKE_ARGS | ||
| # CMAKE_VARIABLE=value | ||
| # ) | ||
| # | ||
| # hunter_config( | ||
| # package-name | ||
| # URL https://github.com/organization/repository/archive/hash.tar.gz | ||
| # SHA1 1234567890abcdef1234567890abcdef12345678 | ||
| # CMAKE_ARGS | ||
| # CMAKE_VARIABLE=value | ||
| # ) | ||
|
|
||
| hunter_config( | ||
| qtils | ||
| URL https://github.com/qdrvm/qtils/archive/198a40443b838a421db3ad8fc8dbf72e8ec4a665.tar.gz | ||
| SHA1 da91eaeec936ee572a1310024dfcd7b91ee5e5bf | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| HunterGate( | ||
| URL https://github.com/qdrvm/hunter/archive/refs/tags/v0.25.3-qdrvm29.tar.gz | ||
| SHA1 025920fa980ba81a150deaa534a0248dde25fd54 | ||
| LOCAL | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # specify GITHUB_HUNTER_TOKEN and GITHUB_HUNTER_USERNAME to automatically upload binary cache to github.com/qdrvm/hunter-binary-cache | ||
| # https://hunter.readthedocs.io/en/latest/user-guides/hunter-user/github-cache-server.html | ||
| string(COMPARE EQUAL "$ENV{GITHUB_HUNTER_USERNAME}" "" username_is_empty) | ||
| string(COMPARE EQUAL "$ENV{GITHUB_HUNTER_TOKEN}" "" password_is_empty) | ||
|
|
||
| # binary cache can be uploaded to qdrvm/hunter-binary-cache so others will not build same dependencies twice | ||
| if (NOT password_is_empty AND NOT username_is_empty) | ||
| option(HUNTER_RUN_UPLOAD "Upload cache binaries" YES) | ||
| message("Binary cache uploading is ENABLED.") | ||
| else () | ||
| option(HUNTER_RUN_UPLOAD "Upload cache binaries" NO) | ||
| message(AUTHOR_WARNING " Binary cache uploading is DISABLED. | ||
| Define environment variables GITHUB_HUNTER_USERNAME and GITHUB_HUNTER_TOKEN | ||
| for binary cache activation. To generate github token follow the instructions: | ||
| https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens | ||
| Make sure `read:packages` and `write:packages` permissions are granted (step 7 in instructions).") | ||
| endif () | ||
|
|
||
| set(HUNTER_PASSWORDS_PATH | ||
| "${CMAKE_CURRENT_LIST_DIR}/passwords.cmake" | ||
| CACHE FILEPATH "Hunter passwords" | ||
| ) | ||
|
|
||
| set(HUNTER_CACHE_SERVERS | ||
| "https://github.com/qdrvm/hunter-binary-cache" | ||
| CACHE STRING "Binary cache server" | ||
| ) | ||
|
|
||
| # https://hunter.readthedocs.io/en/latest/reference/user-variables.html#hunter-use-cache-servers | ||
| # set( | ||
| # HUNTER_USE_CACHE_SERVERS NO | ||
| # CACHE STRING "Disable binary cache" | ||
| # ) | ||
|
|
||
| # https://hunter.readthedocs.io/en/latest/reference/user-variables.html#hunter-status-debug | ||
| # set( | ||
| # HUNTER_STATUS_DEBUG ON | ||
| # CACHE STRING "Enable output lot of info for debugging" | ||
| # ) | ||
|
|
||
| include(${CMAKE_CURRENT_LIST_DIR}/HunterGate.cmake) | ||
| include(${CMAKE_CURRENT_LIST_DIR}/hunter-gate-url.cmake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| hunter_upload_password( | ||
| # REPO_OWNER + REPO = https://github.com/forexample/hunter-cache | ||
| REPO_OWNER "qdrvm" | ||
| REPO "hunter-binary-cache" | ||
|
|
||
| # USERNAME = warchant | ||
| USERNAME "$ENV{GITHUB_HUNTER_USERNAME}" | ||
|
|
||
| # PASSWORD = GitHub token saved as a secure environment variable | ||
| PASSWORD "$ENV{GITHUB_HUNTER_TOKEN}" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <scale/types.hpp> | ||
|
|
||
| namespace scale::detail { | ||
|
|
||
| template <typename T, typename F> | ||
| requires SimpleCodeableAggregate<T> | ||
| auto &as_decomposed(T &&v, const F &f) { | ||
xDimon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
xDimon marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| constexpr auto N = field_number_of<T>; | ||
| // clang-format off | ||
| if constexpr (N == 0) { | ||
| return f(); | ||
| } else if constexpr (N == 1) { | ||
| auto &[v1] = v; | ||
| return f(v1); | ||
| } else if constexpr (N == 2) { | ||
| auto &[v1, v2] = v; | ||
| return f(v1, v2); | ||
| } else if constexpr (N == 3) { | ||
| auto &[v1, v2, v3] = v; | ||
| return f(v1, v2, v3); | ||
| } else if constexpr (N == 4) { | ||
| auto &[v1, v2, v3, v4] = v; | ||
| return f(v1, v2, v3, v4); | ||
| } else if constexpr (N == 5) { | ||
| auto &[v1, v2, v3, v4, v5] = v; | ||
| return f(v1, v2, v3, v4, v5); | ||
| } else if constexpr (N == 6) { | ||
| auto &[v1, v2, v3, v4, v5, v6] = v; | ||
| return f(v1, v2, v3, v4, v5, v6); | ||
| } else if constexpr (N == 7) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7); | ||
| } else if constexpr (N == 8) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8); | ||
| } else if constexpr (N == 9) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9); | ||
| } else if constexpr (N == 10) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); | ||
| } else if constexpr (N == 11) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); | ||
| } else if constexpr (N == 12) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); | ||
| } else if constexpr (N == 13) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); | ||
| } else if constexpr (N == 14) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14); | ||
| } else if constexpr (N == 15) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15); | ||
| } else if constexpr (N == 16) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16); | ||
| } else if constexpr (N == 17) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17); | ||
| } else if constexpr (N == 18) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18); | ||
| } else if constexpr (N == 19) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19); | ||
| } else if constexpr (N == 20) { | ||
| auto &[v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20] = v; | ||
| return f(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20); | ||
| } else { | ||
| // We mustn't fall in here | ||
| static_assert(N <= MAX_FIELD_NUM, "Inconsistent value of MAX_FIELD_NUM"); | ||
| static_assert(N > MAX_FIELD_NUM, "No code for cover aggregate with such big amount of fields"); | ||
| } | ||
| // clang-format on | ||
| } | ||
|
|
||
| } // namespace scale::detail | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.