;;;; in Text, HTML, and XML formats. This includes hyperlinking
;;;; capability and sub-objects.
;;;;
-;;;; $Id: ml-class.lisp,v 1.2 2002/10/06 13:30:17 kevin Exp $
+;;;; $Id: ml-class.lisp,v 1.6 2002/10/13 17:39:50 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)
((title :initarg :title :type string :reader ml-std-title
(:default-initargs :title nil :fields nil :subobjects-lists nil :ref-fields nil)
(:documentation "Metaclass for Markup Language classes."))
+#+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)
+
+#+cmu
+(defmethod pcl:validate-superclass ((class pcl::standard-class) (superclass ml-class))
+ t)
+
+#+sbcl
+(defmethod sb-pcl:validate-superclass ((class sb-pcl::standard-class) (superclass ml-class))
+ t)
#+allegro
(defmethod mop:finalize-inheritance :after ((cl ml-class))
(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))
+
#+lispworks
(defmethod clos:process-a-class-option ((class ml-class)
(name (eql :title))
(if first-field
(setq first-field nil)
(progn
- (gu:string-append fmtstr-text " ")
- (gu:string-append fmtstr-html " ")
- (gu:string-append fmtstr-xml " ")
- (gu:string-append fmtstr-text-labels " ")
- (gu:string-append fmtstr-html-labels " ")
- (gu:string-append fmtstr-xml-labels " ")
- (gu:string-append fmtstr-html-ref " ")
- (gu:string-append fmtstr-xml-ref " ")
- (gu:string-append fmtstr-html-ref-labels " ")
- (gu:string-append fmtstr-xml-ref-labels " ")))
+ (string-append fmtstr-text " ")
+ (string-append fmtstr-html " ")
+ (string-append fmtstr-xml " ")
+ (string-append fmtstr-text-labels " ")
+ (string-append fmtstr-html-labels " ")
+ (string-append fmtstr-xml-labels " ")
+ (string-append fmtstr-html-ref " ")
+ (string-append fmtstr-xml-ref " ")
+ (string-append fmtstr-html-ref-labels " ")
+ (string-append fmtstr-xml-ref-labels " ")))
(setq html-str value-fmt)
(setq xml-str (concatenate 'string "<" namestr-lower ">" value-fmt "</" namestr-lower ">"))
(setq html-label-str (concatenate 'string "<i>" namestr-lower "</i> " value-fmt))
(setq xml-label-str (concatenate 'string "<label>" namestr-lower "</label> <" namestr-lower ">" value-fmt "</" namestr-lower ">"))
- (gu:string-append fmtstr-text value-fmt)
- (gu:string-append fmtstr-html html-str)
- (gu:string-append fmtstr-xml xml-str)
- (gu:string-append fmtstr-text-labels namestr-lower " " value-fmt)
- (gu:string-append fmtstr-html-labels html-label-str)
- (gu:string-append fmtstr-xml-labels xml-label-str)
+ (string-append fmtstr-text value-fmt)
+ (string-append fmtstr-html html-str)
+ (string-append fmtstr-xml xml-str)
+ (string-append fmtstr-text-labels namestr-lower " " value-fmt)
+ (string-append fmtstr-html-labels html-label-str)
+ (string-append fmtstr-xml-labels xml-label-str)
(if (find name ref-fields :key #'car)
(progn
- (gu:string-append fmtstr-html-ref "<~~a>" value-fmt "</~~a>")
- (gu:string-append fmtstr-xml-ref "<~~a>" value-fmt "</~~a>")
- (gu:string-append fmtstr-html-ref-labels "<i>" namestr-lower "</i> <~~a>" value-fmt "</~~a>")
- (gu:string-append fmtstr-xml-ref-labels "<label>" namestr-lower "</label> <~~a>" value-fmt "</~~a>"))
+ (string-append fmtstr-html-ref "<~~a>" value-fmt "</~~a>")
+ (string-append fmtstr-xml-ref "<~~a>" value-fmt "</~~a>")
+ (string-append fmtstr-html-ref-labels "<i>" namestr-lower "</i> <~~a>" value-fmt "</~~a>")
+ (string-append fmtstr-xml-ref-labels "<label>" namestr-lower "</label> <~~a>" value-fmt "</~~a>"))
(progn
- (gu:string-append fmtstr-html-ref html-str)
- (gu:string-append fmtstr-xml-ref xml-str)
- (gu:string-append fmtstr-html-ref-labels html-label-str)
- (gu:string-append fmtstr-xml-ref-labels xml-label-str)))
+ (string-append fmtstr-html-ref html-str)
+ (string-append fmtstr-xml-ref xml-str)
+ (string-append fmtstr-html-ref-labels html-label-str)
+ (string-append fmtstr-xml-ref-labels xml-label-str)))
(if formatter
(setq plain-value-func
- (list `(,formatter (,(gu:concat-symbol-pkg
+ (list `(,formatter (,(concat-symbol-pkg
:umlisp namestr) x))))
(setq plain-value-func
- (list `(,(gu:concat-symbol-pkg
+ (list `(,(concat-symbol-pkg
:umlisp namestr) x))))
(setq value-func (append value-func plain-value-func))
(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)
- (gu:awhen (slot-value (class-of obj) 'title)
- (if (consp gu:it)
- (car gu:it)
- gu:it))))
+ (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
(string-downcase (subseq name :start 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)) :start 1)))
;;;; Generic Print functions
: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)
()
- (:default-initargs :file-start-str "" ; (gu:std-xml-header)
+ (:default-initargs :file-start-str "" ; (std-xml-header)
:list-start-indent t
:list-start-fmtstr "<~a><title>~a~p:</title> ~%"
:list-start-value-func #'xmlformat-list-start-value-func
: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)
: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)))
(defmethod fmt-file-start ((fmt textformat) (s stream))
- (gu:aif (file-start-str fmt)
- (format s gu::it)))
+ (aif (file-start-str fmt)
+ (format s it)))
(defmethod fmt-file-end ((fmt textformat) (s stream))
- (gu:aif (file-end-str fmt)
- (format s gu::it)))
+ (aif (file-end-str fmt)
+ (format s it)))
;;; List Start and Ends
(defmethod fmt-list-start (x (fmt textformat) (s stream) &optional (indent 0) (num-items 1))
(if (list-start-indent fmt)
- (gu:indent-spaces indent s))
- (gu:aif (list-start-fmtstr fmt)
- (apply #'format s gu::it
+ (indent-spaces indent s))
+ (aif (list-start-fmtstr fmt)
+ (apply #'format s it
(multiple-value-list
(funcall (list-start-value-func fmt) x num-items)))))
(defmethod fmt-list-end (x (fmt textformat) (s stream) &optional (indent 0) (num-items 1))
(declare (ignore num-items))
(if (list-end-indent fmt)
- (gu:indent-spaces indent s))
- (gu:aif (list-end-fmtstr fmt)
- (apply #'format s gu::it
+ (indent-spaces indent s))
+ (aif (list-end-fmtstr fmt)
+ (apply #'format s it
(multiple-value-list
(funcall (list-end-value-func fmt) x)))))
(defmethod fmt-obj-start (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-start-indent fmt)
- (gu:indent-spaces indent s))
- (gu:aif (obj-start-fmtstr fmt)
- (apply #'format s gu::it
+ (indent-spaces indent s))
+ (aif (obj-start-fmtstr fmt)
+ (apply #'format s it
(multiple-value-list
(funcall (obj-start-value-func fmt) x)))))
(defmethod fmt-obj-end (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-end-indent fmt)
- (gu:indent-spaces indent s))
- (gu:aif (obj-end-fmtstr fmt)
- (apply #'format s gu::it
+ (indent-spaces indent s))
+ (aif (obj-end-fmtstr fmt)
+ (apply #'format s it
(multiple-value-list
(funcall (obj-end-value-func fmt) x)))))
(if refvars
(let ((varstr ""))
(dolist (var refvars)
- (gu:string-append varstr (format nil "~a~a=~a"
+ (string-append varstr (format nil "~a~a=~a"
(ampersand ref) (car var) (cadr var))))
varstr)
"")))
(defmethod fmt-obj-data (x (fmt textformat) s
&optional (indent 0) (label nil) (refvars nil))
(if (obj-data-indent fmt)
- (gu:indent-spaces indent s))
+ (indent-spaces indent s))
(if (link-ref fmt)
(fmt-obj-data-with-ref x fmt s label refvars)
(fmt-obj-data-plain x fmt s label))
- (gu:aif (obj-data-end-fmtstr fmt)
- (format s gu::it)))
+ (aif (obj-data-end-fmtstr fmt)
+ (format s it)))
(defmethod fmt-obj-data-plain (x (fmt textformat) s label)
(if label
(defmethod load-all-subobjects (objs)
"Load all subobjects if they have not already been loaded."
(when objs
- (let ((objlist (gu:mklist objs)))
+ (let ((objlist (mklist objs)))
(dolist (obj objlist)
- (gu:awhen (ml-class-subobjects-lists obj) ;; access list of functions
- (dolist (child-obj gu::it) ;; for each child function
- (gu:awhen (funcall (car child-obj) obj)
- (load-all-subobjects gu:it))))))
+ (awhen (ml-class-subobjects-lists obj) ;; access list of functions
+ (dolist (child-obj it) ;; for each child function
+ (awhen (funcall (car child-obj) obj)
+ (load-all-subobjects it))))))
objs))
(defmethod output-ml-class (objs (fmt dataformat) (strm stream)
(indent 0) (subobjects nil) (refvars nil))
"Display a single or list of ml-class instances and their subobjects"
(when objs
- (setq objs (gu:mklist objs))
+ (setq objs (mklist objs))
(let ((nobjs (length objs)))
(fmt-list-start (car objs) fmt strm indent nobjs)
(dolist (obj objs)
(fmt-obj-start obj fmt strm indent)
(fmt-obj-data obj fmt strm (1+ indent) label refvars)
(if subobjects
- (gu:awhen (ml-class-subobjects-lists obj) ;; access list of functions
- (dolist (child-obj gu::it) ;; for each child function
- (gu:awhen (funcall (car child-obj) obj) ;; access set of child objects
- (output-ml-class gu::it fmt strm label
+ (awhen (ml-class-subobjects-lists obj) ;; access list of functions
+ (dolist (child-obj it) ;; for each child function
+ (awhen (funcall (car child-obj) obj) ;; access set of child objects
+ (output-ml-class it fmt strm label
english-only-function
(1+ indent) subobjects refvars)))))
(fmt-obj-end obj fmt strm indent)))