[Openmcl-devel] Using CFStrings in OpenMCL

David Steuber david at david-steuber.com
Sat Dec 18 05:38:58 UTC 2004

On Dec 17, 2004, at 11:32 PM, Gary Byers wrote:
> On Fri, 17 Dec 2004, David Steuber wrote: >
>> Either way, for a CFString or NSString, I still > have to release it
>> so far as I can tell.
> You don't have to release a -constant- CFString/NSString (and calling
> #_CFRelease on one is a no-op.)

Just in case I was overlooking the blinding obvious, I thought I would 

$ openmcl
Welcome to OpenMCL Version (Beta: Darwin) 0.14.2-p1!
? (open-shared-library 
#<SHLIB /System/Library/Frameworks/Carbon.framework/Carbon #x6389596>
? (ccl::with-cstr (str "foo") (defconstant +foo+
                               (#___CFStringMakeConstantString str)))
? +foo+
#<A Mac Pointer #x102F30>
? (#_CFStringGetCStringPtr +foo+ #$kCFStringEncodingASCII)
#<A Null Mac Pointer>

I'm not sure how to get my string back to confirm that +foo+ really has 
"foo" in it.  I did manage to get myself into the kernel debugger by 
not noticing that #_CFStringGetCStringPtr gave me a null MACPTR before 
doing CCL::%GET-CSTRING on it.  The docs weren't lying about the % 
functions being dangerous.

It would be nice to be able to put a constant CFString in a DEFCONSTANT 
and have it survive a CCL::SAVE-APPLICATION.

More information about the Openmcl-devel mailing list