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

Add data_loc method to Rust bindings #2854

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

ryym
Copy link
Contributor

@ryym ryym commented Jun 1, 2024

Closes #2621

Currently Prism recognizes the __END__ content and provides a way to access it in Ruby, C, and Java APIs, but Rust bindings does not have it. This PR adds the data_loc method to Rust API.

which returns a location of the __END__ content.
pub fn data_loc(&self) -> Option<Location<'_>> {
let root = self.source.as_ptr();
let location = unsafe { &(*self.parser.as_ptr()).data_loc };
if location.start >= root {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other optional locations we're checking start.is_null() instead, can you do that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I changed the implementation to use is_null() .
be34f68

@ryym ryym requested a review from kddnewton June 2, 2024 00:54
@kddnewton kddnewton merged commit 99b2303 into ruby:main Jun 3, 2024
54 of 55 checks passed
@ryym ryym deleted the add-data-loc-to-rust-bindings branch July 27, 2024 00:27
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.

2 participants