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

Commit

Permalink
Merge pull request #5459 from xJonathanLEI/abi_action_name
Browse files Browse the repository at this point in the history
Fixed Bug Ignoring Action Name in ABI Generation
  • Loading branch information
heifner authored Aug 28, 2018
2 parents 8399f32 + e6633a5 commit a4096cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libraries/abi_generator/abi_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,19 @@ bool abi_generator::inspect_type_methods_for_actions(const Decl* decl) { try {

// Try to get "action" annotation from method comment
bool raw_comment_is_action = false;
string action_name_from_comment;
const RawComment* raw_comment = ast_context->getRawCommentForDeclNoCache(method);
if(raw_comment != nullptr) {
SourceManager& source_manager = ast_context->getSourceManager();
string raw_text = raw_comment->getRawText(source_manager);
regex r(R"(@abi (action)((?: [a-z0-9]+)*))");
regex r(R"(@abi (action) ?((?:[a-z0-9]+)*))");
smatch smatch;
regex_search(raw_text, smatch, r);
raw_comment_is_action = smatch.size() == 3;

if (raw_comment_is_action) {
action_name_from_comment = smatch[2];
}
}

// Check if current method is listed the EOSIO_ABI macro
Expand Down Expand Up @@ -156,7 +161,8 @@ bool abi_generator::inspect_type_methods_for_actions(const Decl* decl) { try {

full_types[method_name] = method_name;

output->actions.push_back({method_name, method_name, rc[method_name]});
string action_name = action_name_from_comment.empty() ? method_name : action_name_from_comment;
output->actions.push_back({action_name, method_name, rc[method_name]});
at_least_one_action = true;
};

Expand Down

0 comments on commit a4096cb

Please sign in to comment.