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