X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=views.lisp;h=e5ada414699923f2dae9459700cbbd995a01ce3a;hb=86acb3681c00ae3c64cdb1f1d4296e136ed55cd4;hp=0aeafe1bda4b2401a7d617dcea6c321a66bb246d;hpb=d6af219e32386c64ef95b8ff0dd8900ea92371fc;p=hyperobject.git diff --git a/views.lisp b/views.lisp index 0aeafe1..e5ada41 100644 --- a/views.lisp +++ b/views.lisp @@ -7,15 +7,12 @@ ;;;; 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 () @@ -72,15 +69,16 @@ (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")) @@ -331,7 +329,7 @@ (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)))) @@ -518,18 +516,25 @@ (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)) @@ -577,7 +582,6 @@ (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) @@ -594,7 +598,9 @@ (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))) @@ -604,7 +610,7 @@ (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)))