1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Procedural macros for libperl-rs.
//!
//! - `#[thx]` — function attribute that splices `my_perl: *mut
//! PerlInterpreter` as the first parameter in threaded builds and is a
//! no-op in non-threaded builds. Lets a single Rust source compile
//! against both `MULTIPLICITY` modes without manual `cfg` branches.
//! - `#[xs_sub]` — function attribute that turns a high-level Rust
//! signature like `fn is_even(n: IV) -> bool { ... }` into a complete
//! XS-callable `extern "C"` trampoline. (Phase 3.2 — TBD.)
//! - `xs_boot!` — declarative macro that emits the module's `boot_<name>`
//! entry. (Phase 3.3 — TBD.)
//!
//! Threading mode is selected at proc-macro compile time via
//! `cfg(perl_useithreads)`, set by `build.rs`.
use TokenStream;
use quote;
use ;
/// `#[xs_sub]` — see `xs_sub` module documentation.
/// `xs_boot!` — see `xs_boot` module documentation.
/// `#[thx]` — splice `my_perl: *mut ::libperl_sys::PerlInterpreter` as the
/// first parameter of `fn` in threaded builds; pass through unchanged in
/// non-threaded builds.
///
/// The injected name `my_perl` matches the C convention (`aTHX_`) and the
/// project's naming rule (see `docs/plan/README.md` §3.8). The
/// fully-qualified path `::libperl_sys::PerlInterpreter` is hard-coded
/// rather than `$crate::PerlInterpreter` because proc-macros emit raw
/// tokens — the path is resolved at the *call site* of `#[thx]`.
///
/// Examples
/// --------
///
/// Source:
///
/// ```ignore
/// #[thx]
/// fn helper(sv: *mut SV) -> i32 { /* ... */ }
/// ```
///
/// Threaded expansion:
///
/// ```ignore
/// fn helper(my_perl: *mut ::libperl_sys::PerlInterpreter, sv: *mut SV) -> i32 { /* ... */ }
/// ```
///
/// Non-threaded expansion: identical to the input.