chiark / gitweb /
src/c-types-parse.lisp, src/c-types-proto.lisp: Some minor cleanups.
[sod] / src / builtin.lisp
index c38d92cd4c72b15b0a45c4126f43280744e7fba8..1c14f198570dd530521366c4f873a12ebb548010 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
@@ -61,7 +61,7 @@ (defmacro define-class-slot
       ',name
       (lambda (,classvar)
        (make-sod-slot ,classvar ,name (c-type ,type)
-                      (make-property-set :lisp-class 'sod-class-slot
+                      (make-property-set :slot-class 'sod-class-slot
                                          :initializer-function
                                          (lambda (,class)
                                            ,init)
@@ -95,7 +95,7 @@ (define-class-slot "imprint" (class stream)
 {
   struct ~A *sod__obj = p;
 
-  ~:{sod__obj->~A.~A._vt = &~A;~:^~%  ~}
+  ~:{sod__obj->~A.~A._vt = &~A.~A;~:^~%  ~}
   return (p);
 }~2%"
            class
@@ -105,7 +105,8 @@ (define-class-slot "imprint" (class stream)
                             (tail (ichain-tail ichain)))
                        (list (sod-class-nickname head)
                              (sod-class-nickname tail)
-                             (vtable-name class head))))
+                             (vtable-name class head)
+                             (sod-class-nickname tail))))
                    (ilayout-ichains ilayout)))))
 
 (define-class-slot "init" (class stream)
@@ -139,19 +140,23 @@ (define-class-slot "init" (class stream)
                               "  struct ~A *sod__obj = ~A__imprint(p);~2%"
                               (ilayout-struct-tag class) class)
                       (setf used t))
-                    (format stream "  ~A.~A =" isl
-                            (sod-slot-name dslot))
+                    (format stream "  {~%    ")
+                    (pprint-c-type (sod-slot-type dslot) stream
+                                   *sod-tmp-val*)
+                    (format stream " =")
                     (ecase (sod-initializer-value-kind init)
                       (:simple (write (sod-initializer-value-form init)
                                       :stream stream
                                       :pretty nil :escape nil)
                                (format stream ";~%"))
-                      (:compound (format stream " (~A) {"
-                                         (sod-slot-type dslot))
+                      (:compound (format stream " {")
                                  (write (sod-initializer-value-form init)
                                         :stream stream
                                         :pretty nil :escape nil)
-                                 (format stream "};~%"))))))))))))
+                                 (format stream "    };~%")))
+                    (format stream "    ~A.~A = ~A;~%  }~%"
+                            isl (sod-slot-name dslot)
+                            *sod-tmp-val*))))))))))
     (unless used
       (format stream "  ~A__imprint(p);~%" class))
     (format stream "~&~:
@@ -312,7 +317,7 @@ (defun make-builtin-module ()
                                                    :case :common)
                               :state nil)))
     (with-module-environment (module)
-      (dolist (name '("va_list" "size_t" "ptrdiff_t"))
+      (dolist (name '("va_list" "size_t" "ptrdiff_t" "wchar_t"))
        (add-to-module module (make-instance 'type-item :name name)))
       (flet ((header-name (name)
               (concatenate 'string "\"" (string-downcase name) ".h\""))
@@ -331,4 +336,7 @@ (defun make-builtin-module ()
       (bootstrap-classes module))
     (setf *builtin-module* module)))
 
+(define-clear-the-decks builtin-module
+  (unless *builtin-module* (make-builtin-module)))
+
 ;;;----- That's all, folks --------------------------------------------------