Class: Prism::LibRubyParser::PrismString
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_string_t. We only use it as an opaque pointer, so it doesn’t have to be an FFI::Struct
.
Constant Summary
-
SIZEOF =
# File 'lib/prism/ffi.rb', line 138LibRubyParser.pm_string_sizeof
Class Method Summary
- .new(pointer) ⇒ PrismString constructor
-
.with(filepath, &block)
Yields a pm_string_t pointer to the given block.
Instance Attribute Summary
- #pointer readonly
Instance Method Summary
Constructor Details
.new(pointer) ⇒ PrismString
Class Method Details
.with(filepath, &block)
Yields a pm_string_t pointer to the given block.
# File 'lib/prism/ffi.rb', line 159
def self.with(filepath, &block) pointer = FFI::MemoryPointer.new(SIZEOF) begin raise unless LibRubyParser.pm_string_mapped_init(pointer, filepath) yield new(pointer) ensure LibRubyParser.pm_string_free(pointer) pointer.free end end
Instance Attribute Details
#pointer (readonly)
[ GitHub ]# File 'lib/prism/ffi.rb', line 140
attr_reader :pointer
Instance Method Details
#length
[ GitHub ]# File 'lib/prism/ffi.rb', line 150
def length LibRubyParser.pm_string_length(pointer) end
#read
[ GitHub ]#source
[ GitHub ]# File 'lib/prism/ffi.rb', line 146
def source LibRubyParser.pm_string_source(pointer) end