<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. &nbsp;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">&nbsp;(let* ((Name &nbsp; &nbsp; &nbsp; &nbsp; (%make-nsstring (native-translated-namestring File)))</font></div><div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(#_CFURLCreateWithFileSystemPath (%null-ptr) Name #$kCFURLPOSIXPathStyle #$NO))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(imageSrcRef &nbsp;(#_CGImageSourceCreateWithURL url (%null-ptr)))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(imageRef &nbsp; &nbsp; (#_CGImageSourceCreateImageAtIndex imageSrcRef 0 (%null-ptr)))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(uprightImage (#/imageWithCGImage: (@class c-i-image) imageRef)))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; (if (%null-ptr-p uprightImage)</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; (error "cannot decode texture file \"~A\"" (native-translated-namestring Filename)))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; (let* ( ;; Flip image (if necessary)</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(image (if Flip-Vertical (#/imageByApplyingTransform: uprightImage transform) uprightImage))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(rect (#/extent image))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(depth (#_CGImageGetBitsPerPixel imageRef))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(width (#_CGImageGetWidth imageRef))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(height (#_CGImageGetHeight imageRef))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(bytesPerRow (#_CGImageGetBytesPerRow imageRef))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(bytesPerPixel (truncate depth 8))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(bitmap (#/initWithCIImage: (#/alloc (@class n-s-bitmap-image-rep)) image))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(Codec (#/bitmapFormat bitmap))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(samples-per-pixel (#/samplesPerPixel bitmap)))</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(when Verbose</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(format t "---&gt; bytes-per-pixel/samples-per-pixel: ~A/~A~%" bytesPerPixel bytesPerPixel) ;samples-per-pixel)</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(format t "---&gt; 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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;;; FIXME: &nbsp;Need Core Image filters to change depth if required</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(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">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(#_CFRelease image)</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(#_CFRelease imageRef)</font></div><div><font class="Apple-style-span" face="Courier">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(#_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. &nbsp;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>