This describes the C++ side name
(
&self,
func: &Function,
guest_export: bool,
cpp_file: bool,
)
| 913 | |
| 914 | /// This describes the C++ side name |
| 915 | fn func_namespace_name( |
| 916 | &self, |
| 917 | func: &Function, |
| 918 | guest_export: bool, |
| 919 | cpp_file: bool, |
| 920 | ) -> (Vec<String>, String) { |
| 921 | let (object, owner) = match &func.kind { |
| 922 | FunctionKind::Freestanding => None, |
| 923 | FunctionKind::Method(i) => Some(i), |
| 924 | FunctionKind::Static(i) => Some(i), |
| 925 | FunctionKind::Constructor(i) => Some(i), |
| 926 | FunctionKind::AsyncFreestanding => todo!(), |
| 927 | FunctionKind::AsyncMethod(_id) => todo!(), |
| 928 | FunctionKind::AsyncStatic(_id) => todo!(), |
| 929 | } |
| 930 | .map(|i| { |
| 931 | let ty = &self.resolve.types[*i]; |
| 932 | (ty.name.as_ref().unwrap().to_pascal_case(), ty.owner) |
| 933 | }) |
| 934 | .unwrap_or(( |
| 935 | Default::default(), |
| 936 | self.interface |
| 937 | .map(TypeOwner::Interface) |
| 938 | .unwrap_or(TypeOwner::World(self.r#gen.world_id.unwrap())), |
| 939 | )); |
| 940 | let mut namespace = namespace(self.resolve, &owner, guest_export, &self.r#gen.opts); |
| 941 | let is_drop = is_special_method(func); |
| 942 | let func_name_h = if !matches!(&func.kind, FunctionKind::Freestanding) { |
| 943 | namespace.push(object.clone()); |
| 944 | if let FunctionKind::Constructor(_i) = &func.kind { |
| 945 | // Fallible constructors return result<T, E> and are static factory methods |
| 946 | let is_fallible_constructor = |
| 947 | self.r#gen.is_fallible_constructor(self.resolve, func); |
| 948 | |
| 949 | if is_fallible_constructor { |
| 950 | String::from("Create") |
| 951 | } else if guest_export && cpp_file { |
| 952 | String::from("New") |
| 953 | } else { |
| 954 | object.clone() |
| 955 | } |
| 956 | } else { |
| 957 | match is_drop { |
| 958 | SpecialMethod::ResourceDrop => { |
| 959 | if guest_export { |
| 960 | "ResourceDrop".to_string() |
| 961 | } else { |
| 962 | "~".to_string() + &object |
| 963 | } |
| 964 | } |
| 965 | SpecialMethod::Dtor => "Dtor".to_string(), |
| 966 | SpecialMethod::ResourceNew => "ResourceNew".to_string(), |
| 967 | SpecialMethod::ResourceRep => "ResourceRep".to_string(), |
| 968 | SpecialMethod::Allocate => "New".to_string(), |
| 969 | SpecialMethod::None => func.item_name().to_pascal_case(), |
| 970 | } |
| 971 | } |
| 972 | } else { |
no test coverage detected