From: Kevin M. Rosenberg Date: Fri, 13 Dec 2002 22:00:05 +0000 (+0000) Subject: r3623: *** empty log message *** X-Git-Tag: debian-2.11.0-2~226 X-Git-Url: http://git.kpe.io/?p=hyperobject.git;a=commitdiff_plain;h=7a312cdf8e1e8b5013bad08343c806460e05d6eb r3623: *** empty log message *** --- diff --git a/mop.lisp b/mop.lisp index d1567ab..da33f87 100644 --- a/mop.lisp +++ b/mop.lisp @@ -11,7 +11,7 @@ ;;;; in Text, HTML, and XML formats. This includes hyperlinking ;;;; capability and sub-objects. ;;;; -;;;; $Id: mop.lisp,v 1.11 2002/12/13 08:25:45 kevin Exp $ +;;;; $Id: mop.lisp,v 1.12 2002/12/13 22:00:05 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -48,6 +48,8 @@ "List of fields that contain a list of subobjects objects.") (hyperlinks :type list :initform nil :accessor hyperlinks :documentation "List of fields that have hyperlinks") + (direct-rules :type list :initform nil :accessor direct-rules + :documentation "List of rules to fire on slot changes.") (class-id :type integer :initform nil :accessor class-id :documentation "Unique ID for the class") @@ -203,6 +205,8 @@ :description (slot-value dsd 'description) :user-name (slot-value dsd 'user-name) :index (slot-value dsd 'index) + :value-constraint (slot-value dsd 'value-constraint) + :null-allowed (slot-value dsd 'null-allowed) ia)))) (defun ho-type-to-lisp-type (ho-type) @@ -362,3 +366,31 @@ (defun hyperobject-class-fields (obj) (class-slots (class-of obj))) +;;; Slot accessor and class rules + +(defun fire-class-rules (cl obj) + "Fire all class rules. Called after a slot is modified." + (dolist (rule (direct-rules cl)) + (cmsg "firing rule: ~a" rule))) + + +(defmethod (setf slot-value-using-class) + :around (new-value (cl hyperobject-class) obj + (slot standard-effective-slot-definition)) + (cmsg-c :verbose "Setf slot value: class: ~s, obj: ~s, slot: ~s, value: ~s" cl (class-of obj) slot new-value) + (let ((func (esd-value-constraint slot))) + (cond + ((and func (not (funcall func new-value obj))) + (warn "Rejected change to value of slot ~a of object ~a" + (slot-definition-name slot) obj) + (slot-value obj (slot-definition-name slot))) + (t + (call-next-method) + (fire-class-rules cl obj) + new-value)))) + +(defmethod slot-value-using-class :around ((cl hyperobject-class) obj + (slot standard-effective-slot-definition)) + (let ((value (call-next-method))) + (cmsg-c :verbose "slot value: class: ~s, obj: ~s, slot: ~s" cl (class-of obj) slot) + value)) diff --git a/package.lisp b/package.lisp index d0d3957..81cd8ae 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id: package.lisp,v 1.19 2002/12/13 07:33:54 kevin Exp $ +;;;; $Id: package.lisp,v 1.20 2002/12/13 22:00:05 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; ************************************************************************* @@ -40,12 +40,14 @@ `(mop::class-slots mop::slot-definition-name mop:finalize-inheritance mop::standard-direct-slot-definition mop::standard-effective-slot-definition mop:direct-slot-definition-class mop:compute-effective-slot-definition - excl::compute-effective-slot-definition-initargs) + excl::compute-effective-slot-definition-initargs + mop:slot-value-using-class) #+lispworks `(clos:class-slots clos::slot-definition-name clos:finalize-inheritance clos::standard-direct-slot-definition clos::standard-effective-slot-definition clos:direct-slot-definition-class clos:compute-effective-slot-definition - clos::compute-effective-slot-definition-initargs) + clos::compute-effective-slot-definition-initargs + clos:slot-value-using-class) #+sbcl `(sb-pcl:class-of sb-pcl:class-name sb-pcl:class-slots sb-pcl:find-class sb-pcl::standard-class @@ -53,21 +55,24 @@ sb-pcl::standard-direct-slot-definition sb-pcl::standard-effective-slot-definition sb-pcl::validate-superclass sb-pcl:direct-slot-definition-class sb-pcl:compute-effective-slot-definition - sb-pcl::compute-effective-slot-definition-initargs) + sb-pcl::compute-effective-slot-definition-initargs + sb-pcl::slot-value-using-class) #+cmu `(pcl:class-of pcl:class-name pcl:class-slots pcl:find-class pcl::standard-class pcl::slot-definition-name pcl:finalize-inheritance pcl::standard-direct-slot-definition pcl::standard-effective-slot-definition pcl::validate-superclass pcl:direct-slot-definition-class pcl:compute-effective-slot-definition - pcl::compute-effective-slot-definition-initargs) + pcl::compute-effective-slot-definition-initargs + pcl::slot-value-using-class) #+scl `(clos:class-slots clos::standard-class clos::slot-definition-name clos:finalize-inheritance clos::standard-direct-slot-definition clos::standard-effective-slot-definition clos::validate-superclass clos:direct-slot-definition-class clos:compute-effective-slot-definition - clos::compute-effective-slot-definition-initargs) + clos::compute-effective-slot-definition-initargs + clos::slot-value-using-class) :hyperobject))