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

Method change_namespace_with_docs

crates/cpp/src/lib.rs:809–835  ·  view source on GitHub ↗
(&mut self, target: &[String], docs: Option<&str>)

Source from the content-addressed store, hash-verified

807 }
808
809 fn change_namespace_with_docs(&mut self, target: &[String], docs: Option<&str>) {
810 let mut same = 0;
811 // itertools::fold_while?
812 for (a, b) in self.namespace.iter().zip(target.iter()) {
813 if a == b {
814 same += 1;
815 } else {
816 break;
817 }
818 }
819 for _i in same..self.namespace.len() {
820 uwrite!(self.src, "}}\n");
821 }
822 self.namespace.truncate(same);
823 let new_namespaces: Vec<_> = target.iter().skip(same).collect();
824 if !new_namespaces.is_empty() {
825 if let Some(content) = docs {
826 for line in content.trim().lines() {
827 uwriteln!(self.src, "/// {}", line);
828 }
829 }
830 for i in &new_namespaces {
831 uwrite!(self.src, "namespace {} {{\n", i);
832 self.namespace.push(i.to_string());
833 }
834 }
835 }
836
837 fn qualify(&mut self, target: &[String]) {
838 let mut same = 0;

Callers 3

import_interfaceMethod · 0.80
export_interfaceMethod · 0.80
change_namespaceMethod · 0.80

Calls 5

collectMethod · 0.80
iterMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected