X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/e7dbc3bf4c4169062a861804a24e5b3381c27266..09f6e23711ab7b3b8f713f0cabdaeffcc7c4ac20:/glib/gtype.lisp?ds=sidebyside diff --git a/glib/gtype.lisp b/glib/gtype.lisp index b13bc6d..2a746e2 100644 --- a/glib/gtype.lisp +++ b/glib/gtype.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: gtype.lisp,v 1.34 2006-02-01 14:17:37 espen Exp $ +;; $Id: gtype.lisp,v 1.38 2006-02-04 12:15:32 espen Exp $ (in-package "GLIB") @@ -171,7 +171,7 @@ type (let ((name (find-foreign-type-name type-number))) (cond - ((and name (type-number-from-glib-name name nil)) + ((and name (not (= (type-number-from-glib-name name nil) type-number))) ;; This is a hack because GdkEvent seems to be registered ;; multiple times (type-from-number (type-number-from-glib-name name))) @@ -261,13 +261,13 @@ (info type-info) (0 unsigned-int)) -(defun register-new-type (type parent) +(defun register-new-type (type parent &optional foreign-name) (let ((parent-info (type-query parent))) (with-slots ((parent-number type-number) class-size instance-size) parent-info (let ((type-number (%type-register-static parent-number - (default-alien-type-name type) + (or foreign-name (default-alien-type-name type)) (make-instance 'type-info :class-size class-size :instance-size instance-size)))) (setf (gethash type *lisp-type-to-type-number*) type-number) (setf (gethash type-number *type-number-to-lisp-type*) type) @@ -279,21 +279,28 @@ (eval-when (:compile-toplevel :load-toplevel :execute) (defclass ginstance-class (proxy-class) - ())) + ((gtype :initarg :gtype :initform nil :reader ginstance-class-gtype)))) -(defmethod shared-initialize ((class ginstance-class) names &rest initargs &key name gtype) - (declare (ignore names)) - (let* ((class-name (or name (class-name class))) - (type-number +(defmethod compute-foreign-size ((class ginstance-class)) + (type-instance-size (find-type-number (class-name class)))) + +(defmethod finalize-inheritance ((class ginstance-class)) + (call-next-method) + (let* ((class-name (class-name class)) + (super (most-specific-proxy-superclass class)) + (gtype (or + (first (ginstance-class-gtype class)) + (default-alien-type-name class-name))) + (type-number (or (find-type-number class-name) - (register-type class-name - (or (first gtype) (default-type-init-name class-name)))))) - (if (getf initargs :size) - (call-next-method) - (let ((size (type-instance-size type-number))) - (apply #'call-next-method class names :size (list size) initargs))))) + (if (or (symbolp gtype) (type-number-from-glib-name gtype nil)) + (register-type class-name gtype) + (register-new-type class-name (class-name super) gtype))))) + (unless (eq (class-name super) (supertype type-number)) + (warn "~A is the super type for ~A in the gobject type system." + (supertype type-number) class-name)))) (defmethod validate-superclass ((class ginstance-class) (super standard-class)) @@ -304,8 +311,10 @@ (eval-when (:compile-toplevel :load-toplevel :execute) (defclass ginstance (proxy) - ((class :allocation :alien :type pointer)) - (:metaclass proxy-class))) + (;(class :allocation :alien :type pointer :offset 0) + ) + (:metaclass proxy-class) + (:size #.(size-of 'pointer)))) (defun %type-number-of-ginstance (location) (let ((class (sap-ref-sap location 0)))