Open
Conversation
Closed
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.
2e6e9ef to
52f326b
Compare
|
FWIW, this LGTM. There are no more warnings about prototype mismatches for my code when wrapping XS calls. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.