Sha256: 103d40ee5039935f7490b66a94d30e168670eb51e75dc16e59172b6df9d532bd

Contents?: true

Size: 510 Bytes

Versions: 2

Compression:

Stored size: 510 Bytes

Contents

module GLib
  load_class :ByteArray

  # 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 self.to_ptr, bytes, len)
    end

    class << self; undef :new; end

    def self.new
      wrap(Lib.g_byte_array_new)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-0.7.4 lib/ffi-glib/byte_array.rb
gir_ffi-0.7.3 lib/ffi-glib/byte_array.rb