From a4bf380c965c178fc326973a958f9211d3c2c565 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 9 Dec 2023 00:05:36 +0100 Subject: [PATCH] lib is optional, exporttyp can be stringified --- crates/goblin-pyo3/src/exports.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/goblin-pyo3/src/exports.rs b/crates/goblin-pyo3/src/exports.rs index eecf388..d4e7038 100644 --- a/crates/goblin-pyo3/src/exports.rs +++ b/crates/goblin-pyo3/src/exports.rs @@ -9,6 +9,17 @@ enum ExportTyp { Stub } +#[pymethods] +impl ExportTyp { + fn __str__(&self) -> &'static str { + match self { + ExportTyp::Regular => "regular", + ExportTyp::Reexport => "reexport", + ExportTyp::Stub => "stub", + } + } +} + #[derive(Debug, Default, Clone)] #[pyclass] struct ExportInfo { @@ -19,7 +30,7 @@ struct ExportInfo { #[pyo3(get)] flags: u64, #[pyo3(get)] - lib: String, + lib: Option, #[pyo3(get)] lib_symbol_name: Option, } @@ -39,7 +50,7 @@ impl From> for ExportInfo { Reexport { lib, lib_symbol_name, flags } => { Self { typ: ExportTyp::Reexport, - lib: lib.to_string(), + lib: Some(lib.to_string()), lib_symbol_name: lib_symbol_name.map(|s| s.to_string()), flags, .. Default::default()