Sha256: 621b6daa9570122f90514bf380a0c16bfab9e80b6628a8f5c23636f0d7e7bdc7
Contents?: true
Size: 742 Bytes
Versions: 2
Compression:
Stored size: 742 Bytes
Contents
# frozen_string_literal: true require 'ffi' module GLib # Represents a null-terminated array of strings. GLib uses this # construction, but does not provide any actual functions for this class. class Strv include Enumerable POINTER_SIZE = FFI.type_size(:pointer) def initialize(ptr) @ptr = ptr end def to_ptr @ptr end def each return if @ptr.null? reset_iterator while (ptr = next_ptr) yield ptr.read_string end end def self.wrap(ptr) new ptr end private def reset_iterator @offset = 0 end def next_ptr ptr = @ptr.get_pointer @offset @offset += POINTER_SIZE ptr unless ptr.null? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gir_ffi-0.9.4 | lib/gir_ffi-base/glib/strv.rb |
gir_ffi-0.9.3 | lib/gir_ffi-base/glib/strv.rb |