Redesign abi generation for multi_index and singleton#201
Conversation
tools/include/eosio/abigen.hpp
Outdated
| if (!contract_class) { | ||
| contract_class = find_contract_class(decl->getASTContext()); | ||
| if (!contract_class) | ||
| CDT_ERROR("abigen_error", decl->getLocation(), "contract class not found"); |
There was a problem hiding this comment.
Will CDT_ERROR throw? Should just report the error and return false?
There was a problem hiding this comment.
good point. this one doesn't throw so I changed the macro
There was a problem hiding this comment.
It is not an error to not find the contract class, right? Just means this type is not in a contract class.
tools/include/eosio/abigen.hpp
Outdated
| if (!contract_class) { | ||
| contract_class = find_contract_class(decl->getASTContext()); | ||
| if (!contract_class) | ||
| CDT_ERROR("abigen_error", decl->getLocation(), "contract class not found"); |
There was a problem hiding this comment.
It is not an error to not find the contract class, right? Just means this type is not in a contract class.
tools/include/eosio/abigen.hpp
Outdated
| if (!contract_class) { | ||
| contract_class = find_contract_class(decl->getASTContext()); | ||
| if (!contract_class) | ||
| CDT_INTERNAL_ERROR("contract class not found"); |
There was a problem hiding this comment.
This is not an error, right? Just means it is not in the main eosio contract.
There was a problem hiding this comment.
this is a fatal error. we must have a contract class that corresponds to c++ filename or --contract option
There was a problem hiding this comment.
But will that always be accessible from the current translation unit?
There was a problem hiding this comment.
good point.. maybe you are right, we should just return false if no contract.
So this is abi generator. Currently we are not traversing translation units other than containing a main file:
https://github.com/AntelopeIO/cdt/blob/extend-abi-non-contract/tools/include/eosio/abigen.hpp#L878
However if we will change that in any way we may want to just return false. That is fine, if type is defined in main file, it will be picked up anyway.
|
Note:start |
After allowing non-table types inside
eosio::singletonwe extended types that can appear in abi. That way non contract singleton can appear in abi.That PR resolves #198 and defines the following rules:
multi_indexandsingletontables together with underlying structures appear in abi only if they are defined or aliased inside main contract class. If abi generator finds anymulti_indexorsingletonoutside main contract class without aliasing them inside main contract class (either bytypedeforusing) - those are ignored and won't appear in contract class.Change Description
API Changes
Documentation Additions