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 : use crate::declare_fwd_iterator;
8 : use crate::dwarf::Parameters;
9 :
10 : /// This structure represents a `DW_TAG_template_alias`
11 : pub struct TemplateAlias<'a> {
12 : ptr: cxx::UniquePtr<ffi::DWARF_types_TemplateAlias>,
13 : _owner: PhantomData<&'a ()>,
14 : }
15 :
16 : impl FromFFI<ffi::DWARF_types_TemplateAlias> for TemplateAlias<'_> {
17 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::DWARF_types_TemplateAlias>) -> Self {
18 0 : Self {
19 0 : ptr,
20 0 : _owner: PhantomData,
21 0 : }
22 0 : }
23 : }
24 :
25 : impl DwarfType for TemplateAlias<'_> {
26 0 : fn get_base(&self) -> &ffi::DWARF_Type {
27 0 : self.ptr.as_ref().unwrap().as_ref()
28 0 : }
29 : }
30 :
31 : impl TemplateAlias<'_> {
32 : /// The underlying type aliased by this type.
33 0 : pub fn underlying_type(&self) -> Option<Type> {
34 0 : into_optional(self.ptr.underlying_type())
35 0 : }
36 :
37 : /// [`Parameters`] associated with the underlying template
38 0 : pub fn parameters(&self) -> ParametersIt {
39 0 : ParametersIt::new(self.ptr.parameters())
40 0 : }
41 : }
42 :
43 0 : declare_fwd_iterator!(
44 0 : ParametersIt,
45 0 : Parameters<'a>,
46 0 : ffi::DWARF_Parameter,
47 0 : ffi::DWARF_types_TemplateAlias,
48 0 : ffi::DWARF_types_TemplateAlias_it_parameters
49 0 : );
|