1
Fork 0

lib is optional, exporttyp can be stringified

This commit is contained in:
Jan-Erik Rediger 2023-12-09 00:05:36 +01:00
parent 45ef7d0026
commit a4bf380c96

View file

@ -9,6 +9,17 @@ enum ExportTyp {
Stub Stub
} }
#[pymethods]
impl ExportTyp {
fn __str__(&self) -> &'static str {
match self {
ExportTyp::Regular => "regular",
ExportTyp::Reexport => "reexport",
ExportTyp::Stub => "stub",
}
}
}
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
#[pyclass] #[pyclass]
struct ExportInfo { struct ExportInfo {
@ -19,7 +30,7 @@ struct ExportInfo {
#[pyo3(get)] #[pyo3(get)]
flags: u64, flags: u64,
#[pyo3(get)] #[pyo3(get)]
lib: String, lib: Option<String>,
#[pyo3(get)] #[pyo3(get)]
lib_symbol_name: Option<String>, lib_symbol_name: Option<String>,
} }
@ -39,7 +50,7 @@ impl From<goblin::mach::exports::ExportInfo<'_>> for ExportInfo {
Reexport { lib, lib_symbol_name, flags } => { Reexport { lib, lib_symbol_name, flags } => {
Self { Self {
typ: ExportTyp::Reexport, typ: ExportTyp::Reexport,
lib: lib.to_string(), lib: Some(lib.to_string()),
lib_symbol_name: lib_symbol_name.map(|s| s.to_string()), lib_symbol_name: lib_symbol_name.map(|s| s.to_string()),
flags, flags,
.. Default::default() .. Default::default()