Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Support std::array by adding ABI symbol T[N] #1196

Merged
merged 4 commits into from
Sep 8, 2021
Merged

Conversation

softprofe
Copy link
Contributor

@softprofe softprofe commented Aug 28, 2021

Change Description

EPE 948

The build crash was caused by std::array was not supported. After this change, cdt build is OK.
The running of wasm action is partly support , std::array can be used inside action, in structure, or nested using in structure.
However using std::array as a parameter of action is not supported so far.

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@softprofe softprofe requested a review from bogniq August 28, 2021 19:34
@softprofe softprofe changed the title Support std::array by add abi symbol T[N], eg int[4]. (int[] means ve… EPE 948 Support std::array by add abi symbol T[N], eg int[4]. (int[] means ve… Aug 28, 2021
@nksanthosh nksanthosh self-requested a review August 30, 2021 17:38
…rray<std::string,4>, 2> test, also add using_std_array.cpp/json under tool_chain
@bogniq bogniq requested a review from plroblox September 2, 2021 14:57
tests/toolchain/build-pass/using_std_array.cpp Outdated Show resolved Hide resolved
tools/include/eosio/gen.hpp Outdated Show resolved Hide resolved

struct my_struct {
uint32_t id;
std::array<std::array<std::string,4>,2> aastr;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use typedef here for above array of arrays like typedef std::arraystd::string,4 ary_str4 and then use array<ary_str4,2> as the type of above aastr.
Because so far any abi-type ending with [][] would result in failure when tring to use cleos to put data into nodeos, e.g if using vector<vector<uint16_t> > vv, then using cleos to set vv as shown at https://github.com/EOSIO/nested-container/blob/main/nestcontn2a/nestcontn2a.cpp#L392 would result in Error 3015004: The type defined in the ABI is invalid, Error Details: uint16[][], the problem currently can be resolved by typedef vector<uint16_t> vec_uint16, and then use vector<vec_uint16> vv, the corrsponding type of vv would be vec_uint16[], instead of uint16[][]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed, use typedef std::arraystd::string,4 array_string_4

Copy link
Collaborator

@bogniq bogniq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also suggest: 1. move the toolchain test using_std_array to abigen-pass and add json option abi-file pointing to the expected ABI file containing "type": "int32[32]" (see current nested_container under abigen-pass as an example); 2. shorten the PR title and move details into the PR description. Excellent work!

@softprofe
Copy link
Contributor Author

I would also suggest: 1. move the toolchain test using_std_array to abigen-pass and add json option abi-file pointing to the expected ABI file containing "type": "int32[32]" (see current nested_container under abigen-pass as an example); 2. shorten the PR title and move details into the PR description. Excellent work!

moved to abigen-pass

@plroblox plroblox changed the title EPE 948 Support std::array by add abi symbol T[N], eg int[4]. (int[] means ve… EPE 948 Support std::array by add abi symbol T[N] Sep 8, 2021
@softprofe softprofe changed the title EPE 948 Support std::array by add abi symbol T[N] Support std::array by adding abi symbol T[N] Sep 8, 2021
@bogniq bogniq self-requested a review September 8, 2021 21:11
Copy link
Collaborator

@bogniq bogniq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After other related PRs in abieos are done, let's revisit the complete solution for std::array support.

@softprofe softprofe merged commit 7f48328 into develop Sep 8, 2021
@bogniq bogniq changed the title Support std::array by adding abi symbol T[N] Support std::array by adding ABI symbol T[N] Nov 9, 2021
oschwaldp-oci referenced this pull request in eosnetworkfoundation/mandel.cdt Jul 15, 2022
Support std::array by adding abi symbol T[N]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants