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 100LibRubyParser.pm_buffer_sizeof
Class Method Summary
- .new(pointer) ⇒ PrismBuffer constructor
-
.with(&block)
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(&block)
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 122
def self.with(&block) pointer = FFI::MemoryPointer.new(SIZEOF) begin raise unless LibRubyParser.pm_buffer_init(pointer) yield new(pointer) ensure LibRubyParser.pm_buffer_free(pointer) pointer.free end end
Instance Attribute Details
#pointer (readonly)
[ GitHub ]# File 'lib/prism/ffi.rb', line 102
attr_reader :pointer
Instance Method Details
#length
[ GitHub ]# File 'lib/prism/ffi.rb', line 112
def length LibRubyParser.pm_buffer_length(pointer) end
#read
[ GitHub ]#value
[ GitHub ]# File 'lib/prism/ffi.rb', line 108
def value LibRubyParser.pm_buffer_value(pointer) end