X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/d437292a11e89c11c839145237a1871316593800..8eb242b160e163a1cfc6e810aeda4788116bba1a:/src/module-output.lisp diff --git a/src/module-output.lisp b/src/module-output.lisp index 8632a02..c3c61d6 100644 --- a/src/module-output.lisp +++ b/src/module-output.lisp @@ -7,7 +7,7 @@ ;;;----- Licensing notice --------------------------------------------------- ;;; -;;; This file is part of the Sensble Object Design, an object system for C. +;;; This file is part of the Sensible Object Design, an object system for C. ;;; ;;; SOD is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by @@ -65,6 +65,20 @@ (merge-pathnames (make-pathname :type type :case :common) (module-name module))) +(defvar *done-one-off-output* nil + "A list of tokens for things which should appear at most once in output.") + +(export 'one-off-output) +(defun one-off-output (token sequencer item-name function) + "Arrange to output a thing at most once. + + If there has been no previous call to `one-off-output' with the given + TOKEN during this output run, then arrange to call FUNCTION when the item + called ITEM-NAME is traversed. Otherwise do nothing." + (unless (member token *done-one-off-output*) + (push token *done-one-off-output*) + (add-sequencer-item-function sequencer item-name function))) + ;;;-------------------------------------------------------------------------- ;;; Main output interface. @@ -73,7 +87,9 @@ "Write the MODULE to STREAM, giving the output machinery the REASON. This is the top-level interface for producing output." - (let ((sequencer (make-instance 'sequencer)) + (let ((*print-right-margin* 77) + (*done-one-off-output* nil) + (sequencer (make-instance 'sequencer)) (stream (if (typep stream 'position-aware-output-stream) stream (make-instance 'position-aware-output-stream @@ -112,7 +128,7 @@ (:prologue (:guard :start) (:typedefs :start) :typedefs (:typedefs :end) - (:includes :start) :includes (:includes :end) + (:includes :start) :includes :early-decls (:includes :end) (:early-user :start) :early-user (:early-user :end) (:classes :start) (:classes :end) (:user :start) :user (:user :end)