Class: Prism::LibRubyParser::PrismBuffer
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/prism/ffi.rb |
Overview
This object represents a pm_buffer_t. We only use it as an opaque pointer, so it doesn’t need to know the fields of pm_buffer_t.
Constant Summary
-
SIZEOF =
# File 'lib/prism/ffi.rb', line 124LibRubyParser.pm_buffer_sizeof
Class Method Summary
- .new(pointer) ⇒ PrismBuffer constructor
-
.with
Initialize a new buffer and yield it to the block.
Instance Attribute Summary
- #pointer readonly
Instance Method Summary
Constructor Details
.new(pointer) ⇒ PrismBuffer
Class Method Details
.with
Initialize a new buffer and yield it to the block. The buffer will be automatically freed when the block returns.
# File 'lib/prism/ffi.rb', line 146
def self.with FFI::MemoryPointer.new(SIZEOF) do |pointer| raise unless LibRubyParser.pm_buffer_init(pointer) return yield new(pointer) ensure LibRubyParser.pm_buffer_free(pointer) end end
Instance Attribute Details
#pointer (readonly)
[ GitHub ]# File 'lib/prism/ffi.rb', line 126
attr_reader :pointer
Instance Method Details
#length
[ GitHub ]# File 'lib/prism/ffi.rb', line 136
def length LibRubyParser.pm_buffer_length(pointer) end
#read
[ GitHub ]#value
[ GitHub ]# File 'lib/prism/ffi.rb', line 132
def value LibRubyParser.pm_buffer_value(pointer) end