libperl_rs/lib.rs
1//! libperl-rs — safe Rust API on top of libperl-sys / libperl-macrogen.
2//!
3//! Re-exports everything from `libperl-sys` at the crate root so that
4//! consumers can write `libperl_rs::Perl_sv_setiv(...)` and
5//! `libperl_rs::PL_main_start!(my_perl)` uniformly. The old prototype API
6//! lives on as the `libperl-proto0` workspace member; see
7//! `docs/plan/README.md` for the rebuild plan.
8
9#![allow(non_snake_case)]
10#![allow(non_camel_case_types)]
11#![allow(non_upper_case_globals)]
12
13pub use libperl_sys::*;
14pub use libperl_macros::*;
15
16/// `thx_call!(perl, Perl_xxx, args...)` — call a libperl-sys function
17/// that takes a leading `my_perl` parameter in threaded builds and
18/// drops that parameter in non-threaded builds. The first argument
19/// (`perl: &Perl`) is silently discarded in non-threaded mode.
20///
21/// Centralising this here keeps the hand-written `Sv`/`Av`/`Hv`
22/// constructors free of `#[cfg(perl_useithreads)]` clutter — same
23/// abstraction the `#[xs_sub]` proc-macro applies internally via
24/// `myperl_arg_prefix`.
25macro_rules! thx_call {
26 ($perl:expr, $fn:ident, $($arg:expr),* $(,)?) => {{
27 #[cfg(perl_useithreads)]
28 { libperl_sys::$fn($perl.as_ptr(), $($arg),*) }
29 #[cfg(not(perl_useithreads))]
30 { let _ = $perl; libperl_sys::$fn($($arg),*) }
31 }};
32}
33pub(crate) use thx_call;
34
35pub mod perl;
36pub use perl::*;
37
38pub mod sv;
39pub use sv::*;
40
41pub mod rv;
42pub use rv::*;
43
44pub mod av;
45pub use av::*;
46
47pub mod hv;
48pub use hv::*;