Changeset 5729
- Timestamp:
- Jan 18, 2007, 3:11:20 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/examples/objc-clos.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/objc-clos.lisp
r5696 r5729 295 295 296 296 297 298 299 300 297 301 (defun make-objc-class-object-slots-vector (class meta) 298 302 (let* ((n (1+ (length (extract-instance-effective-slotds meta)))) … … 386 390 387 391 (defmethod (setf class-direct-slots) :before (dslotds (class objc::objc-class)) 392 #-apple-objc-2.0 388 393 (let* ((foreign-dslotds 389 394 (loop for d in dslotds … … 394 399 (return 395 400 (ash (%objc-class-instance-size c) 396 3))))))401 3)))))) 397 402 (unless 398 (dolist (d foreign-dslotds t) 399 (if (not (foreign-direct-slot-definition-bit-offset d)) 400 (return nil))) 401 (set-objc-foreign-direct-slot-offsets foreign-dslotds bit-offset)))) 403 (dolist (d foreign-dslotds t) 404 (if (not (foreign-direct-slot-definition-bit-offset d)) 405 (return nil))) 406 (set-objc-foreign-direct-slot-offsets foreign-dslotds bit-offset))) 407 #+apple-objc-2.0 408 ;; Add ivars for each foreign direct slot, then ask the runtime for 409 ;; the ivar's byte offset. (Note that the ObjC 2.0 ivar initialization 410 ;; protocol doesn't seem to offer support for bitfield-valued ivars.) 411 (dolist (dslotd dslotds) 412 (when (typep dslotd 'foreign-direct-slot-definition) 413 (let* ((string (lisp-defined-slot-name-to-objc-slot-name (slot-definition-name dslotd))) 414 (type (foreign-slot-definition-foreign-type dslotd)) 415 (encoding (progn 416 (ensure-foreign-type-bits type) 417 (encode-objc-type type))) 418 (size (ceiling (foreign-type-bits type) 8)) 419 (align (round (log (ceiling (foreign-type-alignment type) 8) 2)))) 420 (with-cstrs ((name string) 421 (encoding encoding)) 422 (unless (eql #$NO (#_class_addIvar class name size align encoding)) 423 (with-macptrs ((ivar (#_class_getInstanceVariable class name))) 424 (unless (%null-ptr-p ivar) 425 (let* ((offset (#_ivar_getOffset ivar))) 426 (setf (foreign-direct-slot-definition-bit-offset dslotd) 427 (ash offset 3))))))))))) 428 402 429 403 430 … … 437 464 (pref ivar :objc_ivar.ivar_offset) (ash offset -3)) 438 465 (incf offset (foreign-type-bits type)))))))) 466 467 439 468 440 469 (defun %objc-ivar-offset-in-class (name c) … … 742 771 (declare (ignore initargs)) 743 772 (unless (slot-value class 'foreign) 773 #-apple-objc-2.0 744 774 (multiple-value-bind (ivars instance-size) 745 775 (%make-objc-ivars class) 746 (%add-objc-class class ivars instance-size)))) 776 (%add-objc-class class ivars instance-size)) 777 #+apple-objc-2.0 778 (%add-objc-class class))) 747 779 748 780 (defmethod shared-initialize ((instance objc:objc-object) slot-names
Note:
See TracChangeset
for help on using the changeset viewer.
