X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=glib%2Fgobject.meta.lisp;h=ad01deaa2589a0ffc3285f824754b64e6e1bb9f4;hb=02c0f62d617212f4e51224a2f7e76074dac1378e;hp=deac5b9ac54716819ce4d6cfb05f44eeb0d50f66;hpb=4779b2e12b19f4d3ea431b3784bbe0b8a463962d;p=cl-gtk2.git diff --git a/glib/gobject.meta.lisp b/glib/gobject.meta.lisp old mode 100644 new mode 100755 index deac5b9..ad01dea --- a/glib/gobject.meta.lisp +++ b/glib/gobject.meta.lisp @@ -37,6 +37,35 @@ (warn "Declared GType name '~A' for class '~A' is invalid (g_type_name returned 0)" (gobject-class-direct-g-type-name class) (class-name class))))) +(defun filter-from-initargs (initargs removed-key) + (loop + for (key value) on initargs by #'cddr + unless (eq key removed-key) + collect key and collect value)) + +(defun initargs-have-base-in-superclass (initargs base-class) + (let ((d-s (getf initargs :direct-superclasses))) + (loop + for class in d-s + thereis (subtypep class base-class)))) + +(defun compute-new-initargs-for-metaclass (initargs base-class) + (if (initargs-have-base-in-superclass initargs base-class) + initargs + (append (filter-from-initargs initargs :direct-superclasses) + (list :direct-superclasses + (append (getf initargs :direct-superclasses) + (list (find-class base-class))))))) + +(defmethod initialize-instance :around ((class gobject-class) &rest initargs) + (apply #'call-next-method class (compute-new-initargs-for-metaclass initargs 'g-object))) + +(defmethod reinitialize-instance :around ((class gobject-class) &rest initargs &key (direct-superclasses nil d-s-p) &allow-other-keys) + (declare (ignore direct-superclasses)) + (if d-s-p + (call-next-method) + (apply #'call-next-method class (compute-new-initargs-for-metaclass initargs 'g-object)))) + (defmethod initialize-instance :after ((object gobject-class) &key &allow-other-keys) (when (gobject-class-direct-g-type-name object) (register-object-type (gobject-class-direct-g-type-name object) (class-name object)) @@ -93,28 +122,27 @@ (defmethod validate-superclass ((class gobject-class) (superclass standard-class)) t) -(defmethod compute-class-precedence-list ((class gobject-class)) - (let ((classes (call-next-method))) - (if (member (find-class 'g-object) classes) - classes - `(,class ,(find-class 'g-object) ,@(rest classes))))) - -(defmethod direct-slot-definition-class ((class gobject-class) &rest initargs &key allocation) +(defmethod direct-slot-definition-class ((class gobject-class) &rest initargs &key allocation &allow-other-keys) (declare (ignore initargs)) (case allocation - (:gobject-property 'gobject-property-direct-slot-definition) - (:gobject-fn 'gobject-fn-direct-slot-definition) + (:gobject-property (find-class 'gobject-property-direct-slot-definition)) + (:gobject-fn (find-class 'gobject-fn-direct-slot-definition)) (otherwise (call-next-method)))) -(defmethod effective-slot-definition-class ((class gobject-class) &rest initargs &key allocation) +(defvar *e-s-d* nil) + +(defmethod effective-slot-definition-class ((class gobject-class) &rest initargs) (declare (ignore initargs)) - (case allocation - (:gobject-property 'gobject-property-effective-slot-definition) - (:gobject-fn 'gobject-fn-effective-slot-definition) - (otherwise (call-next-method)))) + (or *e-s-d* (call-next-method))) (defmethod compute-effective-slot-definition ((class gobject-class) name direct-slots) - (let ((effective-slot (call-next-method))) + (let ((effective-slot (let ((*e-s-d* (loop + for slot in direct-slots + when (typep slot 'gobject-direct-slot-definition) + return (etypecase slot + (gobject-property-direct-slot-definition (find-class 'gobject-property-effective-slot-definition)) + (gobject-fn-direct-slot-definition (find-class 'gobject-fn-effective-slot-definition)))))) + (call-next-method)))) (when (typep effective-slot 'gobject-effective-slot-definition) (let ((allocation (loop for direct-slot in direct-slots @@ -153,19 +181,28 @@ (gobject-fn-effective-slot-definition-g-getter-fn effective-slot) (and property-getter (if (stringp property-getter) - (compile nil `(lambda (object) - (foreign-funcall ,property-getter - g-object object - ,property-type))) + (compile nil (if (foreign-symbol-pointer property-getter) + `(lambda (object) + (foreign-funcall ,property-getter + g-object object + ,property-type)) + `(lambda (object) + (declare (ignore object)) + (error "Property getter ~A is not available" ,property-getter)) + )) property-getter)) (gobject-fn-effective-slot-definition-g-setter-fn effective-slot) (and property-setter (if (stringp property-setter) - (compile nil `(lambda (object new-value) - (foreign-funcall ,property-setter - g-object object - ,property-type new-value - :void))) + (compile nil (if (foreign-symbol-pointer property-setter) + `(lambda (object new-value) + (foreign-funcall ,property-setter + g-object object + ,property-type new-value + :void)) + `(lambda (object) + (declare (ignore object)) + (error "Property setter ~A is not avaiable" ,property-setter)))) property-setter))))))) effective-slot)) @@ -219,7 +256,9 @@ (defmethod slot-boundp-using-class ((class gobject-class) object (slot gobject-property-effective-slot-definition)) (handler-case - (progn (g-object-property-type (pointer object) (gobject-property-effective-slot-definition-g-property-name slot) :assert-readable t) t) + (and (slot-boundp object 'pointer) + (pointer object) + (progn (g-object-property-type (pointer 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)) @@ -231,20 +270,25 @@ (g-object-call-set-property (pointer object) (gobject-property-effective-slot-definition-g-property-name slot) new-value - (gobject-effective-slot-definition-g-property-type slot))) + (gobject-effective-slot-definition-g-property-type slot)) + new-value) (defmethod slot-boundp-using-class ((class gobject-class) object (slot gobject-fn-effective-slot-definition)) - (not (null (gobject-fn-effective-slot-definition-g-getter-fn slot)))) + (and (slot-boundp object 'pointer) + (pointer object) + (not (null (gobject-fn-effective-slot-definition-g-getter-fn slot))))) (defmethod slot-value-using-class ((class gobject-class) object (slot gobject-fn-effective-slot-definition)) (let ((fn (gobject-fn-effective-slot-definition-g-getter-fn slot))) (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)) + (funcall (gobject-fn-effective-slot-definition-g-setter-fn slot) object new-value) + new-value) (defmethod slot-boundp-using-class ((class gobject-class) object (slot gobject-effective-slot-definition)) - t) + (slot-boundp object 'pointer)) (defmethod slot-makunbound-using-class ((class gobject-class) object (slot gobject-effective-slot-definition)) + (declare (ignore object)) nil)