X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=mop.lisp;h=da33f873fed27787e0eb017efbff65dd0db798d0;hb=7a312cdf8e1e8b5013bad08343c806460e05d6eb;hp=d1567ab5ac4254c6c9df828328f106355c348a48;hpb=a7f7ec44e3acd442817630a912b5a0c581e23538;p=hyperobject.git 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))