;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: views.lisp,v 1.48 2003/05/26 21:43:05 kevin Exp $
+;;;; $Id: views.lisp,v 1.52 2003/06/12 12:02:31 kevin Exp $
;;;;
;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
;;;; *************************************************************************
-(in-package :hyperobject)
-
-(eval-when (:compile-toplevel :execute)
- (declaim (optimize (speed 2) (safety 2) (compilation-speed 0) (debug 2))))
+(in-package #:hyperobject)
(defclass object-view ()
(link-slots :type list :initform nil
:documentation "List of slot names that have hyperlinks"
:accessor link-slots)
- (link-page-name :type (or string null) :initform nil :initarg :link-page-name
- :accessor link-page-name)
+ (link-page-printer :type (or string function symbol null) :initform nil
+ :initarg :link-page-printer
+ :accessor link-page-printer)
(link-href-start :type (or string null) :initform nil :initarg :link-href-start
:accessor link-href-start)
(link-href-end :type (or string null) :initform nil :initarg :link-href-end
:accessor link-href-end)
(link-ampersand :type (or string null) :initform nil :initarg :link-ampersand
:accessor link-ampersand))
- (:default-initargs :link-page-name "disp-func1")
+ (:default-initargs :link-page-printer "disp-func1")
(:documentation "View class for a hyperobject"))
(vector-push-extend 'x print-func) ;; return object
(setf (obj-data-print-code view) `(lambda (x s links)
- (declare (ignorable links))
+ (declare (ignorable s links))
,@(map 'list #'identity print-func)))
(setf (obj-data-printer view)
(compile nil (eval (obj-data-print-code view))))
(with-output-to-string (s)
(write-string (link-href-start view) s)
(write-char #\" s)
- (write-string (make-url (link-page-name view)) s)
- (write-string "?func=" s)
- (write-simple fieldfunc s)
- (write-string (link-ampersand view) s)
- (write-string "key=" s)
- (write-simple fieldvalue s)
- (dolist (var refvars)
- (write-string (link-ampersand view) s)
- (write-simple (car var) s)
- (write-char #\= s)
- (write-simple (cdr var) s))
- (write-char #\" s)))
+ (let ((link-page (link-page-printer view)))
+ (typecase link-page
+ (string
+ (write-string (make-url link-page) s)
+ (write-string "?func=" s)
+ (write-simple fieldfunc s)
+ (write-string (link-ampersand view) s)
+ (write-string "key=" s)
+ (write-simple fieldvalue s)
+ (dolist (var refvars)
+ (write-string (link-ampersand view) s)
+ (write-simple (car var) s)
+ (write-char #\= s)
+ (write-simple (cdr var) s))
+ (write-char #\" s))
+ (null
+ nil)
+ ((or symbol function)
+ (funcall link-page fieldfunc fieldvalue refvars s))))))
(defun make-link-end (obj view fieldname)
(declare (ignore obj fieldname))
(defun view-hyperobject (objs view category strm &optional (indent 0) filter
subobjects refvars)
"Display a single or list of hyperobject-class instances and their subobjects"
- (declare (fixnum indent))
(let-when (objlist (mklist objs))
(let ((nobjs (length objlist))
(*print-pretty* nil)
(when (and subobjects (hyperobject-class-subobjects obj))
(dolist (subobj (hyperobject-class-subobjects obj))
(aif (slot-value obj (name-slot subobj))
- (view-hyperobject it (get-category-view (car (mklist it)) category)
+ (view-hyperobject it
+ (get-category-view (car (mklist it))
+ category)
category strm (1+ indent) filter
subobjects refvars))))
(fmt-obj-end obj view strm indent)))
(defun view (objs &key (stream *standard-output*) category view
filter subobjects refvars file-wrapper)
- "EXPORTED Function: prints hyperobject-class objects. Simplies call to view-hyperobject"
+ "EXPORTED Function: prints hyperobject-class objects. Calls view-hyperobject"
(let-when (objlist (mklist objs))
(when category
(setq view (get-category-view (car objlist) category)))