class GObject::GObject

we have a number of things we need to inherit in different ways:

the solution is to split the class into four areas which we treat differently:

Public Class Methods

ffi_managed_struct() click to toggle source
# File lib/vips/gobject.rb, line 98
def ffi_managed_struct
  self.const_get :ManagedStruct
end
ffi_struct() click to toggle source
# File lib/vips/gobject.rb, line 87
def ffi_struct
  self.const_get :Struct
end
new(ptr) click to toggle source

don’t allow ptr == nil, we never want to allocate a GObject struct ourselves, we just want to wrap GLib-allocated GObjects

here we use ManagedStruct, not Struct, since this is the ref that will need the unref

# File lib/vips/gobject.rb, line 73
def initialize ptr
  # GLib::logger.debug("GObject::GObject.initialize") {"ptr = #{ptr}"}
  @struct = ffi_managed_struct.new ptr

  # sometimes we need to keep refs across C calls ... hide them here
  @references = []
end

Public Instance Methods

ffi_managed_struct() click to toggle source

access to the managed struct for this class

# File lib/vips/gobject.rb, line 93
def ffi_managed_struct
  self.class.ffi_managed_struct
end
ffi_struct() click to toggle source

access to the casting struct for this class

# File lib/vips/gobject.rb, line 82
def ffi_struct
  self.class.ffi_struct
end