Changeset 14289


Ignore:
Timestamp:
Sep 20, 2010, 5:30:51 AM (9 years ago)
Author:
gb
Message:

Use a copy of the foreign instance pointer as a key in the
*OBJC-OBJECT-SLOT-VECTORS* hash table and as the value of
slot-vector.instance.

File:
1 edited

Legend:

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

    r14263 r14289  
    141141
    142142(defun %objc-domain-slots-vector (p)
    143        (let* ((type (%macptr-type p))
    144              (flags (ldb objc-type-flags type))
    145              (index (ldb objc-type-index type)))
    146         (declare (fixnum type flags index))
    147         (ecase flags
    148           (#.objc-flag-instance (or (gethash p *objc-object-slot-vectors*)
    149                                     ; try to allocate the slot vector on demand
    150                                     (let* ((slot-vector (create-foreign-instance-slot-vector (class-of p))))
    151                                       (when slot-vector
    152                                         (setf (slot-vector.instance slot-vector) p)
    153                                         (setf (gethash p *objc-object-slot-vectors*) slot-vector)
    154                                         (initialize-instance p))
    155                                       slot-vector)
    156                                     (error "~s has no slots." p)))
    157           (#.objc-flag-class (id->objc-class-slots-vector index))
    158           (#.objc-flag-metaclass (id->objc-metaclass-slots-vector index)))))
     143  (let* ((type (%macptr-type p))
     144         (flags (ldb objc-type-flags type))
     145         (index (ldb objc-type-index type)))
     146    (declare (fixnum type flags index))
     147    (ecase flags
     148      (#.objc-flag-instance (or (gethash p *objc-object-slot-vectors*)
     149                                        ; try to allocate the slot vector on demand
     150                                (let* ((slot-vector (create-foreign-instance-slot-vector (class-of p))))
     151                                  (when slot-vector
     152                                    (let* ((copy (%inc-ptr p)))
     153                                      (setf (slot-vector.instance slot-vector) copy)
     154                                      (setf (gethash copy *objc-object-slot-vectors*) slot-vector))
     155                                    (initialize-instance p))
     156                                  slot-vector)
     157                                (error "~s has no slots." p)))
     158      (#.objc-flag-class (id->objc-class-slots-vector index))
     159      (#.objc-flag-metaclass (id->objc-metaclass-slots-vector index)))))
    159160
    160161(defun %objc-domain-class-ordinal (p)
     
    752753        (let* ((slot-vector (create-foreign-instance-slot-vector class)))
    753754          (when slot-vector
    754             (setf (slot-vector.instance slot-vector) instance)
    755             (setf (gethash instance *objc-object-slot-vectors*) slot-vector)))))
     755            (let* ((copy (%inc-ptr instance)))
     756              (setf (slot-vector.instance slot-vector) copy)
     757            (setf (gethash copy *objc-object-slot-vectors*) slot-vector))))))
    756758  instance)
    757759               
Note: See TracChangeset for help on using the changeset viewer.