Changeset 488


Ignore:
Timestamp:
Feb 7, 2004, 1:54:58 PM (21 years ago)
Author:
Gary Byers
Message:

Revive objc-classes/methods when restarting an image.
Check appkit/foundation versions, print a message & exit if mismatch.
Find cfstring-containing library sections after loading appkit/foundation,
and again on image startup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/objc-runtime.lisp

    r486 r488  
    337337)
    338338
     339(defun get-appkit-version ()
     340  (%get-double-float (foreign-symbol-address #+apple-objc "_NSAppKitVersionNumber" #+gnu-objc "NSAppKitVersionNumber")))
     341
     342(defun get-foundation-version ()
     343  (%get-double-float (foreign-symbol-address #+apple-objc "_NSFoundationVersionNumber" #+gnu-objc "NSFoundationVersionNumber")))
     344
     345(defparameter *appkit-library-version-number* (get-appkit-version))
     346(defparameter *foundation-library-version-number* (get-foundation-version))
     347
     348(def-ccl-pointers cfstring-sections ()
     349  (reset-cfstring-sections)
     350  (find-cfstring-sections))
    339351
    340352;;; When starting up an image that's had ObjC classes in it, all of
     
    354366  ;; resolving those foreign classes that existed in the old
    355367  ;; image and still exist in the new.
     368  (unless (= *foundation-library-version-number* (get-foundation-version))
     369    (format *error-output* "~&Foundation version mismatch: expected ~s, got ~s~&"
     370            *Foundation-library-version-number* (get-foundation-version))
     371    (#_exit 1))
     372  (unless (= *appkit-library-version-number* (get-appkit-version))
     373    (format *error-output* "~&AppKit version mismatch: expected ~s, got ~s~&"
     374            *appkit-library-version-number* (get-appkit-version))
     375    (#_exit 1))
    356376  (let* ((class-map (objc-class-map))
    357377         (metaclass-map (objc-metaclass-map))
     
    374394                                      #+gnu-objc :objc_class.class_pointer)))
    375395              (splay-tree-put metaclass-map m meta-id))))))
    376     (break "second pass")
    377396    ;; Second pass: install class objects for user-defined classes,
    378     ;; assuming the superclasses are already "revived".
     397    ;; assuming the superclasses are already "revived".  If the
     398    ;; superclass is itself user-defined, it'll appear first in the
     399    ;; class table; that's an artifact of the current implementation.
    379400    (dotimes (i nclasses)
    380401      (let* ((c (id->objc-class i)))
     
    386407                 (meta-id (objc-class-id->objc-metaclass-id i))
    387408                 (m (id->objc-metaclass meta-id)))
    388             (when (%null-ptr-p m)
     409            (unless (splay-tree-get metaclass-map m)
     410              (%revive-macptr m)
    389411              (%setf-macptr m (%make-basic-meta-class
    390                                (objc-metaclass-id-foreign-name meta-id)
     412                               (make-cstring (objc-metaclass-id-foreign-name meta-id))
    391413                               super
    392                                (@class "NSObject")))
     414                               (find-class 'ns::ns-object)))
    393415              (splay-tree-put metaclass-map m meta-id))
    394416            (%setf-macptr c (%make-class-object
    395417                             m
    396418                             super
    397                              (objc-class-id-foreign-name i)
     419                             (make-cstring (objc-class-id-foreign-name i))
    398420                             (%null-ptr)
    399421                             0))
     
    402424              (%add-objc-class c ivars instance-size)
    403425              (splay-tree-put class-map c i))))))))
    404      
    405      
     426
     427(pushnew #'revive-objc-classes *lisp-system-pointer-functions*
     428         :test #'eq
     429         :key #'function-name)
    406430   
    407431   
     
    12971321     imp)))
    12981322
    1299 
     1323(def-ccl-pointers add-objc-methods ()
     1324  (maphash #'(lambda (impname m)
     1325               (declare (ignore impname))
     1326               (%add-lisp-objc-method m))
     1327           *lisp-objc-methods*))
    13001328
    13011329(defun %define-lisp-objc-method (impname classname selname typestring imp
     
    15161544  (setf (%get-ptr (foreign-symbol-address "__dealloc")) *original-deallocate-hook*))
    15171545
    1518 #+testing
    15191546(pushnew #'uninstall-lisp-deallocate-hook *lisp-cleanup-functions* :test #'eq
    15201547         :key #'function-name)
Note: See TracChangeset for help on using the changeset viewer.