Rework only_interfaces to the interfaces field (#6210)
* Rework `only_interfaces` to the `interfaces` field * Fix the docs * Remove only_interfaces test from the component-macro package
This commit is contained in:
@@ -78,7 +78,16 @@ impl Parse for Config {
|
|||||||
Opt::Async(val) => opts.async_ = val,
|
Opt::Async(val) => opts.async_ = val,
|
||||||
Opt::TrappableErrorType(val) => opts.trappable_error_type = val,
|
Opt::TrappableErrorType(val) => opts.trappable_error_type = val,
|
||||||
Opt::DuplicateIfNecessary(val) => opts.duplicate_if_necessary = val,
|
Opt::DuplicateIfNecessary(val) => opts.duplicate_if_necessary = val,
|
||||||
Opt::OnlyInterfaces(val) => opts.only_interfaces = val,
|
Opt::Interfaces(s) => {
|
||||||
|
if source.is_some() {
|
||||||
|
return Err(Error::new(s.span(), "cannot specify a second source"));
|
||||||
|
}
|
||||||
|
source = Some(Source::Inline(format!(
|
||||||
|
"default world interfaces {{ {} }}",
|
||||||
|
s.value()
|
||||||
|
)));
|
||||||
|
opts.only_interfaces = true;
|
||||||
|
}
|
||||||
Opt::With(val) => opts.with.extend(val),
|
Opt::With(val) => opts.with.extend(val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +145,7 @@ mod kw {
|
|||||||
syn::custom_keyword!(trappable_error_type);
|
syn::custom_keyword!(trappable_error_type);
|
||||||
syn::custom_keyword!(world);
|
syn::custom_keyword!(world);
|
||||||
syn::custom_keyword!(duplicate_if_necessary);
|
syn::custom_keyword!(duplicate_if_necessary);
|
||||||
syn::custom_keyword!(only_interfaces);
|
syn::custom_keyword!(interfaces);
|
||||||
syn::custom_keyword!(with);
|
syn::custom_keyword!(with);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +157,7 @@ enum Opt {
|
|||||||
Async(bool),
|
Async(bool),
|
||||||
TrappableErrorType(Vec<TrappableError>),
|
TrappableErrorType(Vec<TrappableError>),
|
||||||
DuplicateIfNecessary(bool),
|
DuplicateIfNecessary(bool),
|
||||||
OnlyInterfaces(bool),
|
Interfaces(syn::LitStr),
|
||||||
With(HashMap<String, String>),
|
With(HashMap<String, String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,10 +207,10 @@ impl Parse for Opt {
|
|||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
))
|
))
|
||||||
} else if l.peek(kw::only_interfaces) {
|
} else if l.peek(kw::interfaces) {
|
||||||
input.parse::<kw::only_interfaces>()?;
|
input.parse::<kw::interfaces>()?;
|
||||||
input.parse::<Token![:]>()?;
|
input.parse::<Token![:]>()?;
|
||||||
Ok(Opt::OnlyInterfaces(input.parse::<syn::LitBool>()?.value))
|
Ok(Opt::Interfaces(input.parse::<syn::LitStr>()?))
|
||||||
} else if l.peek(kw::with) {
|
} else if l.peek(kw::with) {
|
||||||
input.parse::<kw::with>()?;
|
input.parse::<kw::with>()?;
|
||||||
input.parse::<Token![:]>()?;
|
input.parse::<Token![:]>()?;
|
||||||
|
|||||||
@@ -21,13 +21,6 @@ macro_rules! gentest {
|
|||||||
duplicate_if_necessary: true,
|
duplicate_if_necessary: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
mod interfaces_only {
|
|
||||||
wasmtime::component::bindgen!({
|
|
||||||
path: $path,
|
|
||||||
world: $name,
|
|
||||||
only_interfaces: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// ...
|
// ...
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -292,11 +292,11 @@ pub(crate) use self::store::ComponentStoreData;
|
|||||||
/// interface::ErrorType: RustErrorType,
|
/// interface::ErrorType: RustErrorType,
|
||||||
/// },
|
/// },
|
||||||
///
|
///
|
||||||
/// // Restrict the code generated to what's needed for the imported
|
/// // Restrict the code generated to what's needed for the interface
|
||||||
/// // interfaces of the world file provided. This option is most useful
|
/// // imports in the inlined WIT document fragment.
|
||||||
/// // in conjunction with the `with` option that permits remapping of
|
/// interfaces: "
|
||||||
/// // interface names in generated code.
|
/// import foo: package.foo;
|
||||||
/// only_interfaces: true,
|
/// ",
|
||||||
///
|
///
|
||||||
/// // Remap interface names to module names, imported from elswhere.
|
/// // Remap interface names to module names, imported from elswhere.
|
||||||
/// // Using this option will prevent any code from being generated
|
/// // Using this option will prevent any code from being generated
|
||||||
|
|||||||
@@ -639,15 +639,10 @@ mod with_remapping {
|
|||||||
|
|
||||||
mod interfaces {
|
mod interfaces {
|
||||||
wasmtime::component::bindgen!({
|
wasmtime::component::bindgen!({
|
||||||
inline: "
|
interfaces: "
|
||||||
default world result-playground {
|
import imports: interface {
|
||||||
import imports: interface {
|
empty-error: func(a: float64) -> result<float64>
|
||||||
empty-error: func(a: float64) -> result<float64>
|
|
||||||
}
|
|
||||||
|
|
||||||
export empty-error: func(a: float64) -> result<float64>
|
|
||||||
}",
|
}",
|
||||||
only_interfaces: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user