-
Notifications
You must be signed in to change notification settings - Fork 32
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will CDT_ERROR
throw? Should just report the error and return false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. this one doesn't throw so I changed the macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not an error, right? Just means it is not in the main eosio contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But will that always be accessible from the current translation unit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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::singleton
we 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_index
andsingleton
tables together with underlying structures appear in abi only if they are defined or aliased inside main contract class. If abi generator finds anymulti_index
orsingleton
outside main contract class without aliasing them inside main contract class (either bytypedef
orusing
) - those are ignored and won't appear in contract class.Change Description
API Changes
Documentation Additions