Using ccons to Play with CoreFoundation Interactively

One great thing about ccons is that all the POSIX stack is now available to you in an interactive manner. And suddenly I have this idea: If zlib can be loaded, why can't CoreFoundation?

And indeed it can!

I have made two tweaks, though, because I have limited understanding on how ccons handles include path and the processing of the #include_next. I made some changes to stdarg.h. Your /usr/include/stdarg.h should look like this on Mac OS X:

#if defined(__GNUC__)
#include_next <stdarg.h>

Now, I've changed the second line to:

#include </Developer/SDKs/MacOSX10.5.sdk\

And now sqlite3.h can be included. Make similar change to float.h, and then you can do this!

:load /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
#include <CoreFoundation/CoreFoundation.h>

Here is what you can type, and what you'll get from ccons, a CF-style hello, world:

>>> :load /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
Dynamic library loaded.
>>> #include <CoreFoundation/CoreFoundation.h>
>>> CFStringRef a;
>>> a = CFStringCreateWithCString(NULL, "hello, world", kCFStringEncodingUTF8);
=> (CFStringRef) 0x3147530
>>> CFShow(a);
hello, world
>>> CFStringGetLength(a);
=> (CFIndex) 12

Needless to say, CF is verbose. But the idea of being able to manipulate interactively these libraries is certainly fascinating. Now imagine what one can do if ccons can do Objective-C and Cocoa.