r3018: *** empty log message ***
[kmrcl.git] / ml-class.lisp
index 59e2211a00511f829dc07b634fd2db7ddd102d37..f32a974a29f067aa25bafe7744bd8978b159bef1 100644 (file)
 ;;;; in Text, HTML, and XML formats. This includes hyperlinking
 ;;;; capability and sub-objects.
 ;;;;
-;;;; $Id: ml-class.lisp,v 1.3 2002/10/06 13:35:30 kevin Exp $
+;;;; $Id: ml-class.lisp,v 1.9 2002/10/14 15:01:17 kevin Exp $
 ;;;;
-;;;; This file, part of Kmrcl, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
-;;;; Kmrcl users are granted the rights to distribute and use this software
-;;;; as governed by the terms of the GNU General Public License.
+;;;; KMRCL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
 ;;;; *************************************************************************
  
 (in-package :kmrcl)
 
 (declaim (optimize (speed 3) (safety 1)))
 
+(defun ml-class-of (obj)
+  #-(or cmu sbcl) (class-of obj)
+  #+sbcl (sb-pcl:class-of obj)
+  #+cmu (pcl:class-of obj))
 
-(defclass ml-class (standard-class)
+(defclass ml-class (#-(or cmu sbcl) standard-class
+                     #+cmu pcl::standard-class
+                     #+sbcl sb-pcl::standard-class)
   ((title :initarg :title :type string :reader ml-std-title
          :documentation 
 "Print Title for class")
@@ -60,6 +67,23 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
   (:default-initargs :title nil :fields nil :subobjects-lists nil :ref-fields nil)
   (:documentation "Metaclass for Markup Language classes."))
 
+#+cmu
+(defmethod pcl:finalize-inheritance :after ((cl ml-class))
+  (init-ml-class cl))
+
+
+#+sbcl
+(defmethod sb-pcl:finalize-inheritance :after ((cl ml-class))
+  (init-ml-class cl))
+
+
+#+cmu
+(defmethod pcl:validate-superclass ((class ml-class) (superclass pcl::standard-class))
+  t)
+
+#+sbcl
+(defmethod sb-pcl:validate-superclass ((class ml-class) (superclass sb-pcl::standard-class))
+  t)
 
 #+allegro
 (defmethod mop:finalize-inheritance :after ((cl ml-class))
@@ -69,9 +93,15 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
 (defmethod clos:finalize-inheritance :after ((cl ml-class))
   (init-ml-class cl))
 
-#+cmu
-(defmethod pcl:finalize-inheritance :after ((cl ml-class))
-  (init-ml-class cl))
+;;#+cmu
+;;(defmethod pcl::class-finalized-p ((cl ml-class))
+;;  (and (not (null (slot-value cl 'pcl::wrapper)))
+;;       (not (null (slot-value cl 'fmtstr-text)))))
+
+;;#+sbcl
+;;(defmethod sb-pcl::class-finalized-p ((cl ml-class))
+;;  (and (not (null (slot-value cl 'sb-pcl::wrapper)))
+;;       (not (null (slot-value cl 'fmtstr-text)))))
 
 #+lispworks
 (defmethod clos:process-a-class-option ((class ml-class)
@@ -197,9 +227,9 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
            (setq xmlvalue-func (append xmlvalue-func plain-value-func)))
          ))
 
-      (setq value-func `(lambda (x) (values ,@value-func)))
+      (setq value-func `(lambda () (values ,@value-func)))
       (setq value-func (compile nil (eval value-func)))
-      (setq xmlvalue-func `(lambda (x) (values ,@xmlvalue-func)))
+      (setq xmlvalue-func `(lambda () (values ,@xmlvalue-func)))
       (setq xmlvalue-func (compile nil (eval xmlvalue-func)))
 
       (setf (slot-value cl 'fmtstr-text) fmtstr-text)
@@ -218,64 +248,64 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
 
 
 (defun ml-class-fmtstr-text (obj)
-  (slot-value (class-of obj) 'fmtstr-text))
+  (slot-value (ml-class-of obj) 'fmtstr-text))
 
 (defun ml-class-fmtstr-html (obj)
-  (slot-value (class-of obj) 'fmtstr-html))
+  (slot-value (ml-class-of obj) 'fmtstr-html))
 
 (defun ml-class-fmtstr-xml (obj)
-  (slot-value (class-of obj) 'fmtstr-xml))
+  (slot-value (ml-class-of obj) 'fmtstr-xml))
 
 (defun ml-class-fmtstr-text-labels (obj)
-  (slot-value (class-of obj) 'fmtstr-text-labels))
+  (slot-value (ml-class-of obj) 'fmtstr-text-labels))
 
 (defun ml-class-fmtstr-html-labels (obj)
-  (slot-value (class-of obj) 'fmtstr-html-labels))
+  (slot-value (ml-class-of obj) 'fmtstr-html-labels))
 
 (defun ml-class-fmtstr-xml-labels (obj)
-  (slot-value (class-of obj) 'fmtstr-xml-labels))
+  (slot-value (ml-class-of obj) 'fmtstr-xml-labels))
 
 (defun ml-class-value-func (obj)
-  (slot-value (class-of obj) 'value-func))
+  (slot-value (ml-class-of obj) 'value-func))
 
 (defun ml-class-xmlvalue-func (obj)
-  (slot-value (class-of obj) 'xmlvalue-func))
+  (slot-value (ml-class-of obj) 'xmlvalue-func))
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
 (defun ml-class-title (obj)
-  (awhen (slot-value (class-of obj) 'title)
+  (awhen (slot-value (ml-class-of obj) 'title)
            (if (consp it)
                (car it)
              it))))
 
 (defun ml-class-subobjects-lists (obj)
-  (slot-value (class-of obj) 'subobjects-lists))
+  (slot-value (ml-class-of obj) 'subobjects-lists))
 
 (defun ml-class-ref-fields (obj)
-  (slot-value (class-of obj) 'ref-fields))
+  (slot-value (ml-class-of obj) 'ref-fields))
 
 (defun ml-class-fields (obj)
-  (slot-value (class-of obj) 'fields))
+  (slot-value (ml-class-of obj) 'fields))
 
 (defun ml-class-fmtstr-html-ref (obj)
-  (slot-value (class-of obj) 'fmtstr-html-ref))
+  (slot-value (ml-class-of obj) 'fmtstr-html-ref))
 
 (defun ml-class-fmtstr-xml-ref (obj)
-  (slot-value (class-of obj) 'fmtstr-xml-ref))
+  (slot-value (ml-class-of obj) 'fmtstr-xml-ref))
 
 (defun ml-class-fmtstr-html-ref-labels (obj)
-  (slot-value (class-of obj) 'fmtstr-html-ref-labels))
+  (slot-value (ml-class-of obj) 'fmtstr-html-ref-labels))
 
 (defun ml-class-fmtstr-xml-ref-labels (obj)
-  (slot-value (class-of obj) 'fmtstr-xml-ref-labels))
+  (slot-value (ml-class-of obj) 'fmtstr-xml-ref-labels))
 
 ;;; Class name functions
 
 (defmethod ml-class-stdname ((name string))
-  (string-downcase (subseq name :start 1)))
+  (string-downcase (subseq name 1)))
   
 (defmethod ml-class-stdname ((cl standard-object))
-  (string-downcase (subseq (class-name (class-of cl)) :start 1)))
+  (string-downcase (subseq (class-name (ml-class-of cl)) 1)))
   
 ;;;; Generic Print functions
 
@@ -378,18 +408,15 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
     :obj-data-fmtstr-labels #'ml-class-fmtstr-html-labels
     :obj-data-value-func #'ml-class-value-func))
 
-(defclass htmlrefformat (htmlformat)
-  ()
-  (:default-initargs :link-ref (make-instance 'html-link-ref)))
 
 (defun class-name-of (obj)
-  (string-downcase (class-name (class-of obj))))
+  (string-downcase (class-name (ml-class-of obj))))
 
 (defun xmlformat-list-end-value-func (x)
-  (format nil "~alist" (string-downcase (class-name (class-of x)))))
+  (format nil "~alist" (string-downcase (class-name (ml-class-of x)))))
 
 (defun xmlformat-list-start-value-func (x nitems) 
-  (values (format nil "~alist" (string-downcase (class-name (class-of x)))) (ml-class-title x) nitems))
+  (values (format nil "~alist" (string-downcase (class-name (ml-class-of x)))) (ml-class-title x) nitems))
 
 (defclass xmlformat (textformat) 
   ()
@@ -411,10 +438,6 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
     :obj-data-fmtstr-labels #'ml-class-fmtstr-xml-labels
     :obj-data-value-func #'ml-class-xmlvalue-func))
 
-(defclass xmlrefformat (xmlformat)
-  ()
-  (:default-initargs :link-ref (make-instance 'xml-link-ref)))
-
 (defclass link-ref ()
   ((fmtstr :type function :initarg :fmtstr :accessor fmtstr)
    (fmtstr-labels :type function :initarg :fmtstr-labels :accessor fmtstr-labels)
@@ -445,6 +468,15 @@ Format is ((field-name field-lookup-func other-link-params) ...)")
     :ampersand "&"))
 
 
+(defclass htmlrefformat (htmlformat)
+  ()
+  (:default-initargs :link-ref (make-instance 'html-link-ref)))
+
+(defclass xmlrefformat (xmlformat)
+  ()
+  (:default-initargs :link-ref (make-instance 'xml-link-ref)))
+
+
 ;;; File Start and Ends
 
 (defmethod fmt-file-start ((fmt dataformat) (s stream)))