X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;ds=inline;f=ml-class.lisp;h=b720de00351cd7d5dcb936a8c10d47c8529a00a8;hb=4a7372ef4000eaaa86a987bc9668ccecf7d0489f;hp=84845b6d573e77cac0d58691280ec097b689ceb0;hpb=a021c083c78592e9e8135418821b7f32daa04f79;p=kmrcl.git diff --git a/ml-class.lisp b/ml-class.lisp index 84845b6..b720de0 100644 --- a/ml-class.lisp +++ b/ml-class.lisp @@ -11,7 +11,7 @@ ;;;; in Text, HTML, and XML formats. This includes hyperlinking ;;;; capability and sub-objects. ;;;; -;;;; $Id: ml-class.lisp,v 1.7 2002/10/13 23:08:40 kevin Exp $ +;;;; $Id: ml-class.lisp,v 1.17 2002/10/16 21:58:49 kevin Exp $ ;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -29,7 +29,14 @@ #+sbcl (sb-pcl:class-of obj) #+cmu (pcl:class-of obj)) -(defclass ml-class (standard-class) +(defun ml-class-name (obj) + #-(or cmu sbcl) (class-name obj) + #+sbcl (sb-pcl:class-name obj) + #+cmu (pcl:class-name obj)) + +(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") @@ -66,19 +73,21 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (:documentation "Metaclass for Markup Language classes.")) #+cmu -(defmethod pcl:validate-superclass ((class ml-class) (superclass pcl::standard-class)) - t) +(defmethod pcl:finalize-inheritance :after ((cl ml-class)) + (init-ml-class cl)) + #+sbcl -(defmethod sb-pcl:validate-superclass ((class ml-class) (superclass sb-pcl::standard-class)) - t) +(defmethod sb-pcl:finalize-inheritance :after ((cl ml-class)) + (init-ml-class cl)) + #+cmu -(defmethod pcl:validate-superclass ((class pcl::standard-class) (superclass ml-class)) +(defmethod pcl:validate-superclass ((class ml-class) (superclass pcl::standard-class)) t) #+sbcl -(defmethod sb-pcl:validate-superclass ((class sb-pcl::standard-class) (superclass ml-class)) +(defmethod sb-pcl:validate-superclass ((class ml-class) (superclass sb-pcl::standard-class)) t) #+allegro @@ -89,19 +98,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::class-finalized-p ((cl ml-class)) - (with-slots (wrapper fmtstr-text) cl - (and (not (null wrapper)) - (not (null fmtstr-text))))) - -#+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:finalize-inheritance :after ((cl ml-class)) - (init-ml-class cl)) +;;#+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) @@ -154,6 +159,7 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (value-func '()) (xmlvalue-func '()) (classname (class-name cl)) + (package (symbol-package (ml-class-name cl))) (ref-fields (slot-value cl 'ref-fields))) (declare (ignore classname)) (dolist (f (slot-value cl 'fields)) @@ -189,9 +195,9 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (string-append fmtstr-html-ref-labels " ") (string-append fmtstr-xml-ref-labels " "))) - (setq html-str value-fmt) + (setq html-str (concatenate 'string "" value-fmt "")) (setq xml-str (concatenate 'string "<" namestr-lower ">" value-fmt "" namestr-lower ">")) - (setq html-label-str (concatenate 'string "" namestr-lower " " value-fmt)) + (setq html-label-str (concatenate 'string "" namestr-lower " " value-fmt "")) (setq xml-label-str (concatenate 'string " <" namestr-lower ">" value-fmt "" namestr-lower ">")) (string-append fmtstr-text value-fmt) @@ -205,7 +211,7 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (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 "" namestr-lower " <~~a>" value-fmt "~~a>") + (string-append fmtstr-html-ref-labels "" namestr-lower " <~~a>" value-fmt "~~a>") (string-append fmtstr-xml-ref-labels " <~~a>" value-fmt "~~a>")) (progn (string-append fmtstr-html-ref html-str) @@ -215,21 +221,24 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (if formatter (setq plain-value-func - (list `(,formatter (,(concat-symbol-pkg - :umlisp namestr) x)))) + (list `(,formatter (,(intern namestr package) x)))) (setq plain-value-func - (list `(,(concat-symbol-pkg - :umlisp namestr) x)))) + (list `(,(intern namestr package) x)))) (setq value-func (append value-func plain-value-func)) (if (eql type :cdata) (setq xmlvalue-func (append xmlvalue-func (list `(xml-cdata ,@plain-value-func)))) (setq xmlvalue-func (append xmlvalue-func plain-value-func))) )) - - (setq value-func `(lambda (x) (values ,@value-func))) + + (if value-func + (setq value-func `(lambda (x) (values ,@value-func))) + (setq value-func `(lambda () (values)))) (setq value-func (compile nil (eval value-func))) - (setq xmlvalue-func `(lambda (x) (values ,@xmlvalue-func))) + + (if xmlvalue-func + (setq xmlvalue-func `(lambda (x) (values ,@xmlvalue-func))) + (setq xmlvalue-func `(lambda () (values)))) (setq xmlvalue-func (compile nil (eval xmlvalue-func))) (setf (slot-value cl 'fmtstr-text) fmtstr-text) @@ -301,11 +310,12 @@ Format is ((field-name field-lookup-func other-link-params) ...)") ;;; Class name functions +(defgeneric ml-class-stdname (x)) (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 (ml-class-of cl)) :start 1))) + (string-downcase (subseq (ml-class-name (ml-class-of cl)) 1))) ;;;; Generic Print functions @@ -314,6 +324,7 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (defparameter *default-htmlrefformat* nil) (defparameter *default-xmlformat* nil) (defparameter *default-xmlrefformat* nil) +(defparameter *default-ie-xmlrefformat* nil) (defparameter *default-nullformat* nil) (defparameter *default-init-format?* nil) @@ -324,6 +335,7 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (setq *default-htmlrefformat* (make-instance 'htmlrefformat)) (setq *default-xmlformat* (make-instance 'xmlformat)) (setq *default-xmlrefformat* (make-instance 'xmlrefformat)) + (setq *default-ie-xmlrefformat* (make-instance 'ie-xmlrefformat)) (setq *default-nullformat* (make-instance 'nullformat)) (setq *default-init-format?* t)) @@ -332,7 +344,9 @@ Format is ((field-name field-lookup-func other-link-params) ...)") (:html *default-htmlformat*) (:htmlref *default-htmlrefformat*) (:xml *default-xmlformat*) + (:xml *default-xmlformat*) (:xmlref *default-xmlrefformat*) + (:ie-xmlref *default-ie-xmlrefformat*) (:null *default-nullformat*) (otherwise *default-textformat*))) @@ -387,14 +401,21 @@ Format is ((field-name field-lookup-func other-link-params) ...)") :obj-data-end-fmtstr "~%" :obj-data-value-func #'ml-class-value-func)) + +(defun class-name-of (obj) + (string-downcase (ml-class-name (ml-class-of obj)))) + +(defun htmlformat-list-start-value-func (x nitems) + (values (ml-class-title x) nitems (class-name-of x))) + (defclass htmlformat (textformat) () (:default-initargs :file-start-str "
~%" :file-end-str "~%" :list-start-indent t - :list-start-fmtstr "~a~P:
~a~p: