Skip to content

Conversation

@haarg
Copy link
Member

@haarg haarg commented Apr 4, 2019

This allows wrapping subs that have prototypes, and maintaining the prototypes as appropriate.

There's some weird stuff in this which I'm not certain of myself, but I already wrote the code so I figured I'd have someone else look at it.

@kiwiroy kiwiroy mentioned this pull request Oct 22, 2025
haarg and others added 3 commits October 22, 2025 14:11
While Class::Method::Modifiers is primarily meant to wrap methods, it
can also be used to wrap functions.  Functions may have prototypes, so
it would be better if they could be maintained in the wrapper.

This works similarly to the lvalue attribute.  If a before or after is
applied, the wrapper takes its prototype from the sub being wrapped.  If
an around is applied, the modifier sub's prototype is used.  This is
rather strange for arounds, as the parameters it is passed will still
include the wrapped sub as the first parameter, so the parameters won't
match the prototype exactly.  Even with that oddness, it still seems to
be the best option.  This also means an around could change the
prototype, which will throw warnings.
@kiwiroy
Copy link

kiwiroy commented Oct 22, 2025

FWIW, this LGTM. There are no more warnings about prototype mismatches for my code when wrapping XS calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants