Package: gobject

CStruct gobject:object-class

Declaration

(cffi:defcstruct object-class
  ;; Class type
  (type-class (:struct type-class))
  ;; Private
  (construct-properties :pointer)
  ;; Virtual methods
  (constructor  (g:object
                 (type g:type-t)
                 (n-construct-properties :uint)
                 (construct-properties :pointer)))
  (set-property (:void
                 (object g:object)
                 (property-id :uint)
                 (value (:pointer (:struct g:value)))
                 (pspec g:param-spec)))
  (get-property (:void
                 (object g:object)
                 (property-id :uint)
                 (value (:pointer (:struct g:value)))
                 (pspec g:param-spec)))
  (dispose      (:void (object g:object)))
  (finalize     (:void (object g:object)))
  (dispatch-properties-changed
                (:void
                 (object g:object)
                 (n-pspecs :uint)
                 (pspecs (:pointer g:param-spec))))
  (notify       (:void (object g:object) (pspec g:param-spec)))
  (constructed  (:void (object g:object))))
  ;; Private
  (pdummy :pointer :count 7))  

Values

type-class
The parent class.
constructor
The constructor virtual method is called to complete the object initialization after all the construction properties are set. The first thing a method implementation must do is chain up to the constructor method of the parent class. Overriding the constructor method should be rarely needed, for example, to handle construct properties, or to implement singletons.
set-property
The generic setter for all properties of this type. Should be overridden for every type with properties. If implementations of the set-property method do not emit property change notification explicitly, this will be done implicitly by the type system. However, if the notify signal is emitted explicitly, the type system will not emit it a second time.
get-property
The generic getter for all properties of this type. Should be overridden for every type with properties.
dispose
The dispose virtual method is supposed to drop all references to other objects, but keep the instance otherwise intact, so that client method invocations still work. It may be run multiple times (due to reference loops). Before returning, the dispose method should chain up to the dispose method of the parent class.
finalize
Instance finalization function, should finish the finalization of the instance begun in the dispose method and chain up to the finalize method of the parent class.
dispatch-properties-changed
Emits property change notification for a bunch of properties. Overriding the dispatch-properties-changed method should be rarely needed.
notify
The class closure for the "notify" signal.
constructed
The constructed virtual method is called as the final step of the object creation process. At the point of the call, all construction properties have been set on the object. The purpose of this call is to allow for object initialisation steps that can only be performed after construction properties have been set. Implementors of the constructed method should chain up to the constructed method of their parent class to allow it to complete its initialisation.

Details

The class structure for the g:object class.

Notes

The g:object-class structure is used internally to implement the Lisp API. The main purpose for the Lisp API user is to use the size of the g:object-class structure and the documentation to implement virtual method tables for subclasses of the g:object class.

Examples

This is the installation of a virtual method table for an object class. The dispose and finalize virtual methods are overridden with the my-object-dispose-impl and my-object-finalize-impl methods, respectively. The :after keyword means that the new methods are chained up and called after the default implementation.
(gobject:define-gobject-subclass "MyObject" my-object
  (:superclass g:object
   :export nil
   :interfaces ())
  nil)

(gobject:define-vtable ("MyObject" my-object) ;; Class type (:skip type-class (:pointer (:struct g:type-class))) ;; Private (:skip construct-properties :pointer) ;; Virtual functions (:skip constructor :pointer) (:skip set-property :pointer) (:skip get-property :pointer) (dispose (:void (object (g:object my-object))) :chained :after) (finalize (:void (object (g:object my-object))) :chained :after) (:skip dispatch-properties-changed :pointer) (:skip notify :pointer) (:skip constructed :pointer))

(defmethod my-object-dispose-impl ((object my-object)) ... )

(defmethod my-object-finalize-impl ((object my-object)) ... )
 

See also

2026-11-16