MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / parse

Method parse

crates/component-macro/src/bindgen.rs:78–190  ·  view source on GitHub ↗
(input: ParseStream<'_>)

Source from the content-addressed store, hash-verified

76
77impl Parse for Config {
78 fn parse(input: ParseStream<'_>) -> Result<Self> {
79 let call_site = Span::call_site();
80 let mut opts = Opts::default();
81 let mut world = None;
82 let mut inline = None;
83 let mut paths = Vec::new();
84 let mut imports_configured = false;
85 let mut exports_configured = false;
86 let mut include_generated_code_from_file = false;
87
88 if input.peek(token::Brace) {
89 let content;
90 syn::braced!(content in input);
91 let fields = Punctuated::<Opt, Token![,]>::parse_terminated(&content)?;
92 for field in fields.into_pairs() {
93 match field.into_value() {
94 Opt::Path(p) => {
95 paths.extend(p.into_iter().map(|p| p.value()));
96 }
97 Opt::World(s) => {
98 if world.is_some() {
99 return Err(Error::new(s.span(), "cannot specify second world"));
100 }
101 world = Some(s.value());
102 }
103 Opt::Inline(s) => {
104 if inline.is_some() {
105 return Err(Error::new(s.span(), "cannot specify second source"));
106 }
107 inline = Some(s.value());
108 }
109 Opt::Debug(val) => opts.debug = val,
110 Opt::TrappableErrorType(val) => opts.trappable_error_type = val,
111 Opt::Ownership(val) => opts.ownership = val,
112 Opt::Interfaces(s) => {
113 if inline.is_some() {
114 return Err(Error::new(s.span(), "cannot specify a second source"));
115 }
116 inline = Some(format!(
117 "
118 package wasmtime:component-macro-synthesized;
119
120 world interfaces {{
121 {}
122 }}
123 ",
124 s.value()
125 ));
126
127 if world.is_some() {
128 return Err(Error::new(
129 s.span(),
130 "cannot specify a world with `interfaces`",
131 ));
132 }
133 world = Some("wasmtime:component-macro-synthesized/interfaces".to_string());
134
135 opts.only_interfaces = true;

Callers

nothing calls this directly

Calls 15

parse_sourceFunction · 0.85
OkFunction · 0.85
DebugClass · 0.85
PathClass · 0.85
InlineInterface · 0.85
OwnershipEnum · 0.85
TrappableErrorTypeClass · 0.85
from_iterFunction · 0.85
parse_function_configFunction · 0.85
ExportsClass · 0.85
NameClass · 0.85
collectMethod · 0.80

Tested by

no test coverage detected