Update automatically managed build utilities.
[sod] / src / module-impl.lisp
index 9e74b27..08679ce 100644 (file)
 ;;;--------------------------------------------------------------------------
 ;;; Code fragments.
 
-(export 'c-fragment)
+(export '(c-fragment c-fragment-text))
 (defclass c-fragment ()
-  ((location :initarg :location :type file-location
-            :accessor c-fragment-location)
-   (text :initarg :text :type string :accessor c-fragment-text))
+  ((location :initarg :location :type file-location :reader file-location)
+   (text :initarg :text :type string :reader c-fragment-text))
   (:documentation
    "Represents a fragment of C code to be written to an output file.
 
         (line (file-location-line location))
         (filename (file-location-filename location)))
     (cond (line
-          (format stream "~&#line ~D~@[ ~S~]~%" line filename)
+          (when (typep stream 'position-aware-stream)
+            (format stream "~&#line ~D~@[ ~S~]~%" line filename))
           (funcall thunk)
           (when (typep stream 'position-aware-stream)
             (fresh-line stream)
 
 (defmethod print-object ((fragment c-fragment) stream)
   (let ((text (c-fragment-text fragment))
-       (location (c-fragment-location fragment)))
+       (location (file-location fragment)))
     (if *print-escape*
        (print-unreadable-object (fragment stream :type t)
          (when location