(defstruct object-type name class parent interfaces properties)
(defun instance-init (instance class)
+ (log-for :subclass "(instance-init ~A ~A)~%" instance class)
(log-for :subclass "Initializing instance ~A for type ~A (creating ~A)~%" instance (g-type-name (foreign-slot-value class 'g-type-class :type)) *current-creating-object*)
(unless (or *current-creating-object*
+ *currently-making-object-p*
(gethash (pointer-address instance) *foreign-gobjects-strong*)
(gethash (pointer-address instance) *foreign-gobjects-weak*))
- (log-for :subclass " Proceeding with initialization...")
+ (log-for :subclass "Proceeding with initialization...~%")
(let* ((g-type (foreign-slot-value class 'g-type-class :type))
(type-name (g-type-name g-type))
(lisp-type-info (gethash type-name *registered-types*))
(callback c-instance-init) nil))
(add-interfaces ,name))
(defmethod initialize-instance :before ((object ,class) &key pointer)
+ (log-for :subclass "(initialize-instance ~A :pointer ~A) :before~%" object pointer)
(unless (or pointer (and (slot-boundp object 'gobject::pointer)
(gobject::pointer object)))
+ (log-for :subclass "calling g-object-constructor~%")
(setf (gobject::pointer object) (gobject::g-object-call-constructor ,name nil nil)
(gobject::g-object-has-reference object) t)))
(progn
(apply #'call-next-method instance filtered-initargs)))
(defmethod make-instance ((class gobject-class) &rest initargs &key pointer)
- (if pointer
- (progn
- (assert (= (length initargs) 2) nil "POINTER can not be combined with other initargs (~A)" initargs)
- (call-next-method))
- (let* ((default-initargs (iter (for (arg value) in (class-default-initargs class))
- (nconcing (list arg value))))
- (effective-initargs (append initargs default-initargs))
- (pointer (create-gobject-from-class-and-initargs class effective-initargs)))
- (apply #'call-next-method class :pointer pointer effective-initargs))))
+ (log-for :subclass "(make-instance ~A ~{~A~^ ~})~%" class initargs)
+ (let ((*currently-making-object-p* t))
+ (if pointer
+ (progn
+ (assert (= (length initargs) 2) nil "POINTER can not be combined with other initargs (~A)" initargs)
+ (call-next-method))
+ (let* ((default-initargs (iter (for (arg value) in (class-default-initargs class))
+ (nconcing (list arg value))))
+ (effective-initargs (append initargs default-initargs))
+ (pointer (create-gobject-from-class-and-initargs class effective-initargs)))
+ (apply #'call-next-method class :pointer pointer effective-initargs)))))
(defmethod slot-boundp-using-class ((class gobject-class) object (slot gobject-property-effective-slot-definition))
(handler-case
(defvar *foreign-gobjects-strong* (make-hash-table :test 'equal))
(defvar *current-creating-object* nil)
(defvar *current-object-from-pointer* nil)
+(defvar *currently-making-object-p* nil)
(defun ref-count (pointer)
(foreign-slot-value (if (pointerp pointer) pointer (pointer pointer)) 'g-object-struct :ref-count))
(defmethod initialize-instance :around ((obj g-object) &key)
+ (when *currently-making-object-p*
+ (setf *currently-making-object-p* t))
(let ((*current-creating-object* obj))
+ (log-for :subclass "initialize-instance :around; *current-creating-object* = ~A~%" obj)
(call-next-method)))
(defmethod initialize-instance :after ((obj g-object) &key &allow-other-keys)