You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Debugging code generated inside macros is really hard. We should try to implement generic structs outside of the macro code and then just implement a tiny bit of glue code (for instance trait implementation of the part that is instance-specific) inside the macro.
I think current trait generator are following this pattern,
StorageMap, StorageDoubleMap IterableStorageMap etc... Only requires a few item to be implemented, which are for StorageMap:
/// Hasher. Used for generating final key.typeHasher:StorageHasher;/// Module prefix. Used for generating final key.fnmodule_prefix() -> &'static [u8];/// Storage prefix. Used for generating final key.fnstorage_prefix() -> &'static [u8];/// Convert an optional value retrieved from storage to the type queried.fnfrom_optional_value_to_query(v:Option<V>) -> Self::Query;/// Convert a query to an optional value into storage.fnfrom_query_to_optional_value(v:Self::Query) -> Option<V>;
So maybe we can improve other aspect of code generation, I think storage macros are quite fine now.
The idea with name_glue was to move the storage logic completely off the macro (so the only thing that stays there is just the prefix). The motivation was to make it easier to work on the logic (i.e. avoid getting in-macro errors).
Feel free to close the issue if you feel this is no longer relevant.
Debugging code generated inside macros is really hard. We should try to implement generic
structs
outside of the macro code and then just implement a tiny bit of glue code (for instance trait implementation of the part that is instance-specific) inside the macro.So instead of (
substrate/srml/support/procedural/src/storage/impls.rs
Line 139 in ed2faf4
we do something similar to:
The text was updated successfully, but these errors were encountered: