X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=glib%2Fgobject.meta.lisp;h=2b67e7e3a381364bd2cce1553f5a456c1b071f84;hb=9baeb0045ccc5550358d331398c7e61ae078dbb6;hp=b5d3f4c818be956384faa873d66b8cc13652e701;hpb=af90ac5cff9dbb5f44677cc4726eee60ab88bc5d;p=cl-gtk2.git diff --git a/glib/gobject.meta.lisp b/glib/gobject.meta.lisp index b5d3f4c..2b67e7e 100644 --- a/glib/gobject.meta.lisp +++ b/glib/gobject.meta.lisp @@ -1,9 +1,11 @@ (in-package :gobject) (defclass gobject-class (standard-class) - ((g-type-name :initform (error "G-TYPE-NAME must be specified") - :initarg :g-type-name - :reader gobject-class-g-type-name) + ((g-type-name :initform nil + :accessor gobject-class-g-type-name) + (direct-g-type-name :initform nil + :initarg :g-type-name + :accessor gobject-class-direct-g-type-name) (g-type-initializer :initform nil :initarg :g-type-initializer :reader gobject-class-g-type-initializer) @@ -20,25 +22,33 @@ g-type)))) (if (null initializer-fn-ptr) (warn "Type initializer for class '~A' (GType '~A') is invalid: foreign symbol '~A'" - (gobject-class-g-type-name class) (class-name class) (gobject-class-g-type-initializer class)) + (gobject-class-direct-g-type-name class) (class-name class) (gobject-class-g-type-initializer class)) (progn - (when (= +g-type-invalid+ type) + (when (g-type= +g-type-invalid+ type) (warn "Declared GType name '~A' for class '~A' is invalid ('~A' returned 0)" - (gobject-class-g-type-name class) (class-name class) + (gobject-class-direct-g-type-name class) (class-name class) (gobject-class-g-type-initializer class))) - (unless (string= (gobject-class-g-type-name class) - (g-type-name type)) + (unless (g-type= (gobject-class-direct-g-type-name class) type) (warn "Declared GType name '~A' for class '~A' does not match actual GType name '~A'" - (gobject-class-g-type-name class) + (gobject-class-direct-g-type-name class) (class-name class) (g-type-name type)))))) - (unless (g-type-from-name (gobject-class-g-type-name class)) + (unless (g-type-from-name (gobject-class-direct-g-type-name class)) (warn "Declared GType name '~A' for class '~A' is invalid (g_type_name returned 0)" - (gobject-class-g-type-name class) (class-name class))))) + (gobject-class-direct-g-type-name class) (class-name class))))) (defmethod initialize-instance :after ((object gobject-class) &key &allow-other-keys) - (register-object-type (gobject-class-g-type-name object) (class-name object)) - (at-init (initialize-gobject-class-g-type object))) + (when (gobject-class-direct-g-type-name object) + (register-object-type (gobject-class-direct-g-type-name object) (class-name object)) + (at-init (object) (initialize-gobject-class-g-type object)))) + +(defmethod finalize-inheritance :after ((class gobject-class)) + (setf (gobject-class-g-type-name class) + (or (gobject-class-direct-g-type-name class) + (let ((gobject-superclass (iter (for superclass in (class-direct-superclasses class)) + (finding superclass such-that (typep superclass 'gobject-class))))) + (assert gobject-superclass) + (gobject-class-g-type-name gobject-superclass))))) (defclass gobject-direct-slot-definition (standard-direct-slot-definition) ((g-property-type :initform nil @@ -83,9 +93,6 @@ (defmethod validate-superclass ((class gobject-class) (superclass standard-class)) t) -(defmethod validate-superclass ((class standard-class) (superclass gobject-class)) - t) - (defmethod compute-class-precedence-list ((class gobject-class)) (let ((classes (call-next-method))) (if (member (find-class 'g-object) classes) @@ -202,29 +209,34 @@ (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))) - (apply #'call-next-method class :pointer pointer initargs)))) + (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 - (progn (g-object-property-type object (gobject-property-effective-slot-definition-g-property-name slot) :assert-readable t) t) + (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)) - (g-object-call-get-property object + (g-object-call-get-property (pointer object) (gobject-property-effective-slot-definition-g-property-name slot) (gobject-effective-slot-definition-g-property-type slot))) (defmethod (setf slot-value-using-class) (new-value (class gobject-class) object (slot gobject-property-effective-slot-definition)) - (g-object-call-set-property object + (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))) +(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)))) + (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))) - (when fn - (funcall fn object)))) + (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))