| 27 | pub type Result<R> = std::result::Result<R, ()>; |
| 28 | |
| 29 | pub fn demangle_generic<S: BnStrCompatible>( |
| 30 | arch: &CoreArchitecture, |
| 31 | mangled_name: S, |
| 32 | view: Option<&BinaryView>, |
| 33 | simplify: bool, |
| 34 | ) -> Option<(QualifiedName, Option<Ref<Type>>)> { |
| 35 | let mangled_name_bwn = mangled_name.into_bytes_with_nul(); |
| 36 | let mangled_name_ptr = mangled_name_bwn.as_ref(); |
| 37 | let mut out_type: *mut BNType = std::ptr::null_mut(); |
| 38 | let mut out_name = BNQualifiedName::default(); |
| 39 | let res = unsafe { |
| 40 | BNDemangleGeneric( |
| 41 | arch.handle, |
| 42 | mangled_name_ptr.as_ptr() as *const c_char, |
| 43 | &mut out_type, |
| 44 | &mut out_name, |
| 45 | view.map(|v| v.handle).unwrap_or(std::ptr::null_mut()), |
| 46 | simplify, |
| 47 | ) |
| 48 | }; |
| 49 | |
| 50 | if res { |
| 51 | let out_type = match out_type.is_null() { |
| 52 | true => None, |
| 53 | false => Some(unsafe { Type::ref_from_raw(out_type) }), |
| 54 | }; |
| 55 | Some((QualifiedName::from_owned_raw(out_name), out_type)) |
| 56 | } else { |
| 57 | None |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | pub fn demangle_llvm<S: BnStrCompatible>(mangled_name: S, simplify: bool) -> Option<QualifiedName> { |
| 62 | let mangled_name_bwn = mangled_name.into_bytes_with_nul(); |