chiark / gitweb /
src/method-impl.lisp (method-keyword-argument-lists): Check message type.
[sod] / src / module-output.lisp
index f61eb929b51af1098e08c125363efbfd3ad20005..c3c61d6c534fb4786707e1626d6e735b110f796f 100644 (file)
@@ -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 @@ (defun guess-output-file (module type)
   (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 @@ (defun output-module (module reason stream)
   "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,8 +128,10 @@ (defmethod hook-output progn ((module module) (reason (eql :h)) sequencer)
     (:prologue
      (:guard :start)
      (:typedefs :start) :typedefs (:typedefs :end)
-     (:includes :start) :includes (:includes :end)
-     (:classes :start) :classes (:classes :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)
      (:guard :end)
      :epilogue)
 
@@ -161,7 +179,9 @@ (defmethod hook-output progn ((module module) (reason (eql :c)) sequencer)
     :constraint
     (:prologue
      (:includes :start) :includes (:includes :end)
+     (:early-user :start) :early-user (:early-user :end)
      (:classes :start) (:classes :end)
+     (:user :start) :user (:user :end)
      :epilogue)
 
     (:prologue