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 8 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
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
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.