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

Fix getting wrong name of the table for singleton #125

Merged
merged 1 commit into from
Apr 6, 2023
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
45 changes: 45 additions & 0 deletions tests/toolchain/abigen-pass/singleton_contract.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "tbl_config",
"base": "",
"fields": [
{
"name": "y",
"type": "uint64"
},
{
"name": "x",
"type": "uint64"
}
]
},
{
"name": "whatever",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "whatever",
"type": "whatever",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "config",
"type": "tbl_config",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
21 changes: 21 additions & 0 deletions tests/toolchain/abigen-pass/singleton_contract.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
#include <eosio/name.hpp>
#include <eosio/singleton.hpp>

using namespace eosio;

class [[eosio::contract("singleton_contract")]] singleton_contract : public contract {
public:
using contract::contract;

[[eosio::action]]
void whatever() {};

struct [[eosio::table]] tbl_config {
uint64_t y;
uint64_t x;
};

typedef eosio::singleton<"config"_n, tbl_config> config;
};
10 changes: 10 additions & 0 deletions tests/toolchain/abigen-pass/singleton_contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tests" : [
{
"expected" : {
"abi-file" : "singleton_contract.abi"
}
}
]
}

2 changes: 1 addition & 1 deletion tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ namespace eosio { namespace cdt {
}
virtual bool VisitDecl(clang::Decl* decl) {
if (const auto* d = dyn_cast<clang::ClassTemplateSpecializationDecl>(decl)) {
if (d->getName() == "multi_index") {
if (d->getName() == "multi_index" || d->getName() == "singleton") {
ag.add_table(d->getTemplateArgs()[0].getAsIntegral().getExtValue(),
(clang::CXXRecordDecl*)((clang::RecordType*)d->getTemplateArgs()[1].getAsType().getTypePtr())->getDecl());
}
Expand Down