F-Script.app 2.0 is automatically linked with a number of new frameworks found in Leopard. This is convenient for quickly exploring Leopard's capabilities.
Let me illustrate this on a practical example: I'm currently experimenting with the new Image Kit framework introduced in Leopard. I can launch F-Script.app and directly enter the following code:
IKPictureTaker pictureTaker orderFront:nil
It will activate the
IKPictureTaker panel, a component of Image Kit that allows, among other things, browsing images in the file system and taking snapshots from digital camera (including the built-in iSight).
Then, once I've got the image I want, I can get the image objet (an
NSImage instance) from the panel with:
IKPictureTaker pictureTaker outputImage
I can also explore the image object in the object browser by typing:
sys browse:IKPictureTaker pictureTaker outputImage
Here is the list of frameworks automatically linked with F-Script.app:
|Address Book||Access to the contacts database|
|Application Kit||User interface|
|Automator||Automator plugin system|
|Calendar Store||Access to the calendar database|
|Colaboration||Identity information management|
|Core Animation||Graphical animation|
|Core Audio Kit||Audio Units custom views|
|Core Data||Data model management (object persistence, etc.)|
|Core Image||Image processing|
|Core Video||Video processing|
|Disc Recording||CD and DVD burning|
|Disc Recording UI||User interface components for CD and DVD burning|
|Disk Arbitration||Hard disk events monitoring and management|
|Exception Handling||Exception handling configuration|
|Foundation Kit||Core services (root class, string handling, collections, networking, file management, threading, etc.)|
|Image Kit||User interface components for image browsing and manipulation|
|Input Method Kit||Input methods management|
|Instant Message||Online status of instant messaging users|
|IOBluetooth||Access to Bluetooth devices|
|IOBluetooth UI||User interface components for access to Bluetooth devices|
|JavaVM||Access to the Java environment|
|OSA Kit||Management and execution of OSA-compliant scripts|
|PDF Kit||PDF handling|
|PubSub||RSS and ATOM handling|
|QT Kit||Rendering and manipulation of QuickTime content|
|Quartz Composer||Access to Quartz Composer compositions|
|Scripting Bridge||Control of scriptable applications|
|Security Foundation||Users authorization|
|Security Interface||User interface components for users authorization|
|Sync Services||Data synchronization between multiples computers and devices|
|WebKit||Web content rendering|
|Xgrid Foundation||Cluster management|
You can dynamically load other frameworks or bundles (including yours) using standards Cocoa techniques. For example, the following code loads the SenTesting Kit:
(NSBundle bundleWithPath:'/Developer/Library/Frameworks/SenTestingKit.framework') load
You can also have F-Script automatically load additional frameworks or bundles at launch time by putting them in the F-Script repository. This repository is created by the F-Script.app application when you launch it for the first time. By default it will be
~/Library/Application Support/F-Script (where
~ stands for your home directory). You should put your bundles and frameworks in the
~/Library/Application Support/F-Script/classes directory.
Most constants defined in the Objective-C-based frameworks of Leopard are available in F-Script. I used to rely on my own header scanner for this feature on previous Mac OS X versions, but it was essentially a quick and dirty piece of code done ages ago on a full moon night. I was hoping something better would eventually appear that I could reuse. Well, it’s finally here, in the form of BridgeSupport, a technology developed by Laurent Sansonetti at Apple.
BridgeSupport files are XML files that describe the API symbols of frameworks or libraries that cannot be introspected at runtime. These are generally ANSI C symbols that is, non-object-oriented items such as constants, enumerations, structures, and functions but can also include some additional information about Objective-C classes, methods, and informal protocols.
Thanks to the inclusion of this technology in Leopard, my old code is gone and I rely on BridgeSupport in F-Script 2.0.
Accessing the BridgeSupport XML files has been easy, using Cocoa's
NSXML classes. Speaking of
NSXML, below is a code snippet that illustrates how it can be used to process XML files with F-Script. We’ll access the BridgeSupport XML file for the Application Kit, and look at the names of the constants therein referenced.
"Define the location of the XML document we want to read" location := NSURL fileURLWithPath:'/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/BridgeSupport/AppKitFull.bridgesupport'. "Load the XML document" xml := NSXMLDocument alloc initWithContentsOfURL: location options: NSXMLNodePreserveWhitespace error: nil. "Inspect nodes containing constant's names" ((xml rootElement elementsForName:'constant') attributeForName:'name') inspect.
inspect message in the last instruction opens the array of selected nodes in the graphical array inspector, shown below: