Index: /trunk/ccl/examples/objc-runtime.lisp
===================================================================
--- /trunk/ccl/examples/objc-runtime.lisp	(revision 487)
+++ /trunk/ccl/examples/objc-runtime.lisp	(revision 488)
@@ -337,4 +337,16 @@
 )
 
+(defun get-appkit-version ()
+  (%get-double-float (foreign-symbol-address #+apple-objc "_NSAppKitVersionNumber" #+gnu-objc "NSAppKitVersionNumber")))
+
+(defun get-foundation-version ()
+  (%get-double-float (foreign-symbol-address #+apple-objc "_NSFoundationVersionNumber" #+gnu-objc "NSFoundationVersionNumber")))
+
+(defparameter *appkit-library-version-number* (get-appkit-version))
+(defparameter *foundation-library-version-number* (get-foundation-version))
+
+(def-ccl-pointers cfstring-sections ()
+  (reset-cfstring-sections)
+  (find-cfstring-sections))
 
 ;;; When starting up an image that's had ObjC classes in it, all of
@@ -354,4 +366,12 @@
   ;; resolving those foreign classes that existed in the old
   ;; image and still exist in the new.
+  (unless (= *foundation-library-version-number* (get-foundation-version))
+    (format *error-output* "~&Foundation version mismatch: expected ~s, got ~s~&"
+	    *Foundation-library-version-number* (get-foundation-version))
+    (#_exit 1))
+  (unless (= *appkit-library-version-number* (get-appkit-version))
+    (format *error-output* "~&AppKit version mismatch: expected ~s, got ~s~&"
+	    *appkit-library-version-number* (get-appkit-version))
+    (#_exit 1))
   (let* ((class-map (objc-class-map))
 	 (metaclass-map (objc-metaclass-map))
@@ -374,7 +394,8 @@
 				      #+gnu-objc :objc_class.class_pointer)))
 	      (splay-tree-put metaclass-map m meta-id))))))
-    (break "second pass")
     ;; Second pass: install class objects for user-defined classes,
-    ;; assuming the superclasses are already "revived".
+    ;; assuming the superclasses are already "revived".  If the
+    ;; superclass is itself user-defined, it'll appear first in the
+    ;; class table; that's an artifact of the current implementation.
     (dotimes (i nclasses)
       (let* ((c (id->objc-class i)))
@@ -386,14 +407,15 @@
 		 (meta-id (objc-class-id->objc-metaclass-id i))
 		 (m (id->objc-metaclass meta-id)))
-	    (when (%null-ptr-p m)
+	    (unless (splay-tree-get metaclass-map m)
+	      (%revive-macptr m)
 	      (%setf-macptr m (%make-basic-meta-class
-			       (objc-metaclass-id-foreign-name meta-id)
+			       (make-cstring (objc-metaclass-id-foreign-name meta-id))
 			       super
-			       (@class "NSObject")))
+			       (find-class 'ns::ns-object)))
 	      (splay-tree-put metaclass-map m meta-id))
 	    (%setf-macptr c (%make-class-object
 			     m
 			     super
-			     (objc-class-id-foreign-name i)
+			     (make-cstring (objc-class-id-foreign-name i))
 			     (%null-ptr)
 			     0))
@@ -402,6 +424,8 @@
 	      (%add-objc-class c ivars instance-size)
 	      (splay-tree-put class-map c i))))))))
-      
-      
+
+(pushnew #'revive-objc-classes *lisp-system-pointer-functions*
+	 :test #'eq
+	 :key #'function-name)
     
     
@@ -1297,5 +1321,9 @@
      imp)))
 
-
+(def-ccl-pointers add-objc-methods ()
+  (maphash #'(lambda (impname m)
+	       (declare (ignore impname))
+	       (%add-lisp-objc-method m))
+	   *lisp-objc-methods*))
 
 (defun %define-lisp-objc-method (impname classname selname typestring imp
@@ -1516,5 +1544,4 @@
   (setf (%get-ptr (foreign-symbol-address "__dealloc")) *original-deallocate-hook*))
 
-#+testing
 (pushnew #'uninstall-lisp-deallocate-hook *lisp-cleanup-functions* :test #'eq
          :key #'function-name)
