r3623: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 13 Dec 2002 22:00:05 +0000 (22:00 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 13 Dec 2002 22:00:05 +0000 (22:00 +0000)
mop.lisp
package.lisp

index d1567ab5ac4254c6c9df828328f106355c348a48..da33f873fed27787e0eb017efbff65dd0db798d0 100644 (file)
--- 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")
        :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)
 (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))
index d0d3957144c16042ea11a4d2d839af65ffceaf0f..81cd8ae62e89dbc98fadf022d65501b758b3c159 100644 (file)
@@ -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
 ;;;; *************************************************************************
    `(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
      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))