chiark / gitweb /
src/optparse.lisp: Rearrange system-specific stuff.
[sod] / src / module-impl.lisp
index fe6b545785778b0a8d26c1e14d1810cb9df75b9a..206b5e65a688241ffe77275c4e5eb4e960926057 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
@@ -51,8 +51,7 @@ (defmethod finalize-module ((module module))
     ;; exercise the property-set fiddling in `shared-initialize' and we can
     ;; catch unknown-property errors.
     (change-class module class :state t :pset pset)
-    (check-unused-properties pset)
-    module))
+    (check-unused-properties pset)))
 
 ;;;--------------------------------------------------------------------------
 ;;; Module objects.
@@ -87,7 +86,8 @@ (defun build-module
         (with-module-environment ()
           (module-import *builtin-module*)
           (funcall thunk)
-          (finalize-module *module*))
+          (finalize-module *module*)
+          *module*)
       (when (and truename (not (eq (module-state *module*) t)))
        (remhash truename *module-map*)))))
 
@@ -144,11 +144,10 @@ (defmethod module-import ((class sod-class))
 ;;;--------------------------------------------------------------------------
 ;;; 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.
 
@@ -181,7 +180,7 @@ (defun output-c-excursion (stream location thunk)
 
 (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
@@ -197,7 +196,8 @@ (defmethod print-object ((fragment c-fragment) stream)
 (defmethod make-load-form ((fragment c-fragment) &optional environment)
   (make-load-form-saving-slots fragment :environment environment))
 
-(export 'code-fragment-item)
+(export '(code-fragment-item code-fragment code-fragment-reason
+         code-fragment-name code-fragment-constraints))
 (defclass code-fragment-item ()
   ((fragment :initarg :fragment :type c-fragment :reader code-fragment)
    (reason :initarg :reason :type keyword :reader code-fragment-reason)
@@ -207,24 +207,6 @@ (defclass code-fragment-item ()
   (:documentation
    "A plain fragment of C to be dropped in at top-level."))
 
-(defmacro define-fragment ((reason name) &body things)
-  (categorize (thing things)
-      ((constraints (listp thing))
-       (frags (typep thing '(or string c-fragment))))
-    (when (null frags)
-      (error "Missing code fragment"))
-    (when (cdr frags)
-      (error "Multiple code fragments"))
-    `(add-to-module
-      *module*
-      (make-instance 'code-fragment-item
-                    :fragment ',(car frags)
-                    :name ,name
-                    :reason ,reason
-                    :constraints (list ,@(mapcar (lambda (constraint)
-                                                   (cons 'list constraint))
-                                                 constraints))))))
-
 ;;;--------------------------------------------------------------------------
 ;;; File searching.