;;;----- 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
(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.
"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 ((*done-one-off-output* nil)
+ (sequencer (make-instance 'sequencer))
(stream (if (typep stream 'position-aware-output-stream)
stream
(make-instance 'position-aware-output-stream
(: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)