Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use crate::{common::{FromFFI, into_optional}, pdb::Type};
4 : use std::marker::PhantomData;
5 : use crate::pdb::types::PdbType;
6 :
7 : /// This structure wraps a `LF_ARRAY` PDB type
8 : pub struct Array<'a> {
9 : ptr: cxx::UniquePtr<ffi::PDB_types_Array>,
10 : _owner: PhantomData<&'a ()>,
11 : }
12 :
13 : impl FromFFI<ffi::PDB_types_Array> for Array<'_> {
14 0 : fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Array>) -> Self {
15 0 : Self {
16 0 : ptr: cmd,
17 0 : _owner: PhantomData,
18 0 : }
19 0 : }
20 : }
21 :
22 : impl Array<'_> {
23 : /// The number of element in this array
24 0 : pub fn numberof_elements(&self) -> u64 {
25 0 : self.ptr.numberof_elements()
26 0 : }
27 :
28 : /// Type of the elements
29 0 : pub fn element_type(&self) -> Option<Type<'_>> {
30 0 : into_optional(self.ptr.element_type())
31 0 : }
32 :
33 : /// Type of the index
34 0 : pub fn index_type(&self) -> Option<Type<'_>> {
35 0 : into_optional(self.ptr.index_type())
36 0 : }
37 : }
38 :
39 : impl PdbType for Array<'_> {
40 0 : fn get_base(&self) -> &ffi::PDB_Type {
41 0 : self.ptr.as_ref().unwrap().as_ref()
42 0 : }
43 : }
|