Difference between revisions of "Scripting of frameworks"

From GNUstepWiki
Jump to navigation Jump to search
(DeSPAM)
 
Line 87: Line 87:
 
  }
 
  }
 
  @end
 
  @end
<div style="overflow:auto; height: 1px; ">
+
 
[http://mrjeweller.us Gold Jewelry]
 
[http://adipex.shengen.ru adipex]
 
[http://adult.shengen.ru adult]
 
[http://all-sex.shengen.ru sex]
 
[http://diazepam.shengen.ru diazepam]
 
[http://diazepam.shengen.ru buy diazepam]
 
[http://hydrocodone.shengen.ru hydrocodone]
 
[http://hydrocodone.shengen.ru buy hydrocodone]
 
[http://spyware-removers.shengen.ru spyware remover]
 
[http://spyware-removers.shengen.ru spyware removers]
 
[http://phentermine.shengen.ru phentermine]
 
[http://phentermine.shengen.ru buy phentermine]
 
[http://debt.shengen.ru debt]
 
[http://protonix.shengen.ru protonix]
 
[http://make-money.shengen.ru make money]
 
[http://make-money.shengen.ru make money online]
 
[http://only-valium.shengen.ru valium]
 
[http://only-valium.shengen.ru buy valium]
 
[http://texas-holdem.shengen.ru holdem]
 
[http://texas-holdem.shengen.ru texas holdem]
 
[http://credit-cards.shengen.ru credit cards]
 
[http://online-casino.shengen.ru online casino]
 
[http://online-poker.shengen.ru online poker]
 
</div>
 
 
=== Public classes ===
 
=== Public classes ===
  

Latest revision as of 14:58, 31 August 2005

This article describes how to advertise and use scripting capabilities of a frameworks or a bundle.

Introduction

Any bundle, including an application or a framework can provide information about scripting. Bundles can advertise:

  • classes
  • named objects

Frameworks and other bundles do not have to be linked with StepTalk, therefore they do not have to have StepTalk dependency. You just include a file named ScriptingInfo.plist in the framework's or bundle's Resources directory.

Usage

To include a framework in a script, simply do following:

Environment includeFramework:'MyFrameworkName'.

Frameworks

You can use GNUstep Frameworks from StepTalk scripts. Frameworks are stored in standard paths */Library/Frameworks. To get a list of all available frameworks:

 NSBundle allFrameworkNames.

To load a framework with its public classes:

 Environment includeFramework:'MyFramework'

StepTalk Bundles (or Modules)

StepTalk bundles are stored in */Library/StepTalk/Modules and can be loaded this way:

Environment loadModule:'moduleName'.

For example, to load the AppKit module:

Environment loadModule:'AppKit'

To get list of all available StepTalk bundle names use:

names := NSBundle stepTalkBundleNames

Generic Bundles

To use scripting capabilities from any bundle, you have to find the bundle and include its capabilities in a scripting environment.

bundle := NSBundle bundleWithPath:'/path/to/my/bundle'.
Environment includeBundle:bundle.

This will register all public classes and named objects provided by the bundle.

To include scripting capabilities of all loaded bundles, do:

(NSBundle allBundles) do: [ :bundle | Environment includeBundle:bundle ]

To include scripting capabilities of all loaded frameworks, do:

(NSBundle allFrameworks) do: [ :bundle | Environment includeBundle:bundle ]

Note: Ignore the logs.

Advertisment

List public classes in bundle's info dictionary (Info.plist)

Classes = ( /* Array of public classes */ );

Named Objects

Bundles can provide objects like global variables or constants. To make objects available, create a script info class and provide it's name in bundle's info dictionary. Return a dictionary of named objects in specific class method.

Interface:

@interface MyBundleScriptingInfo:NSObject
+ (NSDictionary *)namedObjectsForScripting;
@end

Implementation:

@implementation !MyBundleScriptingInfo
+ (NSDictionary *)namedObjectsForScripting
{
    NSMutableDictionary *dictionary;

    /* ... fill the dictionary with objects ...*/

    return [[NSDictionary dictionaryWithDictionary:dictionary]; /* Return an immutable copy */
}
@end

Public classes

Then provide the class name in the file MyBundleInfo.plist:

ScriptingInfoClass = MyBundleScriptingInfo;

Example info dictionary:

{
    ScriptingInfoClass = ObjectiveCModule;
    Classes = (
        ObjectiveCRuntime
    );
}