Skip to content

Commit

Permalink
#201 reivew concerns addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
dimas1185 committed Sep 22, 2023
1 parent 0d5973b commit 9abb751
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
15 changes: 3 additions & 12 deletions tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,20 +808,11 @@ namespace eosio { namespace cdt {
if (const auto* cxx_decl = llvm::dyn_cast<clang::CXXRecordDecl>(cur_decl)) {

if (cxx_decl->isEosioContract()) {
auto attr_name = cxx_decl->getEosioContractAttr()->getName().str();
auto name = attr_name.empty() ? cxx_decl->getName().str() : attr_name;
if (name == ag.get_contract_name())
auto attr_name = cxx_decl->getEosioContractAttr()->getName();
auto name = attr_name.empty() ? cxx_decl->getName() : attr_name;
if (name == llvm::StringRef(ag.get_contract_name()))
return cxx_decl;
}
else {
const auto* parent_decl = llvm::dyn_cast<clang::CXXRecordDecl>(cxx_decl->getParent());
if (parent_decl && parent_decl->isEosioContract()) {
auto attr_name = parent_decl->getEosioContractAttr()->getName().str();
auto name = attr_name.empty() ? parent_decl->getName().str() : attr_name;
if (name == ag.get_contract_name())
return parent_decl;
}
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions tools/include/eosio/gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct generation_utils {


inline void set_contract_name( const std::string& cn ) { contract_name = cn; }
inline std::string get_contract_name()const { return contract_name; }
inline const std::string& get_contract_name()const { return contract_name; }
static inline std::string get_parsed_contract_name() { return parsed_contract_name; }
inline void set_resource_dirs( const std::vector<std::string>& rd ) {
llvm::SmallString<128> cwd;
Expand Down Expand Up @@ -274,30 +274,30 @@ struct generation_utils {
}

static inline bool is_eosio_contract( const clang::CXXMethodDecl* decl, const std::string& cn ) {
std::string name = "";
llvm::StringRef name;
if (decl->isEosioContract())
name = decl->getEosioContractAttr()->getName();
else if (decl->getParent()->isEosioContract())
name = decl->getParent()->getEosioContractAttr()->getName();
if (name.empty()) {
name = decl->getParent()->getName().str();
name = decl->getParent()->getName();
}
parsed_contract_name = name;
parsed_contract_name = name.str();
return cn == parsed_contract_name;
}

static inline bool is_eosio_contract( const clang::CXXRecordDecl* decl, const std::string& cn ) {
std::string name = "";
llvm::StringRef name;
auto pd = llvm::dyn_cast<clang::CXXRecordDecl>(decl->getParent());
if (decl->isEosioContract()) {
auto nm = decl->getEosioContractAttr()->getName().str();
name = nm.empty() ? decl->getName().str() : nm;
auto nm = decl->getEosioContractAttr()->getName();
name = nm.empty() ? decl->getName() : nm;
}
else if (pd && pd->isEosioContract()) {
auto nm = pd->getEosioContractAttr()->getName().str();
name = nm.empty() ? pd->getName().str() : nm;
auto nm = pd->getEosioContractAttr()->getName();
name = nm.empty() ? pd->getName() : nm;
}
parsed_contract_name = name;
parsed_contract_name = name.str();
return cn == parsed_contract_name;
}

Expand Down

0 comments on commit 9abb751

Please sign in to comment.