projects
/
kmrcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r3035: *** empty log message ***
[kmrcl.git]
/
ml-class.lisp
diff --git
a/ml-class.lisp
b/ml-class.lisp
index 567a327afbf64ba10e3a3e3e2ad74d458ef14f9f..949190b71bdf1e99208a56dcc2cfba3ea8d4c25c 100644
(file)
--- 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.
;;;;
;;;; in Text, HTML, and XML formats. This includes hyperlinking
;;;; capability and sub-objects.
;;;;
-;;;; $Id: ml-class.lisp,v 1.
5 2002/10/11 23:51:33
kevin Exp $
+;;;; $Id: ml-class.lisp,v 1.
12 2002/10/14 20:55:12
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
;;;;
@@
-24,8
+24,19
@@
(declaim (optimize (speed 3) (safety 1)))
(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)
+(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")
((title :initarg :title :type string :reader ml-std-title
:documentation
"Print Title for class")
@@
-61,6
+72,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."))
(: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))
#+allegro
(defmethod mop:finalize-inheritance :after ((cl ml-class))
@@
-70,9
+98,15
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(defmethod clos:finalize-inheritance :after ((cl ml-class))
(init-ml-class cl))
(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)
#+lispworks
(defmethod clos:process-a-class-option ((class ml-class)
@@
-125,6
+159,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(value-func '())
(xmlvalue-func '())
(classname (class-name cl))
(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))
(ref-fields (slot-value cl 'ref-fields)))
(declare (ignore classname))
(dolist (f (slot-value cl 'fields))
@@
-186,11
+221,9
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(if formatter
(setq plain-value-func
(if formatter
(setq plain-value-func
- (list `(,formatter (,(concat-symbol-pkg
- :umlisp namestr) x))))
+ (list `(,formatter (,(intern namestr package) x))))
(setq plain-value-func
(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 value-func (append value-func plain-value-func))
(if (eql type :cdata)
@@
-198,9
+231,14
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(setq xmlvalue-func (append xmlvalue-func 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 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)
(setq xmlvalue-func (compile nil (eval xmlvalue-func)))
(setf (slot-value cl 'fmtstr-text) fmtstr-text)
@@
-219,64
+257,65
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(defun ml-class-fmtstr-text (obj)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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
;;; Class name functions
+(defgeneric ml-class-stdname (x))
(defmethod ml-class-stdname ((name string))
(defmethod ml-class-stdname ((name string))
- (string-downcase (subseq name
:start
1)))
+ (string-downcase (subseq name 1)))
(defmethod ml-class-stdname ((cl standard-object))
(defmethod ml-class-stdname ((cl standard-object))
- (string-downcase (subseq (
class-name (class-of cl)) :start
1)))
+ (string-downcase (subseq (
ml-class-name (ml-class-of cl))
1)))
;;;; Generic Print functions
;;;; Generic Print functions
@@
-381,13
+420,13
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(defun class-name-of (obj)
(defun class-name-of (obj)
- (string-downcase (
class-name (
class-of obj))))
+ (string-downcase (
ml-class-name (ml-
class-of obj))))
(defun xmlformat-list-end-value-func (x)
(defun xmlformat-list-end-value-func (x)
- (format nil "~alist" (string-downcase (
class-name (
class-of x)))))
+ (format nil "~alist" (string-downcase (
ml-class-name (ml-
class-of x)))))
(defun xmlformat-list-start-value-func (x nitems)
(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 (
ml-class-name (ml-
class-of x)))) (ml-class-title x) nitems))
(defclass xmlformat (textformat)
()
(defclass xmlformat (textformat)
()
@@
-450,18
+489,21
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
;;; File Start and Ends
;;; File Start and Ends
+(defgeneric fmt-file-start (fmt s))
(defmethod fmt-file-start ((fmt dataformat) (s stream)))
(defmethod fmt-file-start ((fmt textformat) (s stream))
(aif (file-start-str fmt)
(format s it)))
(defmethod fmt-file-start ((fmt dataformat) (s stream)))
(defmethod fmt-file-start ((fmt textformat) (s stream))
(aif (file-start-str fmt)
(format s it)))
+(defgeneric fmt-file-end (fmt s))
(defmethod fmt-file-end ((fmt textformat) (s stream))
(aif (file-end-str fmt)
(format s it)))
;;; List Start and Ends
(defmethod fmt-file-end ((fmt textformat) (s stream))
(aif (file-end-str fmt)
(format s it)))
;;; List Start and Ends
+(defgeneric fmt-list-start (obj fmt s &optional indent num-items))
(defmethod fmt-list-start (x (fmt textformat) (s stream) &optional (indent 0) (num-items 1))
(if (list-start-indent fmt)
(indent-spaces indent s))
(defmethod fmt-list-start (x (fmt textformat) (s stream) &optional (indent 0) (num-items 1))
(if (list-start-indent fmt)
(indent-spaces indent s))
@@
-470,6
+512,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(multiple-value-list
(funcall (list-start-value-func fmt) x num-items)))))
(multiple-value-list
(funcall (list-start-value-func fmt) x num-items)))))
+(defgeneric fmt-list-end (obj fmt s &optional indent 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)
(defmethod fmt-list-end (x (fmt textformat) (s stream) &optional (indent 0) (num-items 1))
(declare (ignore num-items))
(if (list-end-indent fmt)
@@
-481,6
+524,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
;;; Object Start and Ends
;;; Object Start and Ends
+(defgeneric fmt-obj-start (obj fmt s &optional indent))
(defmethod fmt-obj-start (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-start-indent fmt)
(indent-spaces indent s))
(defmethod fmt-obj-start (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-start-indent fmt)
(indent-spaces indent s))
@@
-489,6
+533,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(multiple-value-list
(funcall (obj-start-value-func fmt) x)))))
(multiple-value-list
(funcall (obj-start-value-func fmt) x)))))
+(defgeneric fmt-obj-end (obj fmt s &optional indent))
(defmethod fmt-obj-end (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-end-indent fmt)
(indent-spaces indent s))
(defmethod fmt-obj-end (x (fmt textformat) (s stream) &optional (indent 0))
(if (obj-end-indent fmt)
(indent-spaces indent s))
@@
-499,6
+544,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
;;; Object Data
;;; Object Data
+(defgeneric make-link-start (obj ref fieldname fieldfunc fieldvalue refvars))
(defmethod make-link-start (obj (ref link-ref) fieldname fieldfunc fieldvalue refvars)
(declare (ignore obj fieldname))
(format nil "~a\"~a?func=~a~akey=~a~a\""
(defmethod make-link-start (obj (ref link-ref) fieldname fieldfunc fieldvalue refvars)
(declare (ignore obj fieldname))
(format nil "~a\"~a?func=~a~akey=~a~a\""
@@
-512,11
+558,13
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
varstr)
"")))
varstr)
"")))
+(defgeneric make-link-end (obj ref fieldname))
(defmethod make-link-end (obj (ref link-ref) fieldname)
(declare (ignore obj fieldname))
(format nil "~a" (href-end ref))
)
(defmethod make-link-end (obj (ref link-ref) fieldname)
(declare (ignore obj fieldname))
(format nil "~a" (href-end ref))
)
+(defgeneric fmt-obj-data (obj fmt s &optional indent label refvars))
(defmethod fmt-obj-data (x (fmt textformat) s
&optional (indent 0) (label nil) (refvars nil))
(if (obj-data-indent fmt)
(defmethod fmt-obj-data (x (fmt textformat) s
&optional (indent 0) (label nil) (refvars nil))
(if (obj-data-indent fmt)
@@
-527,6
+575,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(aif (obj-data-end-fmtstr fmt)
(format s it)))
(aif (obj-data-end-fmtstr fmt)
(format s it)))
+(defgeneric fmt-obj-data-plain (obj fmt s label))
(defmethod fmt-obj-data-plain (x (fmt textformat) s label)
(if label
(apply #'format s
(defmethod fmt-obj-data-plain (x (fmt textformat) s label)
(if label
(apply #'format s
@@
-537,6
+586,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(multiple-value-list
(funcall (funcall (obj-data-value-func fmt) x) x)))))
(multiple-value-list
(funcall (funcall (obj-data-value-func fmt) x) x)))))
+(defgeneric fmt-obj-data-with-ref (obj fmt s label refvars))
(defmethod fmt-obj-data-with-ref (x (fmt textformat) s label refvars)
(let ((refstr (make-ref-data-str x fmt label))
(refvalues nil)
(defmethod fmt-obj-data-with-ref (x (fmt textformat) s label refvars)
(let ((refstr (make-ref-data-str x fmt label))
(refvalues nil)
@@
-556,7
+606,8
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(setq refvalues (nreverse refvalues))
(apply #'format s refstr refvalues)))
(setq refvalues (nreverse refvalues))
(apply #'format s refstr refvalues)))
-
+
+(defgeneric obj-data (obj))
(defmethod obj-data (x)
"Returns the objects data as a string. Used by common-graphics outline function"
(let ((fmt (make-format-instance :text)))
(defmethod obj-data (x)
"Returns the objects data as a string. Used by common-graphics outline function"
(let ((fmt (make-format-instance :text)))
@@
-564,6
+615,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(multiple-value-list
(funcall (funcall (obj-data-value-func fmt) x) x)))))
(multiple-value-list
(funcall (funcall (obj-data-value-func fmt) x) x)))))
+(defgeneric make-ref-data-str (obj fmt &optional label))
(defmethod make-ref-data-str (x (fmt textformat) &optional (label nil))
"Return fmt string for that contains ~a slots for reference link start and end"
(unless (link-ref fmt)
(defmethod make-ref-data-str (x (fmt textformat) &optional (label nil))
"Return fmt string for that contains ~a slots for reference link start and end"
(unless (link-ref fmt)
@@
-580,6
+632,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
;;; Display method for objects
;;; Display method for objects
+(defgeneric load-all-subobjects (objs))
(defmethod load-all-subobjects (objs)
"Load all subobjects if they have not already been loaded."
(when objs
(defmethod load-all-subobjects (objs)
"Load all subobjects if they have not already been loaded."
(when objs
@@
-591,6
+644,7
@@
Format is ((field-name field-lookup-func other-link-params) ...)")
(load-all-subobjects it))))))
objs))
(load-all-subobjects it))))))
objs))
+(defgeneric output-ml-class (objs fmt strm &optional label english-only-function indent subobjects refvars))
(defmethod output-ml-class (objs (fmt dataformat) (strm stream)
&optional (label nil) (english-only-function nil)
(indent 0) (subobjects nil) (refvars nil))
(defmethod output-ml-class (objs (fmt dataformat) (strm stream)
&optional (label nil) (english-only-function nil)
(indent 0) (subobjects nil) (refvars nil))