public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH perlmod v2 0/5] perlmod: add #[hash] parameter attribute
@ 2026-07-24 14:49 Max R. Carrara
  2026-07-24 14:49 ` [PATCH perlmod v2 1/5] macro: function: make argument code generation helpers standalone fns Max R. Carrara
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Max R. Carrara @ 2026-07-24 14:49 UTC (permalink / raw)
  To: pve-devel

perlmod: add #[hash] parameter attribute - v2
=============================================

This series implements a `#[hash]` parameter similar to the existing
`#[list]` one, allowing us to create APIs like
`foo("arg", key => "value")` directly from Rust.

In other words, this essentially mirrors how a sub with `%params` as its
last parameter would work.

For example, this is one of the functions called by the tests that are
added in this series:

    #[export]
    fn trailing_hash(first: u32, #[hash] rest: HashMap<u32, u32>) -> String {
        format!("first={first}, rest is {rest:?}")
    }

This can then be called e.g. like this:

    let $res = TestLib::Hello::trailing_hash(42, 1337 => 123);

Changes Since v1
----------------

- Drop patches that were already applied (thanks!)

- Call it "parameter attribute", not "parameter"

- Take Wolfgang's feedback (thanks!) on patch #3 of v1 into account and
  refactor the majority of `perlmod-macro/src/function.rs` before
  actually implementing the #[hash] parameter attribute.

  This means that all patches but the last just massage `function.rs`
  into a shape that makes it convenient to add and debug new parameter
  attributes. The overall logic was improved as well, making it more
  clear / explicit what's happening in a given block of code.

The tests and docstrings added in the last patch are otherwise kept
identical, including the implementation of `ParamsIter<I>`.

Previous Versions
-----------------

v1: https://lore.proxmox.com/pve-devel/20260720152541.524463-1-m.carrara@proxmox.com/

Summary of Changes
------------------


perlmod:

Max R. Carrara (5):
  macro: function: make argument code generation helpers standalone fns
  macro: function: make argument attribute handling more extendable
  macro: function: explicitly pass identifier for generated arg iter
  macro: function: move signature inputs handling into helper struct
  perlmod, macro: add #[hash] parameter attribute

 perlmod-macro/src/function.rs | 648 ++++++++++++++++++++++------------
 perlmod/src/de.rs             |  44 +++
 perlmod/src/lib.rs            |   5 +
 testlib-tests/01-hello.t      |  46 ++-
 testlib/src/lib.rs            |  24 +-
 5 files changed, 538 insertions(+), 229 deletions(-)


Summary over all repositories:
  5 files changed, 538 insertions(+), 229 deletions(-)

-- 
Generated by murpp 0.11.0




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-24 14:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 14:49 [PATCH perlmod v2 0/5] perlmod: add #[hash] parameter attribute Max R. Carrara
2026-07-24 14:49 ` [PATCH perlmod v2 1/5] macro: function: make argument code generation helpers standalone fns Max R. Carrara
2026-07-24 14:49 ` [PATCH perlmod v2 2/5] macro: function: make argument attribute handling more extendable Max R. Carrara
2026-07-24 14:49 ` [PATCH perlmod v2 3/5] macro: function: explicitly pass identifier for generated arg iter Max R. Carrara
2026-07-24 14:49 ` [PATCH perlmod v2 4/5] macro: function: move signature inputs handling into helper struct Max R. Carrara
2026-07-24 14:49 ` [PATCH perlmod v2 5/5] perlmod, macro: add #[hash] parameter attribute Max R. Carrara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal