Expand description
The ink! code generation.
This module defines everything the ink! procedural macro needs in order to generate Rust code for ink! smart contracts.
We avoid structuring things via hidden or private modules, this was the ink! v1 way of doing code generation and it was bug prone and hard to maintain.
What we do instead to generate code that is hidden from users is to
pack it into anonymous const
(so const _: () = { … };
) and connect
those to the outside world with private trait implementations.
You can see how the generated code looks by installing
cargo-expand
and executing cargo expand --manifest-path ./integration-tests/flipper/Cargo.toml
in
this repository.
Modules§
- reflect
- Definitions and utilities for ink! smart contract static reflection.
Macros§
- for_
each_ abi - Calls the given callback function once for each enabled ABI.
- generate_
abi_ impls - Generates code for all enabled ABIs by calling the given generator function for each
enabled ABI, and returns a
TokenStream
combining all generated ABI specific code. with the ABI as an argument.
Traits§
- Code
Generator - Types for which code can be generated by this crate.
Functions§
- generate_
code - Generates the entire code for the given ink! contract.
- generate_
type_ spec - Generates the ink! metadata for the given type.