1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#![warn(missing_docs)]
use std::io;
use proguard::{ProguardMapper, ProguardMapping, StackFrame};
use symbolic_common::{AsSelf, ByteView, SelfCell, Uuid};
struct Inner<'a> {
mapping: ProguardMapping<'a>,
mapper: ProguardMapper<'a>,
}
impl<'slf, 'a: 'slf> AsSelf<'slf> for Inner<'a> {
type Ref = Inner<'slf>;
fn as_self(&'slf self) -> &Self::Ref {
&self
}
}
#[deprecated = "use the `proguard` crate directly"]
pub struct ProguardMappingView<'a> {
inner: SelfCell<ByteView<'a>, Inner<'a>>,
}
#[allow(deprecated)]
impl<'a> ProguardMappingView<'a> {
pub fn parse(byteview: ByteView<'a>) -> Result<Self, io::Error> {
let inner = SelfCell::new(byteview, |data| {
let mapping = ProguardMapping::new(unsafe { &*data });
let mapper = ProguardMapper::new(mapping.clone());
Inner { mapping, mapper }
});
Ok(ProguardMappingView { inner })
}
pub fn uuid(&self) -> Uuid {
self.inner.get().mapping.uuid()
}
pub fn has_line_info(&self) -> bool {
self.inner.get().mapping.has_line_info()
}
pub fn convert_dotted_path(&self, path: &str, lineno: u32) -> String {
let mapper = &self.inner.get().mapper;
let mut iter = path.splitn(2, ':');
let cls_name = iter.next().unwrap_or("");
match iter.next() {
Some(meth_name) => {
let mut mapped =
mapper.remap_frame(&StackFrame::new(cls_name, meth_name, lineno as usize));
match mapped.next() {
Some(frame) => format!("{}:{}", frame.class(), frame.method()),
None => path.to_string(),
}
}
None => mapper.remap_class(cls_name).unwrap_or(cls_name).to_string(),
}
}
}