MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / finish

Method finish

crates/rust/src/interface.rs:377–404  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

375 }
376
377 pub fn finish(&mut self) -> String {
378 if !self.return_pointer_area_size.is_empty() {
379 uwriteln!(self.src,);
380 self.align_area(self.return_pointer_area_align);
381 uwrite!(
382 self.src,
383 "struct _RetArea([::core::mem::MaybeUninit::<u8>; {size}]);
384 static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); {size}]);
385",
386 size = self.return_pointer_area_size.format_term(POINTER_SIZE_EXPRESSION, true),
387 );
388 }
389
390 let src = mem::take(&mut self.src).into();
391
392 if self.needs_runtime_module {
393 let root = self.path_to_root();
394 if !root.is_empty() {
395 let wit_map_use = if self.needs_wit_map {
396 format!("use {root}_rt::WitMap;\n")
397 } else {
398 String::new()
399 };
400 return format!("use {root}_rt;\n{wit_map_use}{src}");
401 }
402 }
403 src
404 }
405
406 pub(crate) fn path_to_root(&self) -> String {
407 let mut path_to_root = String::new();

Callers 1

Calls 4

newFunction · 0.85
align_areaMethod · 0.80
path_to_rootMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected