This repository has been archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Update to latest changes in scale-info #5
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cd0783a
Update to latest changes in scale-info
montekki 7ee0ffa
Use cargo patch directive
montekki 0c03a18
Formatting
montekki 088cf1e
Support bitvec type
montekki 85a5604
Use root namespace
montekki 3090e4d
Fix root module name
montekki 4d584ef
Fix tests and bump dependencies
montekki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ authors = ["Andrew Jones <[email protected]>"] | |
edition = "2018" | ||
|
||
[dependencies] | ||
frame-metadata = { package = "frame-metadata", git = "https://github.com/paritytech/frame-metadata", branch = "aj-substrate", default-features = false, features = ["v13"] } | ||
frame-metadata = { package = "frame-metadata", git = "https://github.com/paritytech/frame-metadata", branch = "aj-substrate", default-features = false, features = ["v14"] } | ||
heck = "0.3.1" | ||
proc-macro2 = "1.0" | ||
quote = "1" | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
use proc_macro2::{Ident, Span, TokenStream as TokenStream2, TokenStream}; | ||
use quote::{format_ident, quote, ToTokens}; | ||
use scale_info::{ | ||
form::PortableForm, prelude::num::NonZeroU32, Field, PortableRegistry, Type, TypeDef, | ||
form::PortableForm, Field, PortableRegistry, Type, TypeDef, | ||
TypeDefPrimitive, | ||
}; | ||
use std::collections::{BTreeMap, HashSet}; | ||
|
@@ -60,7 +60,7 @@ impl<'a> TypeGenerator<'a> { | |
fn insert_type( | ||
&'a self, | ||
ty: Type<PortableForm>, | ||
id: NonZeroU32, | ||
id: u32, | ||
path: Vec<String>, | ||
root_mod_ident: &Ident, | ||
module: &mut Module<'a>, | ||
|
@@ -87,7 +87,7 @@ impl<'a> TypeGenerator<'a> { | |
/// If no type with the given id found in the type registry. | ||
pub fn resolve_type_path( | ||
&self, | ||
id: NonZeroU32, | ||
id: u32, | ||
parent_type_params: &[TypeParameter], | ||
) -> TypePath { | ||
if let Some(parent_type_param) = parent_type_params | ||
|
@@ -114,7 +114,7 @@ impl<'a> TypeGenerator<'a> { | |
TypeDef::Sequence(seq) => vec![seq.type_param().id()], | ||
TypeDef::Tuple(tuple) => tuple.fields().iter().map(|f| f.id()).collect(), | ||
TypeDef::Compact(compact) => vec![compact.type_param().id()], | ||
TypeDef::Phantom(phantom) => vec![phantom.type_param().id()], | ||
TypeDef::Phantom(_phantom) => vec![/* TODO [now]: this is not yet in the `aj-substrate` branch phantom.type_param().id() */], | ||
_ => ty.type_params().iter().map(|f| f.id()).collect(), | ||
}; | ||
|
||
|
@@ -328,11 +328,14 @@ impl<'a> ModuleType<'a> { | |
let mut fields_tokens = fields | ||
.iter() | ||
.map(|(name, ty, ty_name)| { | ||
let ty = ty_toks(ty_name, ty); | ||
if is_struct { | ||
quote! { pub #name: #ty } | ||
} else { | ||
quote! { #name: #ty } | ||
match ty_name { | ||
Some(ty_name) if is_struct => { | ||
let ty = ty_toks(ty_name, ty); | ||
quote! { pub #name: #ty } | ||
} | ||
_ => { | ||
quote! { #name: #ty } | ||
} | ||
} | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
@@ -364,11 +367,14 @@ impl<'a> ModuleType<'a> { | |
let mut fields_tokens = type_paths | ||
.iter() | ||
.map(|(ty, ty_name)| { | ||
let ty = ty_toks(ty_name, ty); | ||
if is_struct { | ||
quote! { pub #ty } | ||
} else { | ||
quote! { #ty } | ||
match ty_name { | ||
Some(ty_name) if is_struct => { | ||
let ty = ty_toks(ty_name, ty); | ||
quote! { pub #ty } | ||
} | ||
_ => { | ||
quote! { #ty } | ||
} | ||
} | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
@@ -506,11 +512,14 @@ impl TypePathType { | |
syn::Type::Path(path) | ||
} | ||
TypeDef::Phantom(_) => { | ||
/* TODO: [now]: As soon as branch `aj-substrate` is updated to contain new code for | ||
* TypeDefPhantom this goes back, use `()` for the time being. | ||
let type_param = params | ||
.iter() | ||
.next() | ||
.expect("a phantom type should have a single type parameter"); | ||
let type_path = syn::parse_quote! { core::marker::PhantomData<#type_param> }; | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, |
||
let type_path = syn::parse_quote! { core::marker::PhantomData<()> }; | ||
syn::Type::Path(type_path) | ||
} | ||
TypeDef::Compact(_) => { | ||
|
@@ -540,7 +549,7 @@ impl TypePathType { | |
|
||
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
pub struct TypeParameter { | ||
concrete_type_id: NonZeroU32, | ||
concrete_type_id: u32, | ||
name: proc_macro2::Ident, | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Actually I have remove that here: paritytech/scale-info#96, and
aj-substrate
includes that PR. We need to figure out whether we still have enough information to generate the correct types. We probably should, but it needs testing out on this side.