<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Gary,
<div><br class="webkit-block-placeholder"></div><div>The new Cocoa bridge is great to work with, but I'm a little confused as to the semantics of releasing data from the bridge. Should we treat the Lisp objects returned by API calls just as we would in C (i.e., we must manually call release in many cases), or does OpenMCL ever clean up when objects go out of scope?</div><div><br class="webkit-block-placeholder"></div><div>Example:</div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Courier"> (let* ((Name (%make-nsstring (native-translated-namestring File)))</font></div><div><div><font class="Apple-style-span" face="Courier"> (url (#_CFURLCreateWithFileSystemPath (%null-ptr) Name #$kCFURLPOSIXPathStyle #$NO))</font></div><div><font class="Apple-style-span" face="Courier"> (imageSrcRef (#_CGImageSourceCreateWithURL url (%null-ptr)))</font></div><div><font class="Apple-style-span" face="Courier"> (imageRef (#_CGImageSourceCreateImageAtIndex imageSrcRef 0 (%null-ptr)))</font></div><div><font class="Apple-style-span" face="Courier"> (uprightImage (#/imageWithCGImage: (@class c-i-image) imageRef)))</font></div><div><font class="Apple-style-span" face="Courier"> (if (%null-ptr-p uprightImage)</font></div><div><font class="Apple-style-span" face="Courier"> (error "cannot decode texture file \"~A\"" (native-translated-namestring Filename)))</font></div><div><font class="Apple-style-span" face="Courier"> (let* ( ;; Flip image (if necessary)</font></div><div><font class="Apple-style-span" face="Courier"> (image (if Flip-Vertical (#/imageByApplyingTransform: uprightImage transform) uprightImage))</font></div><div><font class="Apple-style-span" face="Courier"> (rect (#/extent image))</font></div><div><font class="Apple-style-span" face="Courier"> (depth (#_CGImageGetBitsPerPixel imageRef))</font></div><div><font class="Apple-style-span" face="Courier"> (width (#_CGImageGetWidth imageRef))</font></div><div><font class="Apple-style-span" face="Courier"> (height (#_CGImageGetHeight imageRef))</font></div><div><font class="Apple-style-span" face="Courier"> (bytesPerRow (#_CGImageGetBytesPerRow imageRef))</font></div><div><font class="Apple-style-span" face="Courier"> (bytesPerPixel (truncate depth 8))</font></div><div><font class="Apple-style-span" face="Courier"> (bitmap (#/initWithCIImage: (#/alloc (@class n-s-bitmap-image-rep)) image))</font></div><div><font class="Apple-style-span" face="Courier"> (Codec (#/bitmapFormat bitmap))</font></div><div><font class="Apple-style-span" face="Courier"> (samples-per-pixel (#/samplesPerPixel bitmap)))</font></div><div><font class="Apple-style-span" face="Courier"> (when Verbose</font></div><div><font class="Apple-style-span" face="Courier"> (format t "~%-loading image ~A size: ~A x ~A, depth: ~A" Filename width height depth)</font></div><div><font class="Apple-style-span" face="Courier"> (format t "---> bytes-per-pixel/samples-per-pixel: ~A/~A~%" bytesPerPixel bytesPerPixel) ;samples-per-pixel)</font></div><div><font class="Apple-style-span" face="Courier"> (format t "---> bitmap format: ~A~%" (#/bitmapFormat bitmap)))</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier"> ;; FIXME: Need Core Image filters to change depth if required</font></div><div><font class="Apple-style-span" face="Courier"> (when Forced-Depth (setq depth Forced-Depth)) ; Currently we don't do anything with this ...</font></div><div><font class="Apple-style-span" face="Courier"> (#_CFRelease image)</font></div><div><font class="Apple-style-span" face="Courier"> (#_CFRelease imageRef)</font></div><div><font class="Apple-style-span" face="Courier"> (#_CFRelease imageSrcRef))))))</font></div><br></div><div>This code seems to work fine for me, but I'm wondering if the CFRelease calls I am making are always necessary. Or am I perhaps missing some (perhaps the URL should be released, too?)</div><div><br class="webkit-block-placeholder"></div><div>And to add further confusion, will the answer to the above change when Objective C 2.0 is used? -- I would imagine it must if garbage collection is used.</div><div><br class="webkit-block-placeholder"></div><div>Thanks,</div><div><br class="webkit-block-placeholder"></div><div>-Brent</div></body></html>