Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wrapping subs with prototypes #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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.

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 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.
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.

1 participant