X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=glib%2Fgobject.meta.lisp;h=abeb0813c7a3cc62f018ad31482e3df3089a9fd9;hb=e9deaecd1782e4bec37bf2c8a490f9fa9fea972f;hp=d72494b3c57896e6dbffc13e0925803db13a9e04;hpb=ab143760c550327dd472c80c5b9072fc1d8a9815;p=cl-gtk2.git diff --git a/glib/gobject.meta.lisp b/glib/gobject.meta.lisp index d72494b..abeb081 100644 --- a/glib/gobject.meta.lisp +++ b/glib/gobject.meta.lisp @@ -9,21 +9,36 @@ :reader gobject-class-g-type-initializer) (interface-p :initform nil :initarg :g-interface-p - :reader gobject-class-interface-p))) + :reader gobject-class-interface-p)) + (:documentation "Metaclass for GObject-based classes.")) + +(defun initialize-gobject-class-g-type (class) + (if (gobject-class-g-type-initializer class) + (let* ((initializer-fn-ptr (foreign-symbol-pointer (gobject-class-g-type-initializer class))) + (type (when initializer-fn-ptr + (foreign-funcall-pointer initializer-fn-ptr nil + 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)) + (progn + (when (= +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-g-type-initializer class))) + (unless (string= (gobject-class-g-type-name class) + (g-type-name type)) + (warn "Declared GType name '~A' for class '~A' does not match actual GType name '~A'" + (gobject-class-g-type-name class) + (class-name class) + (g-type-name type)))))) + (unless (g-type-from-name (gobject-class-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))))) (defmethod initialize-instance :after ((object gobject-class) &key &allow-other-keys) (register-object-type (gobject-class-g-type-name object) (class-name object)) - (when (gobject-class-g-type-initializer object) - (let ((type (foreign-funcall-pointer (foreign-symbol-pointer (gobject-class-g-type-initializer object)) nil - g-type))) - (assert (/= +g-type-invalid+ type) nil "Declared GType name '~A' for class '~A' is invalid (g_type_name returned 0)" - (gobject-class-g-type-name object) (class-name object)) - (assert (string= (gobject-class-g-type-name object) - (g-type-name type)) - nil "Declared GType name '~A' for class '~A' does not match actual GType name '~A'" - (gobject-class-g-type-name object) - (class-name object) - (g-type-name type))))) + (at-init (object) (initialize-gobject-class-g-type object))) (defclass gobject-direct-slot-definition (standard-direct-slot-definition) ((g-property-type :initform nil @@ -196,12 +211,12 @@ (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)))