Changeset 12207


Ignore:
Timestamp:
Jun 6, 2009, 6:16:24 AM (10 years ago)
Author:
gb
Message:

Try to deal better with instances of toll-free-bridged classes and
with instances that aren't heap-allocated in initialized-nsobject-p.

File:
1 edited

Legend:

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

    r12176 r12207  
    385385(defparameter *objc-description-max-length* 1024 "Limit on the length of NSObject description strings if non-NIL.")
    386386
     387(defun %cf-instance-p (instance)
     388  (> (objc-message-send instance "_cfTypeID" #>CFTypeID) 1))
    387389
    388390(defun initialized-nsobject-p (nsobject)
    389391  (or (objc-class-p nsobject)
    390392      (objc-metaclass-p nsobject)
    391       (let* ((class (#/class nsobject))
    392              (isize (%objc-class-instance-size class)))
    393         (declare (fixnum isize))
    394         (do* ((i (record-length :id) (1+ i)))
    395              ((= i isize))
    396           (declare (fixnum i))
    397           (unless (zerop (the (unsigned-byte 8) (%get-unsigned-byte nsobject i)))
    398             (return t))))))
     393      (let* ((cf-p (%cf-instance-p nsobject))
     394             (isize (if cf-p (#_malloc_size nsobject) (%objc-class-instance-size (#/class nsobject))))
     395             (skip (if cf-p (+ (record-length :id) 4 #+64-bit-target 4) (record-length :id))))
     396        (declare (fixnum isize skip))
     397        (or (> skip isize)
     398            (do* ((i skip (1+ i)))
     399                 ((>= i isize))
     400              (declare (fixnum i))
     401              (unless (zerop (the (unsigned-byte 8) (%get-unsigned-byte nsobject i)))
     402                (return t)))))))
    399403 
    400404(defun nsobject-description (nsobject)
Note: See TracChangeset for help on using the changeset viewer.