Sha256: 4fc0ceb43df1b854e3cf1909b9350728b11117c81277ef5031e2f1ee03925241

Contents?: true

Size: 511 Bytes

Versions: 4

Compression:

Stored size: 511 Bytes

Contents

# frozen_string_literal: true
GLib.load_class :ByteArray

module GLib
  # Overrides for GByteArray, GLib's automatically growing array of bytes.
  class ByteArray
    def to_string
      GirFFI::ArgHelper.ptr_to_utf8_length @struct[:data], @struct[:len]
    end

    def append(data)
      bytes = GirFFI::InPointer.from_utf8 data
      len = data.bytesize
      self.class.wrap Lib.g_byte_array_append(to_ptr, bytes, len)
    end

    def initialize
      store_pointer(Lib.g_byte_array_new)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gir_ffi-0.10.2 lib/ffi-glib/byte_array.rb
gir_ffi-0.10.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.10.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.10.0.pre1 lib/ffi-glib/byte_array.rb