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

Resolve #99: Fix abigen with int expression template arguments #100

Merged
merged 3 commits into from
Mar 20, 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
38 changes: 38 additions & 0 deletions tests/toolchain/abigen-pass/tagged_number_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "TaggedNumber_3472950412842106880",
"base": "",
"fields": [
{
"name": "value",
"type": "uint64"
}
]
},
{
"name": "test",
"base": "",
"fields": [
{
"name": "",
"type": "TaggedNumber_3472950412842106880"
}
]
}
],
"actions": [
{
"name": "test",
"type": "test",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"action_results": []
}
17 changes: 17 additions & 0 deletions tests/toolchain/abigen-pass/tagged_number_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <eosio/eosio.hpp>

using namespace eosio;

template<uint64_t Tag>
struct TaggedNumber {
uint64_t value;
};

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

[[eosio::action]]
void test(TaggedNumber<"a.tag"_n.value>) {
}
};
9 changes: 9 additions & 0 deletions tests/toolchain/abigen-pass/tagged_number_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tests" : [
{
"expected" : {
"abi-file" : "tagged_number_test.abi"
}
}
]
}
2 changes: 2 additions & 0 deletions tools/include/eosio/gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ struct generation_utils {
if (auto ce = llvm::dyn_cast<clang::CastExpr>(std::get<clang::Expr*>(arg))) {
auto il = llvm::dyn_cast<clang::IntegerLiteral>(ce->getSubExpr());
return std::to_string(il->getValue().getLimitedValue());
} else if (auto ce = llvm::dyn_cast<clang::ConstantExpr>(std::get<clang::Expr*>(arg))) {
return ce->getResultAsAPSInt().toString(10);
}
} else {
return std::get<llvm::APSInt>(arg).toString(10);
Expand Down