Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use crate::common::{into_optional, FromFFI};
4 : use std::marker::PhantomData;
5 : use crate::dwarf::types::DwarfType;
6 : use crate::dwarf::Type;
7 :
8 : /// This structure represents a ``DW_TAG_pointer_type`` DWARF type.
9 : pub struct Pointer<'a> {
10 : ptr: cxx::UniquePtr<ffi::DWARF_types_Pointer>,
11 : _owner: PhantomData<&'a ()>,
12 : }
13 :
14 : impl FromFFI<ffi::DWARF_types_Pointer> for Pointer<'_> {
15 0 : fn from_ffi(cmd: cxx::UniquePtr<ffi::DWARF_types_Pointer>) -> Self {
16 0 : Self {
17 0 : ptr: cmd,
18 0 : _owner: PhantomData,
19 0 : }
20 0 : }
21 : }
22 :
23 : impl DwarfType for Pointer<'_> {
24 0 : fn get_base(&self) -> &ffi::DWARF_Type {
25 0 : self.ptr.as_ref().unwrap().as_ref()
26 0 : }
27 : }
28 :
29 : impl Pointer<'_> {
30 : /// The type pointed by this pointer
31 0 : pub fn underlying_type(&self) -> Option<Type> {
32 0 : into_optional(self.ptr.underlying_type())
33 0 : }
34 : }
|