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

Allow function attributes to come before the signature/prototype #127

Merged
merged 1 commit into from Jun 6, 2016

Conversation

Projects
None yet
2 participants
@brummett
Contributor

brummett commented May 16, 2016

Attempts to resolve #99 by overriding two method in Devel::Declare that prevented this from working before. D::D's base parser expects to see a function-like declaration in this order

<keyword> name (prototype) : attr1 : attr2 { body }

Without these overridden methods, Devel::Declare's strip_attrs() gets stuck in an endless loop looking for the open brace after finding and removing the attributes. The current offset advances to the open paren starting the signature, and then never advances further. The overridden strip_attrs() is just a copy of D::D::Context::Simple::strip_attrs() that terminates the loop if it finds { or (

D::D's strip_proto() will never find the signature if the attribtes are earlier and still in the parse buffer. So the overridden parser() method looks to see whether ( (a signature/prototype) or : (attributes) comes earlier, and calls strip_proto() and strip_attrs() in the same order they appear in the source.

I'm not happy with all the copied code from Devel::Declare... Maybe it would be better to patch Devel::Declare with these changes, or at least add hooks in D::D we can use here.

Allow function attributes to come before the signature/prototype
Override strip_attrs() from Devel::Declare::Context::Simple to fix a problem
where it'll get stuck in an endless loop looking for the open brace "{".
Stops when it finds an open paren "(" as well.

Override parser() from D::D::MethodInstaller::Simple to call strip_proto()
and strip_attrs() in the same order the signature/prototype and attributes
appear in the source.

@barefootcoder barefootcoder merged commit 31de7e3 into evalEmpire:master Jun 6, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@barefootcoder

This comment has been minimized.

Show comment
Hide comment
@barefootcoder

barefootcoder Jun 6, 2016

Contributor

I'm good with this code. I'm going to put this out as a second developer release. If CPAN Testers is happy with it, I'll go ahead and close out #99.

Contributor

barefootcoder commented Jun 6, 2016

I'm good with this code. I'm going to put this out as a second developer release. If CPAN Testers is happy with it, I'll go ahead and close out #99.

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