chiark / gitweb /
doc/concepts.tex: Typeset method rĂ´le names as identifiers.
[sod] / src / c-types-class-impl.lisp
index de980d82ff151ea67ed560aac9c9b7cc30d95d77..2908d754a5b2f48c687640203460d3b336bba94f 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
@@ -30,8 +30,8 @@ (cl:in-package #:sod)
 
 (export '(c-class-type c-type-class))
 (defclass c-class-type (simple-c-type)
-  ((class :initarg :class :initform nil
-         :type (or null sod-class) :accessor c-type-class)
+  ((%class :initarg :class :initform nil
+          :type (or null sod-class) :accessor c-type-class)
    (tag :initarg :tag))
   (:documentation
    "A SOD class, as a C type.
@@ -45,7 +45,7 @@ (defclass c-class-type (simple-c-type)
    The CLASS slot will be NIL if the class isn't defined yet, i.e., this
    entry was constructed by a forward reference operation.
 
-   The NAME slot inherited from SIMPLE-C-TYPE is here so that we can print
+   The NAME slot inherited from `simple-c-type' is here so that we can print
    the type even when it's a forward reference."))
 
 ;; Constructor function and interning.
@@ -57,18 +57,18 @@ (define-module-var *module-type-map* (make-hash-table :test #'equal)
 
 (export 'find-class-type)
 (defun find-class-type (name)
-  "Look up NAME and return the corresponding C-CLASS-TYPE.
+  "Look up NAME and return the corresponding `c-class-type'.
 
      * If the type was found, and was a class, returns TYPE.
 
-     * If no type was found at all, returns NIL.
+     * If no type was found at all, returns `nil'.
 
      * If a type was found, but it wasn't a class, signals an error."
 
   (atypecase (gethash name *module-type-map*)
     (null nil)
     (c-class-type it)
-    (t (error "Type `~A' (~A) is not a class" name it))))
+    (t (error "Type `~A' is not a class" name))))
 
 (export 'make-class-type)
 (defun make-class-type (name &optional qualifiers)
@@ -91,6 +91,7 @@ (defun make-class-type (name &optional qualifiers)
           (values it (slot-value it 'tag))
           (let* ((tag (gensym "TAG-"))
                  (type (intern-c-type 'c-class-type :name name :tag tag)))
+            (setf (gethash name *module-type-map*) type)
             (values type tag)))
 
     ;; If no qualifiers are wanted then we've already found or created the
@@ -126,10 +127,14 @@ (define-c-type-syntax class (name &rest quals)
 
 (export 'find-sod-class)
 (defun find-sod-class (name)
-  "Return the SOD-CLASS object with the given NAME."
-  (aif (find-class-type name)
-       (or (c-type-class it) (error "Class `~A' is incomplete" name))
-       (error "Type `~A' not known" name)))
+  "Return the `sod-class' object with the given NAME."
+  (acond ((find-class-type name)
+         (or (c-type-class it)
+             (error "Class `~A' is incomplete" name)))
+        ((find-simple-c-type name)
+         (error "Type `~A' is not a class" name))
+        (t
+         (error "Type `~A' not known" name))))
 
 (export 'record-sod-class)
 (defun record-sod-class (class)