Commit Graph

73 Commits

Author SHA1 Message Date
Wolfgang Bumiller
1adcd9727e clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-30 15:46:55 +02:00
Wolfgang Bumiller
5e2a30e18c cargo fmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-30 15:42:33 +02:00
Wolfgang Bumiller
c2c6d6572b macro: comment out unused field
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-07-30 15:42:27 +02:00
Wolfgang Bumiller
754682961f macro: unraw() function names
so we can name an exported sub 'r#type'

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-14 13:46:13 +01:00
Wolfgang Bumiller
95e8123f5b perlmod: search LD_LIBRARY_PATH before @INC/auto dirs
This is for the code generated for `#[package(write = true)]`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-12-19 08:38:41 +01:00
Wolfgang Bumiller
cb86559d13 update to syn-2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-02 13:31:09 +02:00
Wolfgang Bumiller
4600b0779f macro: move 'boot' call into the 'Once' section
This also means boot function call chains must not cause circular
dependencies at all without a way to mitigate this in code. If this
should ever be a problem, we can move it out again, but this should
rather not be necessary.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-26 09:58:01 +02:00
Wolfgang Bumiller
82b4d14ad3 macro: upgrade boot attribute to a full path
This is a lot more flexible than just a single ident.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-26 09:37:59 +02:00
Wolfgang Bumiller
e2d4ad4e96 macro: update docs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-25 13:46:39 +02:00
Wolfgang Bumiller
1017735ad0 macro: add 'boot' attribute to packages
This is supposed to be a function executed after the 'boot' method has
finished registering the XS callbacks.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-25 13:40:43 +02:00
Wolfgang Bumiller
63fcccaa50 macro: allow calling boot fns with None as parameter
This allows using them from other modules for initialization.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-25 13:32:47 +02:00
Wolfgang Bumiller
b94cbb8f16 macro: ensure bootstrap functions happen only once
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-25 13:31:37 +02:00
Wolfgang Bumiller
56bb74b196 add ability to set the errno value
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-02 14:43:47 +02:00
Wolfgang Bumiller
2aa0c70d0d macro: add serialize_error attribute
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-02 11:45:20 +02:00
Wolfgang Bumiller
f381c740b4 macro: fix syntax error in non-result tuple case
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-02 10:41:32 +02:00
Wolfgang Bumiller
76f6a079eb clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-12-09 11:24:34 +01:00
Wolfgang Bumiller
f8b49fc1be clippy fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-09-22 10:00:33 +02:00
Wolfgang Bumiller
02e4344e7e clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-08-01 10:41:11 +02:00
Wolfgang Bumiller
4d84aec490 clippy: don't explicitly drop args in generated code
While code seems to still compile, this was initially done
to explicitly get rid of potential borrows and doesn't seem
to be necessary anymore?

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-06-10 11:51:42 +02:00
Wolfgang Bumiller
c15e1e1456 macro: add a write attribute to packages
the .pm file now gets written if either 'write=true' or
'file' is set, setting just 'lib' won't trigger a write
anymore

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-25 15:45:56 +01:00
Wolfgang Bumiller
08c14b8fc5 macro: rename boot symbol to boot_<module>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-24 11:44:03 +01:00
Wolfgang Bumiller
daf4841996 macro: only write package files if requested
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-24 11:44:03 +01:00
Wolfgang Bumiller
a51cd47f9e macro: drop span hack from error handling
copying the input doesn't seem to be required anymore

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-02-24 11:43:42 +01:00
Wolfgang Bumiller
8bb0c091bc cargo fmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-10 12:50:11 +01:00
Wolfgang Bumiller
2812f550d9 macro: pass 'cv' as Value
to reduce the amount of required unsafe blocks

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-07 15:59:33 +01:00
Wolfgang Bumiller
c25b213cc5 macro: use raw pointer for CV parameter
so generated xsubs are actually compatible with
Value::new_xsub

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-07 15:54:50 +01:00
Wolfgang Bumiller
e5c95f0414 macro: fix multiplicity parameter type
use ffi::Interpreter, same as what perlmod does via the
perl_fn macro

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-07 15:51:33 +01:00
Wolfgang Bumiller
77171723e3 macro: expose the 'cv' as parameter on exports
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-01-07 09:12:00 +01:00
Wolfgang Bumiller
9bf583ca64 macro: export: copy use chosen visibility
when using the export macro directly without a package we
previously always used
    #[no_mangle]
    pub extern "C"
now instead of 'pub' we copy the original function's
visibility

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-23 10:40:59 +01:00
Wolfgang Bumiller
100414d678 macro: fixup export visibility
commi 5491907876 was incomplete, this fixes up the
remaining 2 cases

Fixes: 5491907876 ("don't export xs wrappers from modules")
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-23 10:40:59 +01:00
Wolfgang Bumiller
e68855945d drop imports already in 2021 prelude
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-01 14:13:44 +01:00
Wolfgang Bumiller
4b5b75f1d8 macro: implement prototypes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-25 10:16:39 +01:00
Wolfgang Bumiller
4dc236a2d4 macro: allow optional option parameters
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-24 20:59:27 +01:00
Wolfgang Bumiller
5491907876 don't export xs wrappers from modules
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-24 20:45:11 +01:00
Wolfgang Bumiller
d6b0097481 macro: fix missing parameter name in error message
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-24 11:57:36 +01:00
Wolfgang Bumiller
4632042632 perlmod, macro: detect perl's MULTIPLICITY flag
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-27 15:41:51 +02:00
Wolfgang Bumiller
4a0e18d9b3 calling convention 'fixup'
if we ever want to support mgvtbl methods we may need to add
support for detecting the pTHX_ parameter into our build.rs
scripts

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-27 13:47:58 +02:00
Wolfgang Bumiller
83f19b9599 macro: implement bootstrap function in rust
with this, the generated .pm files don't contain any
exports anymore

when implementing a `perlmod-bindgen` utility to generate
.pm files, we can now also deprecate the `lib =` module
attribute on the `package` proc macro

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-21 11:28:29 +02:00
Wolfgang Bumiller
449d746871 perlmod-macro: improve error handling
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-15 09:52:58 +02:00
Wolfgang Bumiller
f888c202cc perlmod-macro: drop anyhow dependency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-15 09:45:57 +02:00
Wolfgang Bumiller
814014b874 macro: support env vars in package attributes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-13 12:52:02 +02:00
Wolfgang Bumiller
9de065545b macro: use CARGO_PKG_NAME instead of reading Cargo.toml
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-10-13 11:28:16 +02:00
Wolfgang Bumiller
4c9f6c51d7 macro: different approach to clippy warning
currently this does in fact deduplicate code, so...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-07-02 11:54:33 +02:00
Wolfgang Bumiller
a2a884c13d macro: clippy fixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-07-02 11:37:51 +02:00
Wolfgang Bumiller
aa13c5c85b macro: add newlines to errors
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-06-30 08:14:54 +02:00
Wolfgang Bumiller
740eda0643 adjust path for DynaLoader
We usually have multiple packages but only a single library,
so rather than making package look in subdirectories named
after them, just look in the toplevel `auto/` directory.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-22 14:12:25 +01:00
Wolfgang Bumiller
705d6989ad macro: support tuple return types in functions
These are now *list* return types in perl.
However, currently there is no support for 'wantarray' or
lists of dynamic length.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-16 10:39:37 +01:00
Wolfgang Bumiller
fa4d4a654c macro: make generated helpers #[doc(hidden)]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-02-15 14:05:02 +01:00
Wolfgang Bumiller
7de9fdf07b introduce try_from_ref argument attribute
and document attributes in the #[export] macro documentation

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-27 15:35:08 +01:00
Wolfgang Bumiller
241e69eed8 guard '-L./target/debug' lib path by debug_assertions
A release build shouldn't add the local search path for
libraries to the perl modules.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-11-27 13:03:46 +01:00