From 15cbdefc81be2567a4a0b348a277652a5bb9e6fa Mon Sep 17 00:00:00 2001 From: espen Date: Tue, 31 Jan 2006 14:02:51 +0000 Subject: [PATCH] Added code to register new types with the gobject type system --- glib/gtype.lisp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/glib/gtype.lisp b/glib/gtype.lisp index ea24580..afc1f62 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.32 2005-04-23 16:48:51 espen Exp $ +;; $Id: gtype.lisp,v 1.33 2006-01-31 14:02:51 espen Exp $ (in-package "GLIB") @@ -234,6 +234,40 @@ (substitute #\_ #\- (string-downcase type))))) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defclass type-info (struct) + ((class-size :allocation :alien :type (unsigned 16) :initarg :class-size) + (base-init :allocation :alien :type pointer) + (base-finalize :allocation :alien :type pointer) + (class-init :allocation :alien :type pointer) + (class-finalize :allocation :alien :type pointer) + (class-data :allocation :alien :type pointer) + (instance-size :allocation :alien :type (unsigned 16) + :initarg :instance-size) + (n-preallocs :allocation :alien :type (unsigned 16)) + (instance-init :allocation :alien :type pointer) + (value-table :allocation :alien :type pointer)) + (:metaclass struct-class))) + +(defbinding %type-register-static () type-number + (parent-type gtype) + (name string) + (info type-info) + (0 unsigned-int)) + +(defun register-new-type (type parent) + (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) + (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) + type-number)))) + + ;;;; Metaclass for subclasses of ginstance -- 2.11.0