X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=mop.lisp;h=f7f7ae02ed5d0c287197c21f80ae5ad15f686800;hb=b17d32528de6c74cd273ce32c69f3726c8110119;hp=960195134da2aa579e99cfc055f4be8b70c9d4d3;hpb=cda49a13fa66d935f4d7db644364cc741b9c1c4c;p=hyperobject.git diff --git a/mop.lisp b/mop.lisp index 9601951..f7f7ae0 100644 --- a/mop.lisp +++ b/mop.lisp @@ -11,7 +11,7 @@ ;;;; in Text, HTML, and XML formats. This includes hyperlinking ;;;; capability and sub-objects. ;;;; -;;;; $Id: mop.lisp,v 1.2 2002/11/29 05:05:29 kevin Exp $ +;;;; $Id: mop.lisp,v 1.6 2002/12/05 19:15:02 kevin Exp $ ;;;; ;;;; This file is Copyright (c) 2000-2002 by Kevin M. Rosenberg ;;;; @@ -20,7 +20,7 @@ (in-package :hyperobject) (eval-when (:compile-toplevel :execute) - (declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))) + (declaim (optimize (speed 2) (safety 2) (compilation-speed 0) (debug 2)))) ;; Main class @@ -34,17 +34,22 @@ :documentation "Class description") (version :initarg :version :initform nil :documentation "Version number for class") + (sql-name :initarg :table-name :initform nil :reader sql-name) ;;; The remainder of these fields are calculated one time ;;; in finalize-inheritence. (subobjects :initform nil :documentation "List of fields that contain a list of subobjects objects.") - (references :type list :initform nil :documentation - "List of fields that have references") + (hyperlinks :type list :initform nil :documentation + "List of fields that have hyperlinks") (class-id :type integer :initform nil :documentation "Unique ID for the class") + (create-table-cmd :initform nil :reader create-table-cmd) + (create-index-cmds :initform nil :reader create-index-cmds) + (drop-table-cmd :initform nil :reader drop-table-cmd) + (value-func :initform nil :type function) (xmlvalue-func :initform nil :type function) (fmtstr-text :initform nil :type string) @@ -68,13 +73,13 @@ (print-unreadable-object (obj s :type t :identity t) (format s "~S" (name obj)))) -(defclass reference () +(defclass hyperlink () ((name :type symbol :initform nil :initarg :name :reader name) (lookup :type function :initform nil :initarg :lookup :reader lookup) (link-parameters :type list :initform nil :initarg :link-parameters :reader link-parameters))) -(defmethod print-object ((obj reference) (s stream)) +(defmethod print-object ((obj hyperlink) (s stream)) (print-unreadable-object (obj s :type t :identity t) (format s "~S" (name obj)))) @@ -150,10 +155,11 @@ ((cl hyperobject-class) #+(or allegro lispworks) name dsds) #+allergo (declare (ignore name)) (let* ((dsd (car dsds)) - (ho-type (slot-value dsd 'type))) + (ho-type (slot-value dsd 'type)) + (sql-type (ho-type-to-sql-type ho-type))) (setf (slot-value dsd 'ho-type) ho-type) + (setf (slot-value dsd 'sql-type) sql-type) (setf (slot-value dsd 'type) (ho-type-to-lisp-type ho-type)) - (setf (slot-value dsd 'sql-type) (ho-type-to-sql-type ho-type)) (let ((ia (compute-effective-slot-definition-initargs cl #+lispworks name dsds))) (apply @@ -162,10 +168,10 @@ :sql-type sql-type :print-formatter (slot-value dsd 'print-formatter) :subobject (slot-value dsd 'subobject) - :reference (slot-value dsd 'reference) + :hyperlink (slot-value dsd 'hyperlink) + :hyperlink-parameters (slot-value dsd 'hyperlink-parameters) :description (slot-value dsd 'description) - ia))) - ) + ia)))) (defun ho-type-to-lisp-type (ho-type) (check-type ho-type symbol) @@ -193,7 +199,7 @@ (:string 'string) (:fixnum - 'fixnum) + 'integer) (:boolean 'boolean) (:integer @@ -207,9 +213,10 @@ (otherwise ho-type))) + ;;;; Class initialization function -(defun process-subobjects (cl) +(defun finalize-subobjects (cl) "Process class subobjects slot" (setf (slot-value cl 'subobjects) (let ((subobjects '())) @@ -222,13 +229,19 @@ subobjects))) subobjects))) -(defun process-documentation (cl) +(defun finalize-documentation (cl) "Calculate class documentation slot" (awhen (slot-value cl 'title) - (setf (slot-value cl 'title) (car it))) + (setf (slot-value cl 'title) + (etypecase (slot-value cl 'title) + (cons (car it)) + ((or string symbol) it)))) (awhen (slot-value cl 'description) - (setf (slot-value cl 'description) (car it))) - + (setf (slot-value cl 'description) + (etypecase (slot-value cl 'description) + (cons (car it)) + ((or string symbol) it)))) + (let ((*print-circle* nil)) (setf (documentation (class-name cl) 'class) (format nil "Hyperobject~A~A~A~A" @@ -244,9 +257,11 @@ (defun init-hyperobject-class (cl) "Initialize a hyperobject class. Calculates all class slots" - (process-subobjects cl) - (process-views cl) - (process-documentation cl)) + (finalize-subobjects cl) + (finalize-views cl) + (finalize-hyperlinks cl) + (finalize-sql cl) + (finalize-documentation cl)) ;;;; ************************************************************************* @@ -291,12 +306,15 @@ (defun hyperobject-class-subobjects (obj) (slot-value (class-of obj) 'subobjects)) -(defun hyperobject-class-references (obj) - (slot-value (class-of obj) 'references)) +(defun hyperobject-class-hyperlinks (obj) + (slot-value (class-of obj) 'hyperlinks)) (defun hyperobject-class-fields (obj) (class-slots (class-of obj))) +(defun hyperobject-class-print-slots (obj) + (slot-value (class-of obj) 'print-slots)) + (defun hyperobject-class-fmtstr-html-ref (obj) (slot-value (class-of obj) 'fmtstr-html-ref))