Sha256: d7428834be0103ed9366ae04d16fc8d7db817a3ae107071b160bb24702599a83

Contents?: true

Size: 518 Bytes

Versions: 25

Compression:

Stored size: 518 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
      def new
        wrap(Lib.g_byte_array_new)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
gir_ffi-0.3.0 lib/ffi-glib/byte_array.rb
gir_ffi-0.2.3 lib/ffi-glib/byte_array.rb
gir_ffi-0.2.2 lib/ffi-glib/byte_array.rb
gir_ffi-0.2.1 lib/ffi-glib/byte_array.rb
gir_ffi-0.2.0 lib/ffi-glib/byte_array.rb