Skip to content

Commit

Permalink
fix renaming problem
Browse files Browse the repository at this point in the history
  • Loading branch information
indirection42 committed Jul 31, 2024
1 parent ff9f40b commit 134d67f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions xcq-extension/procedural/src/decl_extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct Method {
}

fn call_enum_def(trait_ident: &Ident, methods: &[Method]) -> Result<ItemEnum> {
let xcq_primitives = generate_crate_access("xcq-primitives")?;
let mut variants = Punctuated::<Variant, Comma>::new();
for method in methods {
let name = &method.name;
Expand All @@ -79,7 +80,7 @@ fn call_enum_def(trait_ident: &Ident, methods: &[Method]) -> Result<ItemEnum> {
__Phantom(core::marker::PhantomData<Impl>)
));
Ok(parse_quote!(
#[derive(parity_scale_codec::Decode)]
#[derive(#xcq_primitives::deps::parity_scale_codec::Decode)]
pub enum Call<Impl: #trait_ident> {
#variants
}
Expand Down Expand Up @@ -123,7 +124,7 @@ fn dispatchable_impl(trait_ident: &Ident, methods: &[Method]) -> Result<ItemImpl

Ok(parse_quote! {
impl<Impl: #trait_ident> #xcq_extension::Dispatchable for Call<Impl> {
fn dispatch(self) -> Result<#xcq_primitives::umbrella::xcq_types::vec::Vec<u8>, #xcq_extension::DispatchError> {
fn dispatch(self) -> Result<#xcq_primitives::deps::xcq_types::vec::Vec<u8>, #xcq_extension::DispatchError> {
match self {
#( #pats => Ok(#method_calls.encode()),)*
Self::__Phantom(_) => unreachable!(),
Expand Down
17 changes: 8 additions & 9 deletions xcq-extension/procedural/src/runtime_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use syn::{
/// of the trait generated by the `decl_extensions`.
pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<TokenStream2> {
let xcq_primitives = generate_crate_access("xcq-primitives")?;
let umbrella = quote! { #xcq_primitives::umbrella };
let mut methods = Vec::new();

// Convert `<Self::Config as Config>::Associated` to `T::Associated` with `T:Config` bound
Expand Down Expand Up @@ -48,20 +47,20 @@ pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<Toke
inputs.push(quote!(
#xcq_primitives::metadata_ir::MethodParamMetadataIR {
name: #name,
ty: #umbrella::xcq_types::meta_type::<#ty>(),
ty: #xcq_primitives::deps::xcq_types::meta_type::<#ty>(),
}
));
}

let output = match &signature.output {
syn::ReturnType::Default => quote!(#umbrella::xcq_types::meta_type::<()>()),
syn::ReturnType::Default => quote!(#xcq_primitives::deps::xcq_types::meta_type::<()>()),
syn::ReturnType::Type(_, ty) => {
let mut ty = ty.clone();
if has_config {
replacer.visit_type_mut(&mut ty);
}
where_clause.push(get_type_param(&ty));
quote!(#umbrella::xcq_types::meta_type::<#ty>())
quote!(#xcq_primitives::deps::xcq_types::meta_type::<#ty>())
}
};

Expand All @@ -72,7 +71,7 @@ pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<Toke
#( #attrs )*
#xcq_primitives::metadata_ir::MethodMetadataIR {
name: #method_name,
inputs: #umbrella::xcq_types::vec![ #( #inputs, )* ],
inputs: #xcq_primitives::deps::xcq_types::vec![ #( #inputs, )* ],
output: #output,
}
));
Expand All @@ -96,7 +95,7 @@ pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<Toke
}
where_clause
.into_iter()
.map(|ty| parse_quote!(#ty: #umbrella::xcq_types::XcqTypeInfo + 'static))
.map(|ty| parse_quote!(#ty: #xcq_primitives::deps::xcq_types::XcqTypeInfo + 'static))
.for_each(|w| generics.make_where_clause().predicates.push(w));

let (impl_generics, _, where_clause) = generics.split_for_impl();
Expand All @@ -109,7 +108,7 @@ pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<Toke
{
#xcq_primitives::metadata_ir::ExtensionMetadataIR {
name: #trait_name,
methods: #xcq_primitives::umbrella::xcq_types::vec![ #( #methods, )* ],
methods: #xcq_primitives::deps::xcq_types::vec![ #( #methods, )* ],
}
}
))
Expand All @@ -120,7 +119,7 @@ pub fn generate_decl_metadata(decl: &ItemTrait, has_config: bool) -> Result<Toke
pub fn runtime_metadata() -> #xcq_primitives::metadata_ir::ExtensionMetadataIR {
#xcq_primitives::metadata_ir::ExtensionMetadataIR {
name: #trait_name,
methods: #xcq_primitives::umbrella::xcq_types::vec![ #( #methods, )* ],
methods: #xcq_primitives::deps::xcq_types::vec![ #( #methods, )* ],
}
}
))
Expand Down Expand Up @@ -203,7 +202,7 @@ pub fn generate_impl_metadata(impls: &[ItemImpl]) -> Result<TokenStream2> {
impl #extension_impl_name {
pub fn runtime_metadata() -> #xcq_primitives::metadata_ir::MetadataIR {
#xcq_primitives::metadata_ir::MetadataIR {
extensions: #xcq_primitives::umbrella::xcq_types::vec![ #( #metadata, )* ],
extensions: #xcq_primitives::deps::xcq_types::vec![ #( #metadata, )* ],
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion xcq-extension/tests/with_associated_types_works.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use parity_scale_codec::{Codec, Decode, Encode};
use xcq_extension::{decl_extensions, impl_extensions, ExtensionsExecutor, Guest, Input, InvokeSource, Method};
use xcq_primitives::deps::xcq_types::{PrimitiveType, XcqType};
use xcq_primitives::metadata::{ExtensionMetadata, Metadata, MethodMetadata, MethodParamMetadata};
use xcq_primitives::umbrella::xcq_types::{PrimitiveType, XcqType};

mod extension_core {
use super::*;
Expand Down
3 changes: 2 additions & 1 deletion xcq-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub type XcqResult = Result<XcqResponse, XcqError>;
pub mod metadata;
pub mod metadata_ir;

pub mod umbrella {
pub mod deps {
pub use parity_scale_codec;
pub use xcq_types;
}

0 comments on commit 134d67f

Please sign in to comment.