class Prism::LibRubyParser::PrismString

def self.with_string(string)

Yields a pm_string_t pointer to the given block.
def self.with_string(string)
  raise TypeError unless string.is_a?(String)
  length = string.bytesize
  # + 1 to never get an address of 0, which pm_parser_init() asserts
  FFI::MemoryPointer.new(:char, length + 1, false) do |pointer|
    pointer.write_string(string)
    # since we have the extra byte we might as well \0-terminate
    pointer.put_char(length, 0)
    return yield new(pointer, length, true)
  end
end