Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/component-macro/tests/expanded/conventions.rs
1692 views
1
/// Auto-generated bindings for a pre-instantiated version of a
2
/// component which implements the world `the-world`.
3
///
4
/// This structure is created through [`TheWorldPre::new`] which
5
/// takes a [`InstancePre`](wasmtime::component::InstancePre) that
6
/// has been created through a [`Linker`](wasmtime::component::Linker).
7
///
8
/// For more information see [`TheWorld`] as well.
9
pub struct TheWorldPre<T: 'static> {
10
instance_pre: wasmtime::component::InstancePre<T>,
11
indices: TheWorldIndices,
12
}
13
impl<T: 'static> Clone for TheWorldPre<T> {
14
fn clone(&self) -> Self {
15
Self {
16
instance_pre: self.instance_pre.clone(),
17
indices: self.indices.clone(),
18
}
19
}
20
}
21
impl<_T: 'static> TheWorldPre<_T> {
22
/// Creates a new copy of `TheWorldPre` bindings which can then
23
/// be used to instantiate into a particular store.
24
///
25
/// This method may fail if the component behind `instance_pre`
26
/// does not have the required exports.
27
pub fn new(
28
instance_pre: wasmtime::component::InstancePre<_T>,
29
) -> wasmtime::Result<Self> {
30
let indices = TheWorldIndices::new(&instance_pre)?;
31
Ok(Self { instance_pre, indices })
32
}
33
pub fn engine(&self) -> &wasmtime::Engine {
34
self.instance_pre.engine()
35
}
36
pub fn instance_pre(&self) -> &wasmtime::component::InstancePre<_T> {
37
&self.instance_pre
38
}
39
/// Instantiates a new instance of [`TheWorld`] within the
40
/// `store` provided.
41
///
42
/// This function will use `self` as the pre-instantiated
43
/// instance to perform instantiation. Afterwards the preloaded
44
/// indices in `self` are used to lookup all exports on the
45
/// resulting instance.
46
pub fn instantiate(
47
&self,
48
mut store: impl wasmtime::AsContextMut<Data = _T>,
49
) -> wasmtime::Result<TheWorld> {
50
let mut store = store.as_context_mut();
51
let instance = self.instance_pre.instantiate(&mut store)?;
52
self.indices.load(&mut store, &instance)
53
}
54
}
55
impl<_T: Send + 'static> TheWorldPre<_T> {
56
/// Same as [`Self::instantiate`], except with `async`.
57
pub async fn instantiate_async(
58
&self,
59
mut store: impl wasmtime::AsContextMut<Data = _T>,
60
) -> wasmtime::Result<TheWorld> {
61
let mut store = store.as_context_mut();
62
let instance = self.instance_pre.instantiate_async(&mut store).await?;
63
self.indices.load(&mut store, &instance)
64
}
65
}
66
/// Auto-generated bindings for index of the exports of
67
/// `the-world`.
68
///
69
/// This is an implementation detail of [`TheWorldPre`] and can
70
/// be constructed if needed as well.
71
///
72
/// For more information see [`TheWorld`] as well.
73
#[derive(Clone)]
74
pub struct TheWorldIndices {
75
interface0: exports::foo::foo::conventions::GuestIndices,
76
}
77
/// Auto-generated bindings for an instance a component which
78
/// implements the world `the-world`.
79
///
80
/// This structure can be created through a number of means
81
/// depending on your requirements and what you have on hand:
82
///
83
/// * The most convenient way is to use
84
/// [`TheWorld::instantiate`] which only needs a
85
/// [`Store`], [`Component`], and [`Linker`].
86
///
87
/// * Alternatively you can create a [`TheWorldPre`] ahead of
88
/// time with a [`Component`] to front-load string lookups
89
/// of exports once instead of per-instantiation. This
90
/// method then uses [`TheWorldPre::instantiate`] to
91
/// create a [`TheWorld`].
92
///
93
/// * If you've instantiated the instance yourself already
94
/// then you can use [`TheWorld::new`].
95
///
96
/// These methods are all equivalent to one another and move
97
/// around the tradeoff of what work is performed when.
98
///
99
/// [`Store`]: wasmtime::Store
100
/// [`Component`]: wasmtime::component::Component
101
/// [`Linker`]: wasmtime::component::Linker
102
pub struct TheWorld {
103
interface0: exports::foo::foo::conventions::Guest,
104
}
105
const _: () = {
106
#[allow(unused_imports)]
107
use wasmtime::component::__internal::anyhow;
108
impl TheWorldIndices {
109
/// Creates a new copy of `TheWorldIndices` bindings which can then
110
/// be used to instantiate into a particular store.
111
///
112
/// This method may fail if the component does not have the
113
/// required exports.
114
pub fn new<_T>(
115
_instance_pre: &wasmtime::component::InstancePre<_T>,
116
) -> wasmtime::Result<Self> {
117
let _component = _instance_pre.component();
118
let _instance_type = _instance_pre.instance_type();
119
let interface0 = exports::foo::foo::conventions::GuestIndices::new(
120
_instance_pre,
121
)?;
122
Ok(TheWorldIndices { interface0 })
123
}
124
/// Uses the indices stored in `self` to load an instance
125
/// of [`TheWorld`] from the instance provided.
126
///
127
/// Note that at this time this method will additionally
128
/// perform type-checks of all exports.
129
pub fn load(
130
&self,
131
mut store: impl wasmtime::AsContextMut,
132
instance: &wasmtime::component::Instance,
133
) -> wasmtime::Result<TheWorld> {
134
let _ = &mut store;
135
let _instance = instance;
136
let interface0 = self.interface0.load(&mut store, &_instance)?;
137
Ok(TheWorld { interface0 })
138
}
139
}
140
impl TheWorld {
141
/// Convenience wrapper around [`TheWorldPre::new`] and
142
/// [`TheWorldPre::instantiate`].
143
pub fn instantiate<_T>(
144
store: impl wasmtime::AsContextMut<Data = _T>,
145
component: &wasmtime::component::Component,
146
linker: &wasmtime::component::Linker<_T>,
147
) -> wasmtime::Result<TheWorld> {
148
let pre = linker.instantiate_pre(component)?;
149
TheWorldPre::new(pre)?.instantiate(store)
150
}
151
/// Convenience wrapper around [`TheWorldIndices::new`] and
152
/// [`TheWorldIndices::load`].
153
pub fn new(
154
mut store: impl wasmtime::AsContextMut,
155
instance: &wasmtime::component::Instance,
156
) -> wasmtime::Result<TheWorld> {
157
let indices = TheWorldIndices::new(&instance.instance_pre(&store))?;
158
indices.load(&mut store, instance)
159
}
160
/// Convenience wrapper around [`TheWorldPre::new`] and
161
/// [`TheWorldPre::instantiate_async`].
162
pub async fn instantiate_async<_T>(
163
store: impl wasmtime::AsContextMut<Data = _T>,
164
component: &wasmtime::component::Component,
165
linker: &wasmtime::component::Linker<_T>,
166
) -> wasmtime::Result<TheWorld>
167
where
168
_T: Send,
169
{
170
let pre = linker.instantiate_pre(component)?;
171
TheWorldPre::new(pre)?.instantiate_async(store).await
172
}
173
pub fn add_to_linker<T, D>(
174
linker: &mut wasmtime::component::Linker<T>,
175
host_getter: fn(&mut T) -> D::Data<'_>,
176
) -> wasmtime::Result<()>
177
where
178
D: foo::foo::conventions::HostWithStore,
179
for<'a> D::Data<'a>: foo::foo::conventions::Host,
180
T: 'static,
181
{
182
foo::foo::conventions::add_to_linker::<T, D>(linker, host_getter)?;
183
Ok(())
184
}
185
pub fn foo_foo_conventions(&self) -> &exports::foo::foo::conventions::Guest {
186
&self.interface0
187
}
188
}
189
};
190
pub mod foo {
191
pub mod foo {
192
#[allow(clippy::all)]
193
pub mod conventions {
194
#[allow(unused_imports)]
195
use wasmtime::component::__internal::{anyhow, Box};
196
#[derive(wasmtime::component::ComponentType)]
197
#[derive(wasmtime::component::Lift)]
198
#[derive(wasmtime::component::Lower)]
199
#[component(record)]
200
#[derive(Clone, Copy)]
201
pub struct LudicrousSpeed {
202
#[component(name = "how-fast-are-you-going")]
203
pub how_fast_are_you_going: u32,
204
#[component(name = "i-am-going-extremely-slow")]
205
pub i_am_going_extremely_slow: u64,
206
}
207
impl core::fmt::Debug for LudicrousSpeed {
208
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
209
f.debug_struct("LudicrousSpeed")
210
.field("how-fast-are-you-going", &self.how_fast_are_you_going)
211
.field(
212
"i-am-going-extremely-slow",
213
&self.i_am_going_extremely_slow,
214
)
215
.finish()
216
}
217
}
218
const _: () = {
219
assert!(
220
16 == < LudicrousSpeed as wasmtime::component::ComponentType
221
>::SIZE32
222
);
223
assert!(
224
8 == < LudicrousSpeed as wasmtime::component::ComponentType
225
>::ALIGN32
226
);
227
};
228
pub trait HostWithStore: wasmtime::component::HasData {}
229
impl<_T: ?Sized> HostWithStore for _T
230
where
231
_T: wasmtime::component::HasData,
232
{}
233
pub trait Host {
234
fn kebab_case(&mut self) -> ();
235
fn foo(&mut self, x: LudicrousSpeed) -> ();
236
fn function_with_dashes(&mut self) -> ();
237
fn function_with_no_weird_characters(&mut self) -> ();
238
fn apple(&mut self) -> ();
239
fn apple_pear(&mut self) -> ();
240
fn apple_pear_grape(&mut self) -> ();
241
fn a0(&mut self) -> ();
242
/// Comment out identifiers that collide when mapped to snake_case, for now; see
243
/// https://github.com/WebAssembly/component-model/issues/118
244
/// APPLE: func()
245
/// APPLE-pear-GRAPE: func()
246
/// apple-PEAR-grape: func()
247
fn is_xml(&mut self) -> ();
248
fn explicit(&mut self) -> ();
249
fn explicit_kebab(&mut self) -> ();
250
/// Identifiers with the same name as keywords are quoted.
251
fn bool(&mut self) -> ();
252
}
253
impl<_T: Host + ?Sized> Host for &mut _T {
254
fn kebab_case(&mut self) -> () {
255
Host::kebab_case(*self)
256
}
257
fn foo(&mut self, x: LudicrousSpeed) -> () {
258
Host::foo(*self, x)
259
}
260
fn function_with_dashes(&mut self) -> () {
261
Host::function_with_dashes(*self)
262
}
263
fn function_with_no_weird_characters(&mut self) -> () {
264
Host::function_with_no_weird_characters(*self)
265
}
266
fn apple(&mut self) -> () {
267
Host::apple(*self)
268
}
269
fn apple_pear(&mut self) -> () {
270
Host::apple_pear(*self)
271
}
272
fn apple_pear_grape(&mut self) -> () {
273
Host::apple_pear_grape(*self)
274
}
275
fn a0(&mut self) -> () {
276
Host::a0(*self)
277
}
278
/// Comment out identifiers that collide when mapped to snake_case, for now; see
279
/// https://github.com/WebAssembly/component-model/issues/118
280
/// APPLE: func()
281
/// APPLE-pear-GRAPE: func()
282
/// apple-PEAR-grape: func()
283
fn is_xml(&mut self) -> () {
284
Host::is_xml(*self)
285
}
286
fn explicit(&mut self) -> () {
287
Host::explicit(*self)
288
}
289
fn explicit_kebab(&mut self) -> () {
290
Host::explicit_kebab(*self)
291
}
292
/// Identifiers with the same name as keywords are quoted.
293
fn bool(&mut self) -> () {
294
Host::bool(*self)
295
}
296
}
297
pub fn add_to_linker<T, D>(
298
linker: &mut wasmtime::component::Linker<T>,
299
host_getter: fn(&mut T) -> D::Data<'_>,
300
) -> wasmtime::Result<()>
301
where
302
D: HostWithStore,
303
for<'a> D::Data<'a>: Host,
304
T: 'static,
305
{
306
let mut inst = linker.instance("foo:foo/conventions")?;
307
inst.func_wrap(
308
"kebab-case",
309
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
310
let host = &mut host_getter(caller.data_mut());
311
let r = Host::kebab_case(host);
312
Ok(r)
313
},
314
)?;
315
inst.func_wrap(
316
"foo",
317
move |
318
mut caller: wasmtime::StoreContextMut<'_, T>,
319
(arg0,): (LudicrousSpeed,)|
320
{
321
let host = &mut host_getter(caller.data_mut());
322
let r = Host::foo(host, arg0);
323
Ok(r)
324
},
325
)?;
326
inst.func_wrap(
327
"function-with-dashes",
328
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
329
let host = &mut host_getter(caller.data_mut());
330
let r = Host::function_with_dashes(host);
331
Ok(r)
332
},
333
)?;
334
inst.func_wrap(
335
"function-with-no-weird-characters",
336
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
337
let host = &mut host_getter(caller.data_mut());
338
let r = Host::function_with_no_weird_characters(host);
339
Ok(r)
340
},
341
)?;
342
inst.func_wrap(
343
"apple",
344
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
345
let host = &mut host_getter(caller.data_mut());
346
let r = Host::apple(host);
347
Ok(r)
348
},
349
)?;
350
inst.func_wrap(
351
"apple-pear",
352
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
353
let host = &mut host_getter(caller.data_mut());
354
let r = Host::apple_pear(host);
355
Ok(r)
356
},
357
)?;
358
inst.func_wrap(
359
"apple-pear-grape",
360
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
361
let host = &mut host_getter(caller.data_mut());
362
let r = Host::apple_pear_grape(host);
363
Ok(r)
364
},
365
)?;
366
inst.func_wrap(
367
"a0",
368
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
369
let host = &mut host_getter(caller.data_mut());
370
let r = Host::a0(host);
371
Ok(r)
372
},
373
)?;
374
inst.func_wrap(
375
"is-XML",
376
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
377
let host = &mut host_getter(caller.data_mut());
378
let r = Host::is_xml(host);
379
Ok(r)
380
},
381
)?;
382
inst.func_wrap(
383
"explicit",
384
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
385
let host = &mut host_getter(caller.data_mut());
386
let r = Host::explicit(host);
387
Ok(r)
388
},
389
)?;
390
inst.func_wrap(
391
"explicit-kebab",
392
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
393
let host = &mut host_getter(caller.data_mut());
394
let r = Host::explicit_kebab(host);
395
Ok(r)
396
},
397
)?;
398
inst.func_wrap(
399
"bool",
400
move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
401
let host = &mut host_getter(caller.data_mut());
402
let r = Host::bool(host);
403
Ok(r)
404
},
405
)?;
406
Ok(())
407
}
408
}
409
}
410
}
411
pub mod exports {
412
pub mod foo {
413
pub mod foo {
414
#[allow(clippy::all)]
415
pub mod conventions {
416
#[allow(unused_imports)]
417
use wasmtime::component::__internal::{anyhow, Box};
418
#[derive(wasmtime::component::ComponentType)]
419
#[derive(wasmtime::component::Lift)]
420
#[derive(wasmtime::component::Lower)]
421
#[component(record)]
422
#[derive(Clone, Copy)]
423
pub struct LudicrousSpeed {
424
#[component(name = "how-fast-are-you-going")]
425
pub how_fast_are_you_going: u32,
426
#[component(name = "i-am-going-extremely-slow")]
427
pub i_am_going_extremely_slow: u64,
428
}
429
impl core::fmt::Debug for LudicrousSpeed {
430
fn fmt(
431
&self,
432
f: &mut core::fmt::Formatter<'_>,
433
) -> core::fmt::Result {
434
f.debug_struct("LudicrousSpeed")
435
.field(
436
"how-fast-are-you-going",
437
&self.how_fast_are_you_going,
438
)
439
.field(
440
"i-am-going-extremely-slow",
441
&self.i_am_going_extremely_slow,
442
)
443
.finish()
444
}
445
}
446
const _: () = {
447
assert!(
448
16 == < LudicrousSpeed as wasmtime::component::ComponentType
449
>::SIZE32
450
);
451
assert!(
452
8 == < LudicrousSpeed as wasmtime::component::ComponentType
453
>::ALIGN32
454
);
455
};
456
pub struct Guest {
457
kebab_case: wasmtime::component::Func,
458
foo: wasmtime::component::Func,
459
function_with_dashes: wasmtime::component::Func,
460
function_with_no_weird_characters: wasmtime::component::Func,
461
apple: wasmtime::component::Func,
462
apple_pear: wasmtime::component::Func,
463
apple_pear_grape: wasmtime::component::Func,
464
a0: wasmtime::component::Func,
465
is_xml: wasmtime::component::Func,
466
explicit: wasmtime::component::Func,
467
explicit_kebab: wasmtime::component::Func,
468
bool: wasmtime::component::Func,
469
}
470
#[derive(Clone)]
471
pub struct GuestIndices {
472
kebab_case: wasmtime::component::ComponentExportIndex,
473
foo: wasmtime::component::ComponentExportIndex,
474
function_with_dashes: wasmtime::component::ComponentExportIndex,
475
function_with_no_weird_characters: wasmtime::component::ComponentExportIndex,
476
apple: wasmtime::component::ComponentExportIndex,
477
apple_pear: wasmtime::component::ComponentExportIndex,
478
apple_pear_grape: wasmtime::component::ComponentExportIndex,
479
a0: wasmtime::component::ComponentExportIndex,
480
is_xml: wasmtime::component::ComponentExportIndex,
481
explicit: wasmtime::component::ComponentExportIndex,
482
explicit_kebab: wasmtime::component::ComponentExportIndex,
483
bool: wasmtime::component::ComponentExportIndex,
484
}
485
impl GuestIndices {
486
/// Constructor for [`GuestIndices`] which takes a
487
/// [`Component`](wasmtime::component::Component) as input and can be executed
488
/// before instantiation.
489
///
490
/// This constructor can be used to front-load string lookups to find exports
491
/// within a component.
492
pub fn new<_T>(
493
_instance_pre: &wasmtime::component::InstancePre<_T>,
494
) -> wasmtime::Result<GuestIndices> {
495
let instance = _instance_pre
496
.component()
497
.get_export_index(None, "foo:foo/conventions")
498
.ok_or_else(|| {
499
anyhow::anyhow!(
500
"no exported instance named `foo:foo/conventions`"
501
)
502
})?;
503
let mut lookup = move |name| {
504
_instance_pre
505
.component()
506
.get_export_index(Some(&instance), name)
507
.ok_or_else(|| {
508
anyhow::anyhow!(
509
"instance export `foo:foo/conventions` does \
510
not have export `{name}`"
511
)
512
})
513
};
514
let _ = &mut lookup;
515
let kebab_case = lookup("kebab-case")?;
516
let foo = lookup("foo")?;
517
let function_with_dashes = lookup("function-with-dashes")?;
518
let function_with_no_weird_characters = lookup(
519
"function-with-no-weird-characters",
520
)?;
521
let apple = lookup("apple")?;
522
let apple_pear = lookup("apple-pear")?;
523
let apple_pear_grape = lookup("apple-pear-grape")?;
524
let a0 = lookup("a0")?;
525
let is_xml = lookup("is-XML")?;
526
let explicit = lookup("explicit")?;
527
let explicit_kebab = lookup("explicit-kebab")?;
528
let bool = lookup("bool")?;
529
Ok(GuestIndices {
530
kebab_case,
531
foo,
532
function_with_dashes,
533
function_with_no_weird_characters,
534
apple,
535
apple_pear,
536
apple_pear_grape,
537
a0,
538
is_xml,
539
explicit,
540
explicit_kebab,
541
bool,
542
})
543
}
544
pub fn load(
545
&self,
546
mut store: impl wasmtime::AsContextMut,
547
instance: &wasmtime::component::Instance,
548
) -> wasmtime::Result<Guest> {
549
let _instance = instance;
550
let _instance_pre = _instance.instance_pre(&store);
551
let _instance_type = _instance_pre.instance_type();
552
let mut store = store.as_context_mut();
553
let _ = &mut store;
554
let kebab_case = *_instance
555
.get_typed_func::<(), ()>(&mut store, &self.kebab_case)?
556
.func();
557
let foo = *_instance
558
.get_typed_func::<
559
(LudicrousSpeed,),
560
(),
561
>(&mut store, &self.foo)?
562
.func();
563
let function_with_dashes = *_instance
564
.get_typed_func::<
565
(),
566
(),
567
>(&mut store, &self.function_with_dashes)?
568
.func();
569
let function_with_no_weird_characters = *_instance
570
.get_typed_func::<
571
(),
572
(),
573
>(&mut store, &self.function_with_no_weird_characters)?
574
.func();
575
let apple = *_instance
576
.get_typed_func::<(), ()>(&mut store, &self.apple)?
577
.func();
578
let apple_pear = *_instance
579
.get_typed_func::<(), ()>(&mut store, &self.apple_pear)?
580
.func();
581
let apple_pear_grape = *_instance
582
.get_typed_func::<
583
(),
584
(),
585
>(&mut store, &self.apple_pear_grape)?
586
.func();
587
let a0 = *_instance
588
.get_typed_func::<(), ()>(&mut store, &self.a0)?
589
.func();
590
let is_xml = *_instance
591
.get_typed_func::<(), ()>(&mut store, &self.is_xml)?
592
.func();
593
let explicit = *_instance
594
.get_typed_func::<(), ()>(&mut store, &self.explicit)?
595
.func();
596
let explicit_kebab = *_instance
597
.get_typed_func::<(), ()>(&mut store, &self.explicit_kebab)?
598
.func();
599
let bool = *_instance
600
.get_typed_func::<(), ()>(&mut store, &self.bool)?
601
.func();
602
Ok(Guest {
603
kebab_case,
604
foo,
605
function_with_dashes,
606
function_with_no_weird_characters,
607
apple,
608
apple_pear,
609
apple_pear_grape,
610
a0,
611
is_xml,
612
explicit,
613
explicit_kebab,
614
bool,
615
})
616
}
617
}
618
impl Guest {
619
pub fn call_kebab_case<S: wasmtime::AsContextMut>(
620
&self,
621
mut store: S,
622
) -> wasmtime::Result<()> {
623
let callee = unsafe {
624
wasmtime::component::TypedFunc::<
625
(),
626
(),
627
>::new_unchecked(self.kebab_case)
628
};
629
let () = callee.call(store.as_context_mut(), ())?;
630
callee.post_return(store.as_context_mut())?;
631
Ok(())
632
}
633
pub fn call_foo<S: wasmtime::AsContextMut>(
634
&self,
635
mut store: S,
636
arg0: LudicrousSpeed,
637
) -> wasmtime::Result<()> {
638
let callee = unsafe {
639
wasmtime::component::TypedFunc::<
640
(LudicrousSpeed,),
641
(),
642
>::new_unchecked(self.foo)
643
};
644
let () = callee.call(store.as_context_mut(), (arg0,))?;
645
callee.post_return(store.as_context_mut())?;
646
Ok(())
647
}
648
pub fn call_function_with_dashes<S: wasmtime::AsContextMut>(
649
&self,
650
mut store: S,
651
) -> wasmtime::Result<()> {
652
let callee = unsafe {
653
wasmtime::component::TypedFunc::<
654
(),
655
(),
656
>::new_unchecked(self.function_with_dashes)
657
};
658
let () = callee.call(store.as_context_mut(), ())?;
659
callee.post_return(store.as_context_mut())?;
660
Ok(())
661
}
662
pub fn call_function_with_no_weird_characters<
663
S: wasmtime::AsContextMut,
664
>(&self, mut store: S) -> wasmtime::Result<()> {
665
let callee = unsafe {
666
wasmtime::component::TypedFunc::<
667
(),
668
(),
669
>::new_unchecked(self.function_with_no_weird_characters)
670
};
671
let () = callee.call(store.as_context_mut(), ())?;
672
callee.post_return(store.as_context_mut())?;
673
Ok(())
674
}
675
pub fn call_apple<S: wasmtime::AsContextMut>(
676
&self,
677
mut store: S,
678
) -> wasmtime::Result<()> {
679
let callee = unsafe {
680
wasmtime::component::TypedFunc::<
681
(),
682
(),
683
>::new_unchecked(self.apple)
684
};
685
let () = callee.call(store.as_context_mut(), ())?;
686
callee.post_return(store.as_context_mut())?;
687
Ok(())
688
}
689
pub fn call_apple_pear<S: wasmtime::AsContextMut>(
690
&self,
691
mut store: S,
692
) -> wasmtime::Result<()> {
693
let callee = unsafe {
694
wasmtime::component::TypedFunc::<
695
(),
696
(),
697
>::new_unchecked(self.apple_pear)
698
};
699
let () = callee.call(store.as_context_mut(), ())?;
700
callee.post_return(store.as_context_mut())?;
701
Ok(())
702
}
703
pub fn call_apple_pear_grape<S: wasmtime::AsContextMut>(
704
&self,
705
mut store: S,
706
) -> wasmtime::Result<()> {
707
let callee = unsafe {
708
wasmtime::component::TypedFunc::<
709
(),
710
(),
711
>::new_unchecked(self.apple_pear_grape)
712
};
713
let () = callee.call(store.as_context_mut(), ())?;
714
callee.post_return(store.as_context_mut())?;
715
Ok(())
716
}
717
pub fn call_a0<S: wasmtime::AsContextMut>(
718
&self,
719
mut store: S,
720
) -> wasmtime::Result<()> {
721
let callee = unsafe {
722
wasmtime::component::TypedFunc::<
723
(),
724
(),
725
>::new_unchecked(self.a0)
726
};
727
let () = callee.call(store.as_context_mut(), ())?;
728
callee.post_return(store.as_context_mut())?;
729
Ok(())
730
}
731
/// Comment out identifiers that collide when mapped to snake_case, for now; see
732
/// https://github.com/WebAssembly/component-model/issues/118
733
/// APPLE: func()
734
/// APPLE-pear-GRAPE: func()
735
/// apple-PEAR-grape: func()
736
pub fn call_is_xml<S: wasmtime::AsContextMut>(
737
&self,
738
mut store: S,
739
) -> wasmtime::Result<()> {
740
let callee = unsafe {
741
wasmtime::component::TypedFunc::<
742
(),
743
(),
744
>::new_unchecked(self.is_xml)
745
};
746
let () = callee.call(store.as_context_mut(), ())?;
747
callee.post_return(store.as_context_mut())?;
748
Ok(())
749
}
750
pub fn call_explicit<S: wasmtime::AsContextMut>(
751
&self,
752
mut store: S,
753
) -> wasmtime::Result<()> {
754
let callee = unsafe {
755
wasmtime::component::TypedFunc::<
756
(),
757
(),
758
>::new_unchecked(self.explicit)
759
};
760
let () = callee.call(store.as_context_mut(), ())?;
761
callee.post_return(store.as_context_mut())?;
762
Ok(())
763
}
764
pub fn call_explicit_kebab<S: wasmtime::AsContextMut>(
765
&self,
766
mut store: S,
767
) -> wasmtime::Result<()> {
768
let callee = unsafe {
769
wasmtime::component::TypedFunc::<
770
(),
771
(),
772
>::new_unchecked(self.explicit_kebab)
773
};
774
let () = callee.call(store.as_context_mut(), ())?;
775
callee.post_return(store.as_context_mut())?;
776
Ok(())
777
}
778
/// Identifiers with the same name as keywords are quoted.
779
pub fn call_bool<S: wasmtime::AsContextMut>(
780
&self,
781
mut store: S,
782
) -> wasmtime::Result<()> {
783
let callee = unsafe {
784
wasmtime::component::TypedFunc::<
785
(),
786
(),
787
>::new_unchecked(self.bool)
788
};
789
let () = callee.call(store.as_context_mut(), ())?;
790
callee.post_return(store.as_context_mut())?;
791
Ok(())
792
}
793
}
794
}
795
}
796
}
797
}
798
799