Skip to content

Commit 96ccf12

Browse files
committed
bless bindgen output
1 parent f288d38 commit 96ccf12

File tree

136 files changed

+2691
-7239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2691
-7239
lines changed

crates/component-macro/tests/expanded/char.rs

+21-64
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<_T> TheWorldPre<_T> {
2727
pub fn new(
2828
instance_pre: wasmtime::component::InstancePre<_T>,
2929
) -> wasmtime::Result<Self> {
30-
let indices = TheWorldIndices::new(instance_pre.component())?;
30+
let indices = TheWorldIndices::new(&instance_pre)?;
3131
Ok(Self { instance_pre, indices })
3232
}
3333
pub fn engine(&self) -> &wasmtime::Engine {
@@ -82,11 +82,6 @@ pub struct TheWorldIndices {
8282
/// * If you've instantiated the instance yourself already
8383
/// then you can use [`TheWorld::new`].
8484
///
85-
/// * You can also access the guts of instantiation through
86-
/// [`TheWorldIndices::new_instance`] followed
87-
/// by [`TheWorldIndices::load`] to crate an instance of this
88-
/// type.
89-
///
9085
/// These methods are all equivalent to one another and move
9186
/// around the tradeoff of what work is performed when.
9287
///
@@ -105,29 +100,12 @@ const _: () = {
105100
///
106101
/// This method may fail if the component does not have the
107102
/// required exports.
108-
pub fn new(
109-
component: &wasmtime::component::Component,
103+
pub fn new<_T>(
104+
_instance_pre: &wasmtime::component::InstancePre<_T>,
110105
) -> wasmtime::Result<Self> {
111-
let _component = component;
112-
let interface0 = exports::foo::foo::chars::GuestIndices::new(_component)?;
113-
Ok(TheWorldIndices { interface0 })
114-
}
115-
/// Creates a new instance of [`TheWorldIndices`] from an
116-
/// instantiated component.
117-
///
118-
/// This method of creating a [`TheWorld`] will perform string
119-
/// lookups for all exports when this method is called. This
120-
/// will only succeed if the provided instance matches the
121-
/// requirements of [`TheWorld`].
122-
pub fn new_instance(
123-
mut store: impl wasmtime::AsContextMut,
124-
instance: &wasmtime::component::Instance,
125-
) -> wasmtime::Result<Self> {
126-
let _instance = instance;
127-
let interface0 = exports::foo::foo::chars::GuestIndices::new_instance(
128-
&mut store,
129-
_instance,
130-
)?;
106+
let _component = _instance_pre.component();
107+
let _instance_type = _instance_pre.instance_type();
108+
let interface0 = exports::foo::foo::chars::GuestIndices::new(_instance_pre)?;
131109
Ok(TheWorldIndices { interface0 })
132110
}
133111
/// Uses the indices stored in `self` to load an instance
@@ -140,6 +118,7 @@ const _: () = {
140118
mut store: impl wasmtime::AsContextMut,
141119
instance: &wasmtime::component::Instance,
142120
) -> wasmtime::Result<TheWorld> {
121+
let _ = &mut store;
143122
let _instance = instance;
144123
let interface0 = self.interface0.load(&mut store, &_instance)?;
145124
Ok(TheWorld { interface0 })
@@ -149,21 +128,21 @@ const _: () = {
149128
/// Convenience wrapper around [`TheWorldPre::new`] and
150129
/// [`TheWorldPre::instantiate`].
151130
pub fn instantiate<_T>(
152-
mut store: impl wasmtime::AsContextMut<Data = _T>,
131+
store: impl wasmtime::AsContextMut<Data = _T>,
153132
component: &wasmtime::component::Component,
154133
linker: &wasmtime::component::Linker<_T>,
155134
) -> wasmtime::Result<TheWorld> {
156135
let pre = linker.instantiate_pre(component)?;
157136
TheWorldPre::new(pre)?.instantiate(store)
158137
}
159-
/// Convenience wrapper around [`TheWorldIndices::new_instance`] and
138+
/// Convenience wrapper around [`TheWorldIndices::new`] and
160139
/// [`TheWorldIndices::load`].
161140
pub fn new(
162141
mut store: impl wasmtime::AsContextMut,
163142
instance: &wasmtime::component::Instance,
164143
) -> wasmtime::Result<TheWorld> {
165-
let indices = TheWorldIndices::new_instance(&mut store, instance)?;
166-
indices.load(store, instance)
144+
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
145+
indices.load(&mut store, instance)
167146
}
168147
pub fn add_to_linker<T, U>(
169148
linker: &mut wasmtime::component::Linker<T>,
@@ -279,45 +258,21 @@ pub mod exports {
279258
///
280259
/// This constructor can be used to front-load string lookups to find exports
281260
/// within a component.
282-
pub fn new(
283-
component: &wasmtime::component::Component,
261+
pub fn new<_T>(
262+
_instance_pre: &wasmtime::component::InstancePre<_T>,
284263
) -> wasmtime::Result<GuestIndices> {
285-
let instance = component
264+
let instance = _instance_pre
265+
.component()
286266
.get_export_index(None, "foo:foo/chars")
287267
.ok_or_else(|| {
288268
anyhow::anyhow!(
289269
"no exported instance named `foo:foo/chars`"
290270
)
291271
})?;
292-
Self::_new(|name| {
293-
component.get_export_index(Some(&instance), name)
294-
})
295-
}
296-
/// This constructor is similar to [`GuestIndices::new`] except that it
297-
/// performs string lookups after instantiation time.
298-
pub fn new_instance(
299-
mut store: impl wasmtime::AsContextMut,
300-
instance: &wasmtime::component::Instance,
301-
) -> wasmtime::Result<GuestIndices> {
302-
let instance_export = instance
303-
.get_export_index(&mut store, None, "foo:foo/chars")
304-
.ok_or_else(|| {
305-
anyhow::anyhow!(
306-
"no exported instance named `foo:foo/chars`"
307-
)
308-
})?;
309-
Self::_new(|name| {
310-
instance
311-
.get_export_index(&mut store, Some(&instance_export), name)
312-
})
313-
}
314-
fn _new(
315-
mut lookup: impl FnMut(
316-
&str,
317-
) -> Option<wasmtime::component::ComponentExportIndex>,
318-
) -> wasmtime::Result<GuestIndices> {
319272
let mut lookup = move |name| {
320-
lookup(name)
273+
_instance_pre
274+
.component()
275+
.get_export_index(Some(&instance), name)
321276
.ok_or_else(|| {
322277
anyhow::anyhow!(
323278
"instance export `foo:foo/chars` does \
@@ -338,9 +293,11 @@ pub mod exports {
338293
mut store: impl wasmtime::AsContextMut,
339294
instance: &wasmtime::component::Instance,
340295
) -> wasmtime::Result<Guest> {
296+
let _instance = instance;
297+
let _instance_pre = _instance.instance_pre(&store);
298+
let _instance_type = _instance_pre.instance_type();
341299
let mut store = store.as_context_mut();
342300
let _ = &mut store;
343-
let _instance = instance;
344301
let take_char = *_instance
345302
.get_typed_func::<(char,), ()>(&mut store, &self.take_char)?
346303
.func();

crates/component-macro/tests/expanded/char_async.rs

+21-64
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<_T> TheWorldPre<_T> {
2727
pub fn new(
2828
instance_pre: wasmtime::component::InstancePre<_T>,
2929
) -> wasmtime::Result<Self> {
30-
let indices = TheWorldIndices::new(instance_pre.component())?;
30+
let indices = TheWorldIndices::new(&instance_pre)?;
3131
Ok(Self { instance_pre, indices })
3232
}
3333
pub fn engine(&self) -> &wasmtime::Engine {
@@ -85,11 +85,6 @@ pub struct TheWorldIndices {
8585
/// * If you've instantiated the instance yourself already
8686
/// then you can use [`TheWorld::new`].
8787
///
88-
/// * You can also access the guts of instantiation through
89-
/// [`TheWorldIndices::new_instance`] followed
90-
/// by [`TheWorldIndices::load`] to crate an instance of this
91-
/// type.
92-
///
9388
/// These methods are all equivalent to one another and move
9489
/// around the tradeoff of what work is performed when.
9590
///
@@ -108,29 +103,12 @@ const _: () = {
108103
///
109104
/// This method may fail if the component does not have the
110105
/// required exports.
111-
pub fn new(
112-
component: &wasmtime::component::Component,
106+
pub fn new<_T>(
107+
_instance_pre: &wasmtime::component::InstancePre<_T>,
113108
) -> wasmtime::Result<Self> {
114-
let _component = component;
115-
let interface0 = exports::foo::foo::chars::GuestIndices::new(_component)?;
116-
Ok(TheWorldIndices { interface0 })
117-
}
118-
/// Creates a new instance of [`TheWorldIndices`] from an
119-
/// instantiated component.
120-
///
121-
/// This method of creating a [`TheWorld`] will perform string
122-
/// lookups for all exports when this method is called. This
123-
/// will only succeed if the provided instance matches the
124-
/// requirements of [`TheWorld`].
125-
pub fn new_instance(
126-
mut store: impl wasmtime::AsContextMut,
127-
instance: &wasmtime::component::Instance,
128-
) -> wasmtime::Result<Self> {
129-
let _instance = instance;
130-
let interface0 = exports::foo::foo::chars::GuestIndices::new_instance(
131-
&mut store,
132-
_instance,
133-
)?;
109+
let _component = _instance_pre.component();
110+
let _instance_type = _instance_pre.instance_type();
111+
let interface0 = exports::foo::foo::chars::GuestIndices::new(_instance_pre)?;
134112
Ok(TheWorldIndices { interface0 })
135113
}
136114
/// Uses the indices stored in `self` to load an instance
@@ -143,6 +121,7 @@ const _: () = {
143121
mut store: impl wasmtime::AsContextMut,
144122
instance: &wasmtime::component::Instance,
145123
) -> wasmtime::Result<TheWorld> {
124+
let _ = &mut store;
146125
let _instance = instance;
147126
let interface0 = self.interface0.load(&mut store, &_instance)?;
148127
Ok(TheWorld { interface0 })
@@ -152,7 +131,7 @@ const _: () = {
152131
/// Convenience wrapper around [`TheWorldPre::new`] and
153132
/// [`TheWorldPre::instantiate_async`].
154133
pub async fn instantiate_async<_T>(
155-
mut store: impl wasmtime::AsContextMut<Data = _T>,
134+
store: impl wasmtime::AsContextMut<Data = _T>,
156135
component: &wasmtime::component::Component,
157136
linker: &wasmtime::component::Linker<_T>,
158137
) -> wasmtime::Result<TheWorld>
@@ -162,14 +141,14 @@ const _: () = {
162141
let pre = linker.instantiate_pre(component)?;
163142
TheWorldPre::new(pre)?.instantiate_async(store).await
164143
}
165-
/// Convenience wrapper around [`TheWorldIndices::new_instance`] and
144+
/// Convenience wrapper around [`TheWorldIndices::new`] and
166145
/// [`TheWorldIndices::load`].
167146
pub fn new(
168147
mut store: impl wasmtime::AsContextMut,
169148
instance: &wasmtime::component::Instance,
170149
) -> wasmtime::Result<TheWorld> {
171-
let indices = TheWorldIndices::new_instance(&mut store, instance)?;
172-
indices.load(store, instance)
150+
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
151+
indices.load(&mut store, instance)
173152
}
174153
pub fn add_to_linker<T, U>(
175154
linker: &mut wasmtime::component::Linker<T>,
@@ -295,45 +274,21 @@ pub mod exports {
295274
///
296275
/// This constructor can be used to front-load string lookups to find exports
297276
/// within a component.
298-
pub fn new(
299-
component: &wasmtime::component::Component,
277+
pub fn new<_T>(
278+
_instance_pre: &wasmtime::component::InstancePre<_T>,
300279
) -> wasmtime::Result<GuestIndices> {
301-
let instance = component
280+
let instance = _instance_pre
281+
.component()
302282
.get_export_index(None, "foo:foo/chars")
303283
.ok_or_else(|| {
304284
anyhow::anyhow!(
305285
"no exported instance named `foo:foo/chars`"
306286
)
307287
})?;
308-
Self::_new(|name| {
309-
component.get_export_index(Some(&instance), name)
310-
})
311-
}
312-
/// This constructor is similar to [`GuestIndices::new`] except that it
313-
/// performs string lookups after instantiation time.
314-
pub fn new_instance(
315-
mut store: impl wasmtime::AsContextMut,
316-
instance: &wasmtime::component::Instance,
317-
) -> wasmtime::Result<GuestIndices> {
318-
let instance_export = instance
319-
.get_export_index(&mut store, None, "foo:foo/chars")
320-
.ok_or_else(|| {
321-
anyhow::anyhow!(
322-
"no exported instance named `foo:foo/chars`"
323-
)
324-
})?;
325-
Self::_new(|name| {
326-
instance
327-
.get_export_index(&mut store, Some(&instance_export), name)
328-
})
329-
}
330-
fn _new(
331-
mut lookup: impl FnMut(
332-
&str,
333-
) -> Option<wasmtime::component::ComponentExportIndex>,
334-
) -> wasmtime::Result<GuestIndices> {
335288
let mut lookup = move |name| {
336-
lookup(name)
289+
_instance_pre
290+
.component()
291+
.get_export_index(Some(&instance), name)
337292
.ok_or_else(|| {
338293
anyhow::anyhow!(
339294
"instance export `foo:foo/chars` does \
@@ -354,9 +309,11 @@ pub mod exports {
354309
mut store: impl wasmtime::AsContextMut,
355310
instance: &wasmtime::component::Instance,
356311
) -> wasmtime::Result<Guest> {
312+
let _instance = instance;
313+
let _instance_pre = _instance.instance_pre(&store);
314+
let _instance_type = _instance_pre.instance_type();
357315
let mut store = store.as_context_mut();
358316
let _ = &mut store;
359-
let _instance = instance;
360317
let take_char = *_instance
361318
.get_typed_func::<(char,), ()>(&mut store, &self.take_char)?
362319
.func();

0 commit comments

Comments
 (0)