(
&mut self,
resolve: &Resolve,
world_id: WorldId,
files: &mut Files,
)
| 665 | } |
| 666 | |
| 667 | fn finish( |
| 668 | &mut self, |
| 669 | resolve: &Resolve, |
| 670 | world_id: WorldId, |
| 671 | files: &mut Files, |
| 672 | ) -> std::result::Result<(), anyhow::Error> { |
| 673 | let world = &resolve.worlds[world_id]; |
| 674 | let snake = world.name.to_snake_case(); |
| 675 | let linking_symbol = wit_bindgen_c::component_type_object::linking_symbol(&world.name); |
| 676 | |
| 677 | let mut h_str = SourceWithState::default(); |
| 678 | let mut c_str = SourceWithState::default(); |
| 679 | |
| 680 | let version = env!("CARGO_PKG_VERSION"); |
| 681 | uwriteln!( |
| 682 | h_str.src, |
| 683 | "// Generated by `wit-bindgen` {version}. DO NOT EDIT!" |
| 684 | ); |
| 685 | |
| 686 | uwrite!( |
| 687 | h_str.src, |
| 688 | "#ifndef __CPP_GUEST_BINDINGS_{0}_H |
| 689 | #define __CPP_GUEST_BINDINGS_{0}_H\n", |
| 690 | world.name.to_shouty_snake_case(), |
| 691 | ); |
| 692 | self.finish_includes(); |
| 693 | |
| 694 | for include in self.includes.iter() { |
| 695 | uwriteln!(h_str.src, "#include {include}"); |
| 696 | } |
| 697 | |
| 698 | uwriteln!( |
| 699 | c_str.src, |
| 700 | "// Generated by `wit-bindgen` {version}. DO NOT EDIT!" |
| 701 | ); |
| 702 | uwriteln!( |
| 703 | c_str.src, |
| 704 | "\n// Ensure that the *_component_type.o object is linked in" |
| 705 | ); |
| 706 | uwrite!( |
| 707 | c_str.src, |
| 708 | "#ifdef __wasm32__ |
| 709 | extern \"C\" void {linking_symbol}(void); |
| 710 | __attribute__((used)) |
| 711 | void {linking_symbol}_public_use_in_this_compilation_unit(void) {{ |
| 712 | {linking_symbol}(); |
| 713 | }} |
| 714 | #endif |
| 715 | ", |
| 716 | ); |
| 717 | if self.dependencies.needs_assert { |
| 718 | uwriteln!(c_str.src, "#include <assert.h>"); |
| 719 | } |
| 720 | |
| 721 | h_str.change_namespace(&Vec::default()); |
| 722 | |
| 723 | self.c_src.change_namespace(&Vec::default()); |
| 724 | c_str.src.push_str(&self.c_src_head); |
nothing calls this directly
no test coverage detected