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

Method qualify

crates/cpp/src/lib.rs:837–865  ·  view source on GitHub ↗
(&mut self, target: &[String])

Source from the content-addressed store, hash-verified

835 }
836
837 fn qualify(&mut self, target: &[String]) {
838 let mut same = 0;
839 // itertools::fold_while?
840 for (a, b) in self.namespace.iter().zip(target.iter()) {
841 if a == b {
842 same += 1;
843 } else {
844 break;
845 }
846 }
847 if same == 0 && !target.is_empty() {
848 // if the root namespace exists below the current namespace we need to start at root
849 // Also ensure absolute qualification when crossing from exports to imports
850 if self.namespace.contains(target.first().unwrap())
851 || (self.namespace.first().map(|s| s.as_str()) == Some("exports")
852 && target.first().map(|s| s.as_str()) != Some("exports"))
853 {
854 self.src.push_str("::");
855 }
856 }
857 if same == target.len() && self.namespace.len() != target.len() && same > 0 {
858 // namespace is parent, qualify at least one namespace (and cross fingers)
859 uwrite!(self.src, "{}::", target[same - 1]);
860 } else {
861 for i in target.iter().skip(same) {
862 uwrite!(self.src, "{i}::");
863 }
864 }
865 }
866}
867
868struct CppInterfaceGenerator<'a> {

Callers 4

print_signatureMethod · 0.80
scoped_type_nameMethod · 0.80
type_resourceMethod · 0.80
emitMethod · 0.80

Calls 5

mapMethod · 0.80
as_strMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected