Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
sdef files and ASKApplicationSuite question, plus a hack to inherit across suites with sdef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sdef files and ASKApplicationSuite question, plus a hack to inherit across suites with sdef



First I have a question about sdef files and the ASKApplicationSuite. I'm reading the document "Adding AppleScript Studio Support to Your Cocoa Application" that's located here:

http://developer.apple.com/documentation/AppleScript/Conceptual/ StudioBuildingApps/chapter05/chapter_5_section_4.html#//apple_ref/doc/ uid/20001252/BCIIGFGD

I'm thinking of doing this for my own app, but I'm unsure about two things. First the last instruction says:

5. If your application has a .scriptsuite file, for every class in that file whose superclass belongs to the core suite (NSCoreSuite), change the suite to ASKApplicationSuite. For example, change

The problem is that I'm using sdef files to generate my scriptSuite and scriptTerminology files and the files generated contain NSCoreSuite references. When I generate the files using sdp I'm referencing the core suite like this -i /Developer/Examples/Scripting\ Definitions/NSCoreSuite.sdef. I assume that if I referenced ASKApplicationSuite sdef file then everything would work out, but I don't see an sdef version of ASKApplicationSuite yet. So for now is their a recommended workaround? Would just doing a find and replace after the scriptSuite file work, or is there a better way?

I'm also wondering if it is possible to add terms to a suite that already exists? Right now my application already has an "Application Suite" but the applescript studio stuff contains a suite with that same name and they seem to be conflicting. I've tried using the same and different event codes for the two suites, but things stuff seem to get flaky. Is their a way to make this work, or do I need to use a new name for my suite.

Second here is a hack that seems to get around the "inherit across suites with sdef" problem discussed earlier on the list. The problem being that if two different suites try to inherit from the same class without renaming (more like creating a category) then things break. For example if you include this:

<class name="application" inherits="application" code="capp" description="An application's top level scripting object.">

In two different suites you'll get trouble when you try to script the application object because it can't determine which NSScriptClassDescription it should use. To fix this problem create a subclass of NSScriptClassDescription with the following code and then pose that class as the standard NSScriptClassDescription early in your app's startup process. The code looks for conflicts as the script class descriptions are loaded and when it finds a problem it resolves it by making one of the conflicting definitions inherit from the other. Of course if improvements can be made please let me know.

- (id)initWithSuiteName:(NSString *)suiteName className:(NSString *)className dictionary:(NSDictionary *)descriptions {
Class class = NSClassFromString(className);

if (class) {
id existingDescription = [NSClassDescription classDescriptionForClass:class];
if (existingDescription && [existingDescription isKindOfClass:[NSScriptClassDescription class]]) {
NSString *existingDescriptionClassName = [NSString stringWithFormat:@"%@.%@", [existingDescription suiteName], [existingDescription className], nil];
NSString *newSuperClassName = [descriptions objectForKey:@"Superclass"];


if (![existingDescriptionClassName isEqual:newSuperClassName]) {
NSMutableDictionary *mutableDiscriptions = [[descriptions mutableCopy] autorelease];
[mutableDiscriptions setObject:existingDescriptionClassName forKey:@"Superclass"];
descriptions = mutableDiscriptions;
}
}
}

return [super initWithSuiteName:suiteName className:className dictionary:descriptions];
}


Jesse

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.