Right now, we have to keep the buffer FFI object in sync with the
definition of yp_buffer_t because we access its fields directly. If
we add more fields or change the order, things will get out of sync.
Instead, let's treat yp_buffer_t as an opaque pointer and access
its fields through accessor functions directly. This is more
consistent with how we handle strings anyway.
https://github.com/ruby/yarp/commit/878d845eff
* Otherwise it is undefined behavior to access the field of another `.as`.
* Accessing the right `.as` field according mode would be extra overhead.
https://github.com/ruby/yarp/commit/7dc41ee803
* So it can be reused by the Fiddle backend, etc and not just the C extension.
* Add YP_STRING_MAPPED to use a consistent interface for yp_string_t.
That way yp_string_free() can be used like for other string types.
* Fix handling of empty file for !HAVE_MMAP && !_WIN32
https://github.com/ruby/yarp/commit/e40bc35801
The problem was that we were treating heredoc bodies as part of the %W
list because we didn't push the scanning cursor past the heredoc after
lexing out the here doc. To fix this, we changed the whitespace
scanning function to quit scanning when it reaches a newline but only in
the case that a heredoc is present.
Additionally, we need to prevent double counting newlines in the case of
a heredoc. For example:
```ruby
%W(<<foo 123)
foo
```
The newline after the `)` is counted as part of scanning the heredoc, so
we added logic to prevent double counting the newline when scanning the
rest of the %W list.
https://github.com/ruby/yarp/commit/eb090d8126
Co-authored-by: Jemma Issroff <jemmaissroff@gmail.com>
This commit is the initial sync of all files from ruby/yarp
into ruby/ruby. Notably, it does the following:
* Sync all ruby/yarp/lib/ files to ruby/ruby/lib/yarp
* Sync all ruby/yarp/src/ files to ruby/ruby/yarp/
* Sync all ruby/yarp/test/ files to ruby/ruby/test/yarp