Embedding F-Script into Cocoa Applications
by Philippe Mougin07/12/2002
As we already saw in the previous articles in this series, F-Script can be used as a stand-alone application that dynamically loads your Objective-C classes and enables you to access them either interactively or using scripts. In this article, we'll explore the opposite possibility: including F-Script in your own applications.
All F-Script functionalities are available through components that can be integrated into applications. This enables you to:
- Program all or part of an application using the F-Script language.
- Offer a scripting environment within your applications, allowing users to manipulate your business objects and to automate processes.
- Interface F-Script with other tools.
Because F-Script and Cocoa share the same object model, integration is easy and advanced.
The Main Classes in the F-Script Integration API
The F-Script runtime is integrated into an application via a certain number of Objective-C classes, which are provided with F-Script in the form of a framework (FScript.framework). The following table illustrates the main characteristics of these classes in terms of integration.
Name: |
|
Role: |
Each instance of this class represents a complete F-Script interpreter (workspace included). An application may instantiate any number of interpreters. |
Main Features: |
|
Name: |
|
Role: |
Represents the result of an execution of F-Script code by an FSInterpreter. |
Main Features: |
|
Name: |
|
Role: |
A graphical component, a subclass of NSView, which provides F-Script with a command line interface. An FSInterpreterView has its own interpreter and F-Script workspace and can thus be used directly without requiring any other configuration. |
Main Features: |
|
Name: |
|
Role: |
Enables access (from both Objective-C and F-Script) to various services of the F-Script interpreter. The runtime creates a System instance per interpreter and associates it with the identifier "sys" in the interpreter's workspace. |
Main Features: |
|
Name: |
|
Role: |
A block represents a script (in other words, a piece of F-Script code that can have arguments, local variables and bindings to other objects). |
Main Features: |
|
Name: |
|
Role: |
A category of NSString. |
Main Features: |
|
A program wishing to use this API should use FScript.framework and the following import directive:
#import <FScript/FScript.h>
In order to use the F-Script framework from your own applications you will likely need to put it into one of these standard locations for frameworks on Mac OS X:
~/Library/Frameworks
/Library/Frameworks
/Network/Library/Frameworks
/System/Library/Frameworks
You can also directly bundle the framework into your application. This way, you will be able to ship a self-contained solution.







