;;;; in Text, HTML, and XML formats. This includes hyperlinking
;;;; capability and sub-objects.
;;;;
-;;;; $Id: hyperobject.lisp,v 1.15 2002/11/25 04:49:22 kevin Exp $
+;;;; $Id: hyperobject.lisp,v 1.17 2002/11/26 21:51:10 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg
;;;;
pcl::validate-superclass pcl:direct-slot-definition-class
pcl:compute-effective-slot-definition
pcl::compute-effective-slot-definition-initargs)
+ #+scl
+ `(class-of class-name 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)
:hyperobject))
:documentation "List of slots to print")
(description :initarg :description :initform nil
:documentation "Class description")
+ (version :initarg :version :initform nil
+ :documentation "Version number for class")
;;; The remainder of these fields are calculated one time
;;; in finalize-inheritence.
"List of fields that contain a list of subobjects objects.")
(references :type list :initform nil :documentation
"List of fields that have references")
+ (class-id :type integer :initform nil :documentation
+ "Unique ID for the class")
(value-func :initform nil :type function)
(xmlvalue-func :initform nil :type function)
iargs)
(find-class 'hyperobject-dsd))
-(defmacro define-class-option (slot-name &optional required)
- #+lispworks
- `(defmethod clos:process-a-class-option ((class hyperobject-class)
- (name (eql ,slot-name))
- value)
+
+; Slot definitions
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defmacro process-class-option (slot-name &optional required)
+ #+lispworks
+ `(defmethod clos:process-a-class-option ((class hyperobject-class)
+ (name (eql ,slot-name))
+ value)
(when (and ,required (null value))
(error "hyperobject class slot ~A must have a value" name))
- (if (null (cdr value))
- `(name ,(car value))
- `(name (quote value))))
- #+(or allegro sbcl cmu scl)
- (declare (ignore slot-name required))
- )
-
-(defmacro define-slot-option (slot-name)
- #+lispworks
- `(defmethod clos:process-a-slot-option ((class hyperobject-class)
- (option (eql ,slot-name))
- value
+ (list name `',value))
+ #+(or allegro sbcl cmu scl)
+ (declare (ignore slot-name required))
+ )
+
+ (defmacro process-slot-option (slot-name)
+ #+lispworks
+ `(defmethod clos:process-a-slot-option ((class hyperobject-class)
+ (option (eql ,slot-name))
+ value
already-processed-other-options
- slot)
- (list option value))
- #-lispworks
- (declare (ignore slot-name))
- )
-
-(define-class-option :title)
-(define-class-option :print-slots)
-(define-class-option :description)
-
-(define-slot-option :print-formatter)
-(define-slot-option :subobject)
-(define-slot-option :reference)
-(define-slot-option :description)
-
-;; Slot definitions
-
-(defclass hyperobject-dsd (standard-direct-slot-definition)
- ((ho-type :initarg :ho-type)
- (print-formatter :initarg :print-formatter)
- (subobject :initarg :subobject :initarg nil)
- (reference :initarg :reference :initarg nil)
- (description :initarg :description :initarg nil)
- ))
-
-(defclass hyperobject-esd (standard-effective-slot-definition)
- ((ho-type :initarg :ho-type :accessor esd-ho-type)
- (print-formatter :initarg :print-formatter :accessor esd-print-formatter)
- (subobject :initarg :subobject :accessor esd-subobject)
- (reference :initarg :reference :accessor esd-reference)
- (description :initarg :description :accessor esd-description)
- ))
-
-
-
+ slot)
+ (list option `',value))
+ #-lispworks
+ (declare (ignore slot-name))
+ )
+
+ (defparameter *class-options*
+ '(:title :print-slots :description :version :sql-name)
+ "List of class options for hyperobjects.")
+ (defparameter *slot-options*
+ '(:print-formatter :subobject :reference :description :unique :sql-name)
+ "List of slot options that can appear as an initarg")
+ (defparameter *slot-options-no-initarg*
+ '(:ho-type)
+ "List of slot options that do not have an initarg")
+
+ (dolist (option *class-options*)
+ (eval `(process-class-option ,option)))
+ (dolist (option *slot-options*)
+ (eval `(process-slot-option ,option)))
+
+ (eval
+ `(defclass hyperobject-dsd (standard-direct-slot-definition)
+ (,@(mapcar #'(lambda (x)
+ `(,(intern (symbol-name x))
+ :initform nil))
+ *slot-options-no-initarg*)
+ ,@(mapcar #'(lambda (x)
+ `(,(intern (symbol-name x))
+ :initarg
+ ,(intern (symbol-name x) (symbol-name :keyword))
+ :initform nil))
+ *slot-options*))))
+ (eval
+ `(defclass hyperobject-esd (standard-effective-slot-definition)
+ (,@(mapcar #'(lambda (x)
+ `(,(intern (symbol-name x))
+ :initarg
+ ,(intern (symbol-name x) (symbol-name :keyword))
+ :initform nil))
+ (append *slot-options* *slot-options-no-initarg*)))))
+ ) ;; eval-when
+
(defmethod compute-effective-slot-definition :around
((cl hyperobject-class) #+(or allegro lispworks) name dsds)
#+allergo (declare (ignore name))
'string)
(:float
'float)
+ (:nil
+ t)
(otherwise
ho-type)))
(dolist (slot (class-slots cl))
(when (slot-value slot 'subobject)
(push (make-instance 'subobject :name (slot-definition-name slot)
- :reader (if (eq t (esd-subobject slot))
+ :reader (if (eq t (slot-value slot 'subobject))
(slot-definition-name slot)
- (esd-subobject slot)))
+ (slot-value slot 'subobject)))
subobjects)))
subobjects)))
(package (symbol-package (class-name cl)))
(references nil))
(declare (ignore classname))
+ (check-type (slot-value cl 'print-slots) list)
(dolist (slot-name (slot-value cl 'print-slots))
(let ((slot (find-slot-by-name cl slot-name)))
(unless slot
(string-append fmtstr-html-labels html-label-str)
(string-append fmtstr-xml-labels xml-label-str)
- (if (esd-reference slot)
+ (if (slot-value slot 'reference)
(progn
(string-append fmtstr-html-ref "<~~a>" value-fmt "</~~a>")
(string-append fmtstr-xml-ref "<~~a>" value-fmt "</~~a>")
(string-append fmtstr-html-ref-labels "<span class=\"label\">" namestr-lower "</span> <~~a>" value-fmt "</~~a>")
(string-append fmtstr-xml-ref-labels "<label>" namestr-lower "</label> <~~a>" value-fmt "</~~a>")
- (push (make-instance 'reference :name name :lookup (esd-reference slot))
+ (push (make-instance 'reference :name name
+ :lookup (slot-value slot 'reference))
references))
(progn
(string-append fmtstr-html-ref html-str)
(if print-formatter
(setq plain-value-func
- (list `(,print-formatter (,(intern namestr package) x))))
+ (list `(,print-formatter (slot-value x ',(intern namestr package)))))
(setq plain-value-func
- (list `(,(intern namestr package) x))))
+ (list `(slot-value x ',(intern namestr package)))))
(setq value-func (append value-func plain-value-func))
(if (eql type :cdata)
(slot-value (class-of obj) 'xmlvalue-func))
(eval-when (:compile-toplevel :load-toplevel :execute)
-(defun hyperobject-class-title (obj)
- (awhen (slot-value (class-of obj) 'title)
- (if (consp it)
- (car it)
- it))))
+ (defun hyperobject-class-title (obj)
+ (awhen (slot-value (class-of obj) 'title)
+ (if (consp it)
+ (car it)
+ it))))
(defun hyperobject-class-subobjects (obj)
(slot-value (class-of obj) 'subobjects))