diff --git a/core/message.lisp b/core/message.lisp index a34ca79..15d715e 100644 --- a/core/message.lisp +++ b/core/message.lisp @@ -18,4 +18,4 @@ (make-instance 'message :head head :data data :sender sender)) (defmethod print-object ((msg message) stream) - (shape:print-fields msg stream 'shape:head 'sender 'shape:data)) + (shape:print-slots msg stream 'shape:head 'sender 'shape:data)) diff --git a/shape/shape.lisp b/shape/shape.lisp index fedf8ee..dd71fed 100644 --- a/shape/shape.lisp +++ b/shape/shape.lisp @@ -3,7 +3,7 @@ (defpackage :scopes/shape (:use :common-lisp) (:local-nicknames (:util :scopes/util)) - (:export #:record #:print-fields + (:export #:record #:print-fields #:print-slots #:head-fields #:head #:head-value #:head-plist #:data-fields #:data #:data-value)) @@ -28,6 +28,13 @@ (print-unreadable-object (rec stream :type t) (apply #'format stream fm (mapcar #'(lambda (x) (funcall x rec)) fields))))) +(defun print-slots (rec stream &rest fields) + (let ((fm (util:make-vars-format fields))) + (print-unreadable-object (rec stream :type t) + (apply #'format stream fm + (mapcar #'(lambda (x) (when (slot-boundp rec x) (slot-value rec x))) + fields))))) + (defun head-value (rec key) (elt (head rec) (position key (head-fields rec)))) diff --git a/storage/msgstore.lisp b/storage/msgstore.lisp index 752cd6c..e9994f3 100644 --- a/storage/msgstore.lisp +++ b/storage/msgstore.lisp @@ -10,7 +10,8 @@ (in-package :scopes/storage/msgstore) -(defclass pmsg (message:message tracking:track) ()) +(defclass pmsg (message:message tracking:track) + ((shape:head-fields :initform '(:domain :action :class :item) :allocation :class))) (defun indexes (cont) '((domain action class item) (domain class item))) diff --git a/storage/tracking.lisp b/storage/tracking.lisp index ce842ea..7e225e3 100644 --- a/storage/tracking.lisp +++ b/storage/tracking.lisp @@ -7,7 +7,8 @@ (:storage :scopes/storage) (:util :scopes/util) (:alx :alexandria) - (:jzon :com.inuoe.jzon)) + (:jzon :com.inuoe.jzon) + (:mop :closer-mop)) (:export #:track #:trackid #:id-str #:key-fields #:timestamp #:container #:make-container #:table-name #:storage #:make-item #:get-track #:query-last #:query-one #:query #:make-where @@ -61,8 +62,12 @@ (make-instance 'container :short-name :trk :storage st)) (defmethod initialize-instance :after ((cont container) &key &allow-other-keys) - (setf (gethash (short-name cont) *containers*) cont) - (setf (item-head-fields cont) (shape:head-fields (make-instance (item-class cont))))) + (let ((ic (find-class (item-class cont)))) + (setf (gethash (short-name cont) *containers*) cont) + ;(mop:ensure-finalized ic) + ;(setf (item-head-fields cont) + ; (shape:head-fields (mop:class-prototype ic))))) + (setf (item-head-fields cont) (shape:head-fields (make-instance ic))))) (defun make-item (cont &rest head) (make-instance (item-class cont) :head head :container cont))