Changeset 11597


Ignore:
Timestamp:
Jan 7, 2009, 10:55:15 AM (11 years ago)
Author:
gb
Message:

If sending an "init..." message to a newly-allocated ObjC instance
returns a null pointer, return that null pointer (rather than signalling
an error) in the ObjC version of ALLOCATE-INSTANCE and return that
null pointer from INITIALIZE-INSTANCE.

(In other words, allow

(make-instance some-objc-class :with-args ...)

to return a null pointer when

(#/initWithArgs: (#/alloc some-objc-class) ...)

would do so.)

File:
1 edited

Legend:

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

    r10457 r11597  
    720720(defmethod make-instance ((class objc:objc-class-object) &rest initargs)
    721721  (let ((instance (apply #'allocate-instance class initargs)))
    722     (apply #'initialize-instance instance initargs)))
     722    (if (%null-ptr-p instance)
     723      instance
     724      (apply #'initialize-instance instance initargs))))
    723725
    724726
     
    753755                                                       initargs))
    754756            (send-objc-init-message (allocate-objc-object class) ks vs))))
    755     (if (%null-ptr-p instance)
    756       (error "Got null pointer when trying to init instance of Objective-C class ~s with initargs ~s"
    757              class (remove-slot-initargs class initargs))
     757    (unless (%null-ptr-p instance)
    758758      (or (gethash instance *objc-object-slot-vectors*)
    759759          (let* ((slot-vector (create-foreign-instance-slot-vector class)))
Note: See TracChangeset for help on using the changeset viewer.