Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use std::marker::PhantomData;
4 : use crate::common::FromFFI;
5 :
6 : /// This structure represents an Objective-C Method
7 : pub struct Method<'a> {
8 : ptr: cxx::UniquePtr<ffi::ObjC_Method>,
9 : _owner: PhantomData<&'a ()>,
10 : }
11 :
12 : impl FromFFI<ffi::ObjC_Method> for Method<'_> {
13 0 : fn from_ffi(info: cxx::UniquePtr<ffi::ObjC_Method>) -> Self {
14 0 : Self {
15 0 : ptr: info,
16 0 : _owner: PhantomData
17 0 : }
18 0 : }
19 : }
20 :
21 : impl Method<'_> {
22 : /// Name of the method
23 0 : pub fn name(&self) -> String {
24 0 : self.ptr.name().to_string()
25 0 : }
26 :
27 : /// Prototype of the method in its mangled representation (e.g. `@16@0:8`)
28 0 : pub fn mangled_type(&self) -> String {
29 0 : self.ptr.mangled_type().to_string()
30 0 : }
31 :
32 : /// Virtual address where this method is implemented in the binary
33 0 : pub fn address(&self) -> u64 {
34 0 : self.ptr.address()
35 0 : }
36 :
37 : /// Whether it's an instance method
38 0 : pub fn is_instance(&self) -> bool {
39 0 : self.ptr.is_instance()
40 0 : }
41 : }
42 :
|