;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.projectional-editor) ;;;;;; ;;; API (def (generic e) document? (object) (:documentation "Returns TRUE if OBJECT is a document, otherwise returns FALSE. Purely functional.")) (def (generic e) print-document (document &optional stream) (:documentation "Prints the content of DOCUMENT to STREAM. Has side effects on STREAM.")) (def (generic e) make-projection/t->string (content) (:documentation "Returns a new projection object that projects CONTENT to string.")) ;;;;;; ;;; Data structure (def class* document () ((content :type t) (selection :type selection))) ;;;;;; ;;; Construction (def (function e) make-document (content &key selection) (make-instance 'document :content content :selection selection)) ;;;;;; ;;; Construction (def (macro e) document ((&key selection) &body content) `(make-document ,(first content) :selection ,selection)) ;;;;;; ;;; API implementation (def method document? (object) (typep object 'document)) (def method print-document (document &optional (stream *standard-output*)) (princ (content-of (project-document document (make-projection/t->string (content-of document)))) stream) document)