Changeset 14203


Ignore:
Timestamp:
Aug 21, 2010, 10:40:40 AM (9 years ago)
Author:
gb
Message:

Don't canonicalize objc instances. (That was once intended to help
with retain/release, but it wasn't viable.)

Don't try to override -[NSObject dealloc]; that indeed seemed to
cause problems with (lisp and foreign) thread termination.

Define and export OBJC:REMOVE-LISP-SLOTS. Ensure that ObjC classes
that introduce lisp slots have an automatically generated #/dealloc
method that removes lisp slot vectors from the hash table that
maintains them. (Classes can and sometimes should override this
method; user-defined #/dealloc methods should call OBJC:REMOVE-LISP-SLOTS
as well as calling the next method, after doing other class-specific
cleanup.

Location:
trunk/source/objc-bridge
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/objc-bridge/objc-package.lisp

    r13067 r14203  
    4545           "OBJC-MESSAGE-SEND-SUPER" "OBJC-MESSAGE-SEND-SUPER-STRET"
    4646           "LOAD-FRAMEWORK" "*OBJC-DESCRIPTION-MAX-LENGTH*"
     47           "REMOVE-LISP-SLOTS"
    4748           ))
    4849
  • trunk/source/objc-bridge/objc-runtime.lisp

    r14198 r14203  
    24702470    (#___objc_exec_class m)))
    24712471
     2472
    24722473#+(or apple-objc-2.0 cocotron-objc)
    24732474(defun %add-objc-class (class)
     
    27532754
    27542755
     2756
     2757
     2758
     2759                                 
     2760                   
     2761                               
    27552762
    27562763
     
    30833090  #+gnu-objc (#_method_get_number_of_arguments m))
    30843091
    3085 #+(or apple-objc cocotron-objc)
     3092#+(and bad-idea (or apple-objc cocotron-objc))
    30863093(progn
    30873094(defloadvar *original-deallocate-hook* nil)
  • trunk/source/objc-bridge/objc-support.lisp

    r13023 r14203  
    168168                     (nsobject-description (ns-exception c))))))
    169169
    170 
     170(defun ensure-dealloc-method-for-class (class)
     171  (let* ((direct-slots (class-direct-slots class))
     172         (effective-slots (class-slots class)))
     173    (when (and (dolist (d direct-slots)
     174                 (when (and (typep d 'standard-direct-slot-definition)
     175                            (eq :instance (slot-definition-allocation d)))
     176                   (return t)))
     177               (dolist (e effective-slots t)
     178                 (when (and (typep e 'standard-effective-slot-definition)
     179                            (eq :instance (slot-definition-allocation e))
     180                            (not (find (slot-definition-name e)
     181                                       direct-slots
     182                                         :key #'slot-definition-name
     183                                         :test #'eq)))
     184                   (return))))
     185      (eval `(objc:defmethod (#/dealloc :void) ((self ,(class-name class)))
     186              (objc:remove-lisp-slots self)
     187              (call-next-method))))))
     188
     189(eval-when (:compile-toplevel :execute)
     190  (declaim (ftype (function (&rest t) t) objc-callback-error-return)))
    171191
    172192(defclass ns-lisp-exception (ns::ns-exception)
Note: See TracChangeset for help on using the changeset viewer.