-(defun hyperobject-class-fmtstr-html-ref (obj)
- (slot-value (class-of obj) 'fmtstr-html-ref))
-
-(defun hyperobject-class-fmtstr-xml-ref (obj)
- (slot-value (class-of obj) 'fmtstr-xml-ref))
-
-(defun hyperobject-class-fmtstr-html-ref-labels (obj)
- (slot-value (class-of obj) 'fmtstr-html-ref-labels))
-
-(defun hyperobject-class-fmtstr-xml-ref-labels (obj)
- (slot-value (class-of obj) 'fmtstr-xml-ref-labels))
-
+;;; 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))