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

Adding eosio structure attribute #1082

Draft
wants to merge 9 commits into
base: transaction-sponsorship
Choose a base branch
from
2 changes: 1 addition & 1 deletion eosio_llvm
Submodule eosio_llvm updated 1 files
+1 −1 tools/clang
1 change: 1 addition & 0 deletions libraries/eosiolib/contracts/eosio/contract.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define CONTRACT class [[eosio::contract]]
#define ACTION [[eosio::action]] void
#define TABLE struct [[eosio::table]]
#define STRUCTURE struct [[eosio::structure]]

namespace eosio {

Expand Down
73 changes: 73 additions & 0 deletions tests/toolchain/abigen-pass/structure_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "fee_payer",
"base": "",
"fields": [
{
"name": "payer",
"type": "name"
},
{
"name": "quantity",
"type": "uint64"
}
]
},
{
"name": "getpayer",
"base": "",
"fields": []
},
{
"name": "printfeepyr",
"base": "",
"fields": [
{
"name": "pyr",
"type": "fee_payer"
}
]
},
{
"name": "setfeepyr",
"base": "",
"fields": [
{
"name": "pyr",
"type": "fee_payer"
}
]
}
],
"actions": [
{
"name": "getpayer",
"type": "getpayer",
"ricardian_contract": ""
},
{
"name": "printfeepyr",
"type": "printfeepyr",
"ricardian_contract": ""
},
{
"name": "setfeepyr",
"type": "setfeepyr",
"ricardian_contract": ""
}
],
"tables": [],
"kv_tables": {},
"ricardian_clauses": [],
"variants": [],
"action_results": [
{
"name": "getpayer",
"result_type": "fee_payer"
}
]
}
33 changes: 33 additions & 0 deletions tests/toolchain/abigen-pass/structure_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <eosio/eosio.hpp>

using namespace eosio;

class [[eosio::contract]] structure_test : public eosio::contract {
public:
using contract::contract;

struct [[eosio::structure]] fee_payer {
name payer;
uint64_t quantity;
};

[[eosio::action]]
fee_payer getpayer() {
fee_payer pyr;
pyr.payer = _self;
pyr.quantity = 1000;

return pyr;
}

[[eosio::action]]
void setfeepyr(fee_payer& pyr) {
pyr.payer = "respyr"_n;
pyr.quantity = 10;
}

[[eosio::action]]
void printfeepyr(fee_payer pyr) {
print(pyr.payer, pyr.quantity);
}
};
9 changes: 9 additions & 0 deletions tests/toolchain/abigen-pass/structure_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests": [
{
"expected": {
"abi-file": "structure_test.abi"
}
}
]
}