X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=glib%2Fgobject.meta.lisp;h=d72494b3c57896e6dbffc13e0925803db13a9e04;hb=ab143760c550327dd472c80c5b9072fc1d8a9815;hp=c448d3740fcbd153f60f0795b488a6ef5f21e755;hpb=4c22e03a95b43c06f3518c27df8ebccae04cb2c6;p=cl-gtk2.git diff --git a/glib/gobject.meta.lisp b/glib/gobject.meta.lisp index c448d37..d72494b 100644 --- a/glib/gobject.meta.lisp +++ b/glib/gobject.meta.lisp @@ -171,13 +171,29 @@ do (funcall fn object value)) object))) +(defun filter-initargs-by-class (class initargs) + (iter (with slots = (class-slots class)) + (for (arg-name arg-value) on initargs by #'cddr) + (for slot = (find arg-name slots :key #'slot-definition-initargs :test 'member)) + (unless (and slot (typep slot 'gobject-effective-slot-definition)) + (nconcing (list arg-name arg-value))))) + +(defmethod initialize-instance ((instance g-object) &rest initargs &key &allow-other-keys) + (let ((filtered-initargs (filter-initargs-by-class (class-of instance) initargs))) + (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 ((pointer (create-gobject-from-class-and-initargs class initargs))) - (call-next-method class :pointer pointer)))) + (apply #'call-next-method class :pointer pointer initargs)))) + +(defmethod slot-boundp-using-class ((class gobject-class) object (slot gobject-property-effective-slot-definition)) + (handler-case + (progn (g-object-property-type object (gobject-property-effective-slot-definition-g-property-name slot) :assert-readable t) t) + (property-unreadable-error () nil))) (defmethod slot-value-using-class ((class gobject-class) object (slot gobject-property-effective-slot-definition)) (g-object-call-get-property object @@ -191,7 +207,9 @@ (gobject-effective-slot-definition-g-property-type slot))) (defmethod slot-value-using-class ((class gobject-class) object (slot gobject-fn-effective-slot-definition)) - (funcall (gobject-fn-effective-slot-definition-g-getter-fn slot) object)) + (let ((fn (gobject-fn-effective-slot-definition-g-getter-fn slot))) + (when fn + (funcall fn object)))) (defmethod (setf slot-value-using-class) (new-value (class gobject-class) object (slot gobject-fn-effective-slot-definition)) (funcall (gobject-fn-effective-slot-definition-g-setter-fn slot) object new-value))