STEnvironment cleanup

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@13802 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Stefan Urbanek 2002-06-08 15:07:45 +00:00
parent aeab629f3b
commit 66049a0a8b
12 changed files with 155 additions and 162 deletions

View file

@ -1,3 +1,27 @@
2002 Jun 8
* STEnvironmentDescription: added module list; little code cleanup;
removed descriptionFromFile: and initFromFile: methods
* STEnvironment: removed methods:
environmentWithDescriptionFromFile:
environmentWithDescriptionFromDictionary:
initWithDescriptionFromFile:
init
addAllClasses
addObject:withName:
allObjectNames
new methods:
environmentWithDescription:
initWithDescription:
renamed methods:
defaultObjectPool to objectDictionary
registerObjectFinderWithName: to registerObjectFinderNamed:
load modules from description at initialization;
* STExecutor: reflect STEnvironment changes
* stexec: removed loading of the Foundation environment as this is handled
by the STEnvironment
* AppKit.stenv: new file
2002 Jun 7
* STEnvironmentDescription: added abstract class 'All' that is root

View file

@ -1,3 +1,9 @@
2002 Jun 8
* Reflect STEnvironment changes
* Removed loading of Foundation module as this is handleb by the
STEnvironment
2002 Jun 7
* Changed printing of result object (handle arrays, dictionaries and sets
@ -10,7 +16,6 @@
2002 Jun 4
* add DistributedFinder object finder to the environment
* use allObjectNames instead of allObjectsDictionary
2002 May 30

View file

@ -145,8 +145,8 @@
env = [STEnvironment environmentWithDescriptionName:envName];
}
[env loadModule:@"Foundation"];
[env addObjectFinderWithName:@"DistributedFinder"];
// [env loadModule:@"Foundation"];
[env registerObjectFinderNamed:@"DistributedFinder"];
/* FIXME: make this an option */
[env setFullScriptingEnabled:YES];

8
NEWS
View file

@ -1,9 +1,11 @@
0.5.3
0.6.0
* Created 'Object Finders'
* Added DistributedObject finder
* Automated loading of modules using scripting environment description
* New example tool stshell - the StepTalk shell
* StepTalk defaults changed
* Some source documentation added
* New example tool stshell - the StepTalk shell
* Added DistributedObject finder
* Bugfixes in Smalltalk language
0.5.2

View file

@ -0,0 +1,11 @@
/** AppKit.stenv
*/
{
Name = "AppKit";
Modules = (AppKit);
Use = (Foundation);
}

View file

@ -3,7 +3,8 @@
{
Name = "Foundation";
Modules = (Foundation);
Use = ("Foundation-operators");
DefaultRestriction = AllowAll;

View file

@ -54,12 +54,10 @@
+ (STEnvironment *)defaultScriptingEnvironment;
+ environmentWithDescriptionName:(NSString *)descName;
+ environmentWithDescriptionFromDictionary:(NSDictionary *)dict;
+ environmentWithDescriptionFromFile:(NSString *)path;
+ environmentWithDescription:(NSString *)description;
- initWithDescriptionName:(NSString *)descName;
- initWithDescriptionFromDictionary:(NSDictionary *)dict;
- initWithDescriptionFromFile:(NSString *)path;
- initWithDescription:(STEnvironmentDescription *)aDescription;
/** Full scripting */
@ -71,13 +69,13 @@
/** Modules */
- (void) loadModule:(NSString *)moduleName;
- (void)loadModule:(NSString *)moduleName;
- (void)addClassesWithNames:(NSArray *)names;
/** Named objects and object references */
- (NSDictionary *)allObjectsDictionary;
- (NSMutableDictionary *)objectDictionary;
- (void)setObject:(id)anObject
forName:(NSString *)objName;
- (void)removeObjectWithName:(NSString *)objName;
@ -87,9 +85,10 @@
- (STObjectReference *)objectReferenceForObjectWithName:(NSString *)name;
/** Distributed objects */
- (void)addObjectFinder:(id)finder name:(NSString*)name;
- (void)addObjectFinderWithName:(NSString *)name;
- (void)registerObjectFinder:(id)finder name:(NSString*)name;
- (void)registerObjectFinderNamed:(NSString *)name;
- (void)removeObjectFinderWithName:(NSString *)name;
- (NSArray *)knownObjectNames;
/** Selector translation */

View file

@ -1,6 +1,5 @@
/**
STEnvironmentDescription.m
Script executor
STEnvironmentDescription.h
Copyright (c) 2002 Free Software Foundation
@ -44,6 +43,7 @@ enum
NSMutableDictionary *classes;
NSMutableDictionary *behaviours;
NSMutableDictionary *aliases;
NSMutableArray *modules;
int restriction;
}

View file

@ -74,33 +74,12 @@
}
/**
Creates and initialises scripting environment using description
from dictionary <var>dict</var>.
Creates and initialises scripting environment using environment description
<var>description</var>.
*/
+ environmentWithDescriptionFromDictionary:(NSDictionary *)dict
+ environmentWithDescription:(NSString *)description
{
return AUTORELEASE([[self alloc] initWithDescriptionFromDictionary:dict]);
}
/**
Creates and initialises scripting environment using description
from file at <var>path</var>.
*/
+ environmentWithDescriptionFromFile:(NSString *)path
{
return AUTORELEASE([[self alloc] initWithDescriptionFromFile:path]);
}
- init
{
defaultPool = [[NSMutableDictionary alloc] init];
/* FIXME: */
// [defaultPool setObject:STNil forKey:@"nil"];
infoCache = [[NSMutableDictionary alloc] init];
return [super init];
return AUTORELEASE([[self alloc] initWithDescription:description]);
}
/**
@ -109,43 +88,34 @@
*/
- initWithDescriptionName:(NSString *)descName
{
[self init];
description = [STEnvironmentDescription descriptionWithName:descName];
classes = [description classes];
RETAIN(description);
return self;
return [self initWithDescription:
[STEnvironmentDescription descriptionWithName:descName]];
}
/**
Initialises scripting environment using description from dictionary
<var>dict</var>.
Initialises scripting environment using scripting description
<var>aDescription</var>.
*/
- initWithDescriptionFromDictionary:(NSDictionary *)dict
- initWithDescription:(STEnvironmentDescription *)aDescription
{
[self init];
NSEnumerator *enumerator;
NSString *module;
description = [STEnvironmentDescription descriptionFromDictionary:dict];
self = [super init];
defaultPool = [[NSMutableDictionary alloc] init];
infoCache = [[NSMutableDictionary alloc] init];
description = RETAIN(aDescription);
classes = [description classes];
RETAIN(description);
return self;
}
/**
Initialises scripting environment using description
from file at <var>path</var>
*/
- initWithDescriptionFromFile:(NSString *)path
{
[self init];
description = [STEnvironmentDescription descriptionFromFile:path];
classes = [description classes];
enumerator = [[description modules] objectEnumerator];
while( (module = [enumerator nextObject]) )
{
[self loadModule:module];
}
RETAIN(description);
return self;
@ -198,10 +168,6 @@
return createsUnknownObjects;
}
- (void)addAllClasses
{
[self addNamedObjectsFromDictionary:STAllObjectiveCClasses()];
}
/**
Add classes specified by the names in the <var>names</var> array.
*/
@ -224,7 +190,7 @@
[self addClassesWithNames:[module providedClasses]];
}
- (NSMutableDictionary *)defaultObjectPool
- (NSMutableDictionary *)objectDictionary
{
return defaultPool;
}
@ -233,16 +199,6 @@
Objects
----------------------------------------------------------------------- */
/**
Register object <var>anObject</var> with name <var>objName</var>.
*/
- (void)addObject:(id)anObject
withName:(NSString *)objName
{
NSLog(@"In STEnvironment: addObject:withName: used. Use setObject:forName:");
[defaultPool setObject:anObject forKey:objName];
}
/**
Register object <var>anObject</var> with name <var>objName</var>.
*/
@ -276,6 +232,14 @@
[defaultPool addEntriesFromDictionary:dict];
}
/**
Return object with name <var>objName</var>. If object is not found int the
object dictionary, then object finders are used to try to find the object.
If object is found by an object finder, then it is put into the object
dicitonary. If there is no object with given name, <var>nil</var> is
returned.
*/
- (id)objectWithName:(NSString *)objName
{
NSEnumerator *enumerator;
@ -441,16 +405,7 @@
STClassInfo *class;
NSString *selector;
#if 0
if( [anObject isProxy] )
{
NSDebugLog(@"Warning: receiver is a distant object (FIXME)");
return aString;
}
#endif
class = [self findClassInfoForObject:anObject];
class = [self findClassInfoForObject:anObject];
NSDebugLLog(@"STSending",
@"Lookup selector '%@' class %@", aString, [class behaviourName]);
@ -492,11 +447,6 @@
return selector;
}
- (NSArray *)allObjectNames
{
return [defaultPool allKeys];
}
- (NSArray *)knownObjectNames
{
NSMutableArray *array = [NSMutableArray array];
@ -513,8 +463,9 @@
return [NSArray arrayWithArray:array];
}
/** Distributed objects */
- (void)addObjectFinder:(id)finder name:(NSString*)name
/** Register object finder <var>finder</var> under the name <var>name</var> */
- (void)registerObjectFinder:(id)finder name:(NSString*)name
{
if(!objectFinders)
{
@ -524,7 +475,10 @@
[objectFinders setObject:finder forKey:name];
}
- (void)addObjectFinderWithName:(NSString *)name
/** Register object finder named <var>name</var>. This method will try to find
an object finder bundle in Library/StepTalk/Finders directories.
*/
- (void)registerObjectFinderNamed:(NSString *)name
{
NSBundle *bundle;
NSString *path;
@ -559,9 +513,10 @@
return;
}
[self addObjectFinder:finder name:name];
[self registerObjectFinder:finder name:name];
}
/** Remove object finder with name <var>name</var> */
- (void)removeObjectFinderWithName:(NSString *)name
{
[objectFinders removeObjectForKey:name];

View file

@ -108,27 +108,19 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
{
return AUTORELEASE([[self alloc] initWithName:descriptionName]);
}
+ descriptionFromFile:(NSString *)fileName
{
return AUTORELEASE([[self alloc] initFromFile:fileName]);
}
+ descriptionFromDictionary:(NSDictionary *)dictionary
{
return AUTORELEASE([[self alloc] initFromDictionary:dictionary]);
}
- (void)dealloc
{
RELEASE(behaviours);
RELEASE(usedDefs);
RELEASE(classes);
[super dealloc];
}
- initFromFile:(NSString *)fileName
{
NSDictionary *dict;
RELEASE(behaviours);
RELEASE(aliases);
RELEASE(modules);
dict = [NSDictionary dictionaryWithContentsOfFile:fileName];
return [self initFromDictionary:dict];
[super dealloc];
}
- initWithName:(NSString *)defName;
@ -184,25 +176,21 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
}
}
[self updateUseListFromDictionary:def];
[self updateBehavioursFromDictionary:def];
[self updateClassesFromDictionary:def];
[self updateAliasesFromDictionary:def];
[self updateUseList:[def objectForKey:@"Use"]];
[self updateModuleList:[def objectForKey:@"Modules"]];
[self updateBehavioursFromDictionary:[def objectForKey:@"Behaviours"]];
[self updateClassesFromDictionary:[def objectForKey:@"Classes"]];
[self updateAliasesFromDictionary:[def objectForKey:@"Aliases"]];
restriction = saveFlag;
}
- (void)updateUseListFromDictionary:(NSDictionary *)def
- (void)updateUseList:(NSArray *)array
{
NSEnumerator *enumerator;
NSString *str;
if(!def)
{
return;
}
enumerator = [[def objectForKey:@"Use"] objectEnumerator];
enumerator = [array objectEnumerator];
while( (str = [enumerator nextObject]) )
{
@ -210,29 +198,44 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
{
usedDefs = [[NSMutableArray alloc] init];
}
if( [usedDefs containsObject:str] )
{
continue;
}
else
if( ![usedDefs containsObject:str] )
{
[usedDefs addObject:str];
[self updateFromDictionary:dictForDescriptionWithName(str)];
}
[self updateFromDictionary:dictForDescriptionWithName(str)];
}
}
- (void)updateBehavioursFromDictionary:(NSDictionary *)aDict
- (void)updateModuleList:(NSArray *)array
{
NSEnumerator *enumerator;
NSString *str;
enumerator = [array objectEnumerator];
while( (str = [enumerator nextObject]) )
{
if(!modules)
{
modules = [[NSMutableArray alloc] init];
}
if( ![modules containsObject:str] )
{
[modules addObject:str];
}
}
}
- (void)updateBehavioursFromDictionary:(NSDictionary *)dict
{
NSEnumerator *enumerator;
NSDictionary *dict;
NSString *name;
STBehaviourInfo *behInfo;
dict = [aDict objectForKey:@"Behaviours"];
enumerator = [dict keyEnumerator];
while( (name = [enumerator nextObject]) )
@ -252,7 +255,6 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
behInfo = [[STBehaviourInfo alloc] initWithName:name];
[behaviours setObject:behInfo forKey:name];
// NSDebugLog(@"Create behaviour %@", name);
[self updateBehaviour:behInfo description:[dict objectForKey:name]];
}
@ -267,8 +269,6 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
STBehaviourInfo *useInfo;
// NSDebugLog(@"Update behaviour '%@'", [behInfo behaviourName]);
enumerator = [[def objectForKey:@"Use"] objectEnumerator];
while( (str = [enumerator nextObject]) )
{
@ -287,19 +287,16 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
[behInfo allowMethods:[NSSet setWithArray:[def objectForKey:@"AllowMethods"]]];
[behInfo denyMethods:[NSSet setWithArray:[def objectForKey:@"DenyMethods"]]];
/* FIXME: should be special */
[behInfo addTranslationsFromDictionary:[def objectForKey:@"SymbolicSelectors"]];
[behInfo addTranslationsFromDictionary:[def objectForKey:@"Aliases"]];
}
- (void)updateClassesFromDictionary:(NSDictionary *)def
- (void)updateClassesFromDictionary:(NSDictionary *)dict
{
NSEnumerator *enumerator;
NSDictionary *dict;
NSString *str;
dict = [def objectForKey:@"Classes"];
enumerator = [dict keyEnumerator];
while( (str = [enumerator nextObject]) )
@ -392,13 +389,11 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
}
}
- (void)updateAliasesFromDictionary:(NSDictionary *)def
- (void)updateAliasesFromDictionary:(NSDictionary *)dict
{
NSEnumerator *enumerator;
NSDictionary *dict;
NSString *str;
dict = [def objectForKey:@"Aliases"];
enumerator = [dict keyEnumerator];
while( (str = [enumerator nextObject]) )
@ -412,6 +407,11 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
return classes;
}
- (NSArray *)modules
{
return [NSArray arrayWithArray:modules];
}
- (void)fixupScriptingDescription
{
[self resolveSuperclasses];
@ -419,10 +419,10 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
- (void)resolveSuperclasses
{
STClassInfo *class;
STClassInfo *superclass;
NSString *className;
NSEnumerator *enumerator;
STClassInfo *superclass;
STClassInfo *class;
NSString *className;
enumerator = [classes objectEnumerator];
@ -461,5 +461,3 @@ static NSDictionary *dictForDescriptionWithName(NSString *defName)
}
}
@end

View file

@ -198,16 +198,15 @@ const char *STExecutorCommonOptions =
- (void)listObjects
{
NSArray *objects;
NSEnumerator *enumerator;
NSDictionary *dict;
NSString *name;
NSDictionary *pool;
NSArray *objects;
pool = [env defaultObjectPool];
dict = [env objectDictionary];
objects = [[dict allKeys] sortedArrayUsingSelector:@selector(compare:)];
objects = [pool allKeys];
objects = [objects sortedArrayUsingSelector:@selector(compare:)];
enumerator = [objects objectEnumerator];
if(listObjects == STListAll)
@ -221,7 +220,7 @@ const char *STExecutorCommonOptions =
{
while( (name = [enumerator nextObject]) )
{
if([[pool objectForKey:name] isClass])
if([[dict objectForKey:name] isClass])
{
printf("%s\n", [name cString]);
}
@ -231,7 +230,7 @@ const char *STExecutorCommonOptions =
{
while( (name = [enumerator nextObject]) )
{
if(! [[pool objectForKey:name] isClass])
if(! [[dict objectForKey:name] isClass])
{
printf("%s\n", [name cString]);
}

View file

@ -57,7 +57,6 @@
env = [STEnvironment environmentWithDescriptionName:envName];
}
[env loadModule:@"Foundation"];
[env loadModule:@"SimpleTranscript"];
[env setCreatesUnknownObjects:YES];