diff --git a/ChangeLog b/ChangeLog index 7a95199..2115119 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,19 @@ +2005 Jan 4 Stefan Urbanek + + * First step of introducing contexts + + NOTE: This version is unstable. + 2004 Nov 9 Stefan Urbanek * Remove STMethodSignatureForSelector as it was deprecated because of inportability to OSX. +2004 Sep 23 Stefan Urbanek + + * STContext: new class + * STEnvironment: make it subclass of STContext, move several methods + 2004 Sep 6 Stefan Urbanek * stshell: fix for compiler diff --git a/Examples/Shell/STShell.m b/Examples/Shell/STShell.m index c36140a..48d2612 100644 --- a/Examples/Shell/STShell.m +++ b/Examples/Shell/STShell.m @@ -89,7 +89,7 @@ int complete_handler(void) scriptsManager = RETAIN([STScriptsManager defaultManager]); prompt = @"StepTalk > "; - conversation = [[STConversation alloc] initWithEnvironment:env language:nil]; + conversation = [[STConversation alloc] initWithContext:env language:nil]; /* FIXME: make this more clever for completion handler */ if(!sharedShell) { @@ -147,12 +147,12 @@ int complete_handler(void) - (STEnvironment *)environment { - return [conversation environment]; + return [conversation context]; } - (void)run { - STEnvironment *env = [conversation environment]; + STEnvironment *env = [conversation context]; NSString *line; id result; @@ -202,7 +202,7 @@ int complete_handler(void) } - (id)executeLine:(NSString *)line { - STEnvironment *env = [conversation environment]; + STEnvironment *env = [conversation context]; NSString *cmd; id result = nil; @@ -261,7 +261,7 @@ int complete_handler(void) - (int)completion { - STEnvironment *env = [conversation environment]; + STEnvironment *env = [conversation context]; NSEnumerator *enumerator; NSMutableSet *set; NSString *match; diff --git a/Frameworks/StepTalk/Environments/Foundation-operators.stenv b/Frameworks/StepTalk/Environments/Foundation-operators.stenv index f2c5dba..1794efb 100644 --- a/Frameworks/StepTalk/Environments/Foundation-operators.stenv +++ b/Frameworks/StepTalk/Environments/Foundation-operators.stenv @@ -11,7 +11,7 @@ { "NSObject-operators" = { Use = (Comparison, KeyValueCoding); - } + }; }; Classes = @@ -53,7 +53,7 @@ { "+=" = "addObject:"; "-=" = "removeObject:"; - } + }; }; NSDictionary = @@ -61,7 +61,7 @@ Super = NSObject; SymbolicSelectors = { "@" = "objectForKey:"; - } + }; }; NSUserDefaults = @@ -69,7 +69,7 @@ Super = NSObject; SymbolicSelectors = { "@" = "objectForKey:"; - } + }; }; NSString = @@ -93,7 +93,7 @@ SymbolicSelectors = { "+=" = "appendString:"; - } + }; }; NSSet = @@ -102,7 +102,7 @@ SymbolicSelectors = { "<" = "isSubsetOfSet:"; - } + }; }; NSMutableSet = @@ -112,7 +112,7 @@ { "+=" = "addObject:"; "-=" = "removeObject:"; - } + }; }; NSDate = @@ -121,7 +121,7 @@ SymbolicSelectors = { "-" = "timeIntervalSinceDate:"; - } + }; }; @@ -135,7 +135,7 @@ "<>" = "rangeWith:"; "@" = "pointWith:"; "@@" = "sizeWith:"; - } + }; }; }; /* Classes */ } diff --git a/Frameworks/StepTalk/Environments/Safe.stenv b/Frameworks/StepTalk/Environments/Safe.stenv index f639b52..177f150 100644 --- a/Frameworks/StepTalk/Environments/Safe.stenv +++ b/Frameworks/StepTalk/Environments/Safe.stenv @@ -13,7 +13,7 @@ "writeToFile:atomically:", "writeToURL:atomically:" ) - } + }; }; Classes = diff --git a/Frameworks/StepTalk/Environments/SymbolicSelectors.stenv b/Frameworks/StepTalk/Environments/SymbolicSelectors.stenv index 7390d5b..d2fa14a 100644 --- a/Frameworks/StepTalk/Environments/SymbolicSelectors.stenv +++ b/Frameworks/StepTalk/Environments/SymbolicSelectors.stenv @@ -25,7 +25,7 @@ "<=" = "isLessOrEqualThan:"; ">=" = "isGreatherOrEqualThan:"; - } + }; }; NumberArithmetic = diff --git a/Frameworks/StepTalk/GNUmakefile b/Frameworks/StepTalk/GNUmakefile index e5160d6..34fd6ff 100644 --- a/Frameworks/StepTalk/GNUmakefile +++ b/Frameworks/StepTalk/GNUmakefile @@ -30,6 +30,7 @@ StepTalk_OBJC_FILES = \ STBehaviourInfo.m \ STBundleInfo.m \ STClassInfo.m \ + STContext.m \ STConversation.m \ STEngine.m \ STEnvironment.m \ @@ -58,6 +59,7 @@ StepTalk_OBJC_FILES = \ STEPTALK_HEADER_FILES = \ STBundleInfo.h \ + STContext.h \ STConversation.h \ STEngine.h \ STEnvironment.h \ @@ -82,10 +84,7 @@ StepTalk_HEADER_FILES = $(STEPTALK_HEADER_FILES) \ StepTalk.h -StepTalk_RESOURCE_FILES = ScriptingInfo.plist - -STEPTALK_LIBRARY_DIR = $(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk -STEPTALK_ENVDEFS_DIR = $(STEPTALK_LIBRARY_DIR)/Environments +StepTalk_RESOURCE_FILES = ScriptingInfo.plist Environments ADDITIONAL_CPPFLAGS += -pipe ADDITIONAL_OBJCFLAGS = -Wno-import -DSTEPTALK_VERSION=$(STEPTALK_VERSION) diff --git a/Frameworks/StepTalk/GNUmakefile.postamble b/Frameworks/StepTalk/GNUmakefile.postamble index 10efca9..5362423 100644 --- a/Frameworks/StepTalk/GNUmakefile.postamble +++ b/Frameworks/StepTalk/GNUmakefile.postamble @@ -34,25 +34,17 @@ # after-all:: # Things to do before installing -before-install:: - $(MKDIRS) $(STEPTALK_LIBRARY_DIR) - $(MKDIRS) $(STEPTALK_ENVDEFS_DIR) +# before-install:: +# $(MKDIRS) $(STEPTALK_LIBRARY_DIR) # Things to do after installing -after-install:: - @(echo Copying scripting environments...; \ - cd Environments;\ - for file in *.stenv; do \ - $(INSTALL_DATA) $$file $(STEPTALK_ENVDEFS_DIR)/$$file ; \ - done;\ - ) +# after-install:: # Things to do before uninstalling # before-uninstall:: # Things to do after uninstalling -after-uninstall:: - rm -rf $(STEPTALK_ENVDEFS_DIR) +# after-uninstall:: # Things to do before cleaning # before-clean:: diff --git a/Frameworks/StepTalk/STContext.h b/Frameworks/StepTalk/STContext.h new file mode 100644 index 0000000..3ebc969 --- /dev/null +++ b/Frameworks/StepTalk/STContext.h @@ -0,0 +1,69 @@ +/** + STContext + Scripting context + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2004 + + This file is part of the StepTalk project. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + STEnvironment class reference + + */ + +#import + +@class NSBundle; +@class NSDictionary; +@class NSMutableDictionary; +@class NSMutableArray; +@class NSMutableSet; + +@class STObjectReference; +@class STEnvironmentDescription; + +@interface STContext:NSObject +{ + NSMutableDictionary *objectDictionary; + STContext *parentContext; + BOOL fullScripting; + BOOL createsUnknownObjects; +} + +- (void)setParentContext:(STContext *)context; +- (STContext *)parentContext; + +/** Full scripting */ +- (void)setFullScriptingEnabled:(BOOL)flag; +- (BOOL)fullScriptingEnabled; + +-(void)setCreatesUnknownObjects:(BOOL)flag; +-(BOOL)createsUnknownObjects; + +- (NSMutableDictionary *)objectDictionary; +- (void)setObject:(id)anObject + forName:(NSString *)objName; +- (void)removeObjectWithName:(NSString *)objName; +- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict; +- (id)objectWithName:(NSString *)objName; + +- (STObjectReference *)objectReferenceForObjectWithName:(NSString *)name; + +- (NSArray *)knownObjectNames; +@end diff --git a/Frameworks/StepTalk/STContext.m b/Frameworks/StepTalk/STContext.m new file mode 100644 index 0000000..4589e05 --- /dev/null +++ b/Frameworks/StepTalk/STContext.m @@ -0,0 +1,217 @@ +/** + STContext + Scripting context + + Copyright (c) 2004 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2004 + + This file is part of the StepTalk project. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + STEnvironment class reference + + */ + +#import "STContext.h" + +#import "STScripting.h" +#import "STClassInfo.h" +#import "STEnvironmentDescription.h" +#import "STExterns.h" +#import "STFunctions.h" +#import "STBundleInfo.h" +#import "STObjCRuntime.h" +#import "STObjectReference.h" +#import "STUndefinedObject.h" + +#import +#import +#import +#import +#import +#import +#import +#import + +@implementation STContext +-init +{ + self = [super init]; + + objectDictionary = [[NSMutableDictionary alloc] init]; + + return self; +} + +- (void)dealloc +{ + RELEASE(objectDictionary); + RELEASE(parentContext); + [super dealloc]; +} + +- (void)setParentContext:(STContext *)context +{ + ASSIGN(parentContext, context); +} +- (STContext *)parentContext +{ + return parentContext; +} + +/** + Enable or disable full scripting. When full scripting is enabled, + you may send any message to any object. + */ +- (void)setFullScriptingEnabled:(BOOL)flag +{ + fullScripting = flag; +} + +/** + Returns YES if full scripting is enabled. + */ +- (BOOL)fullScriptingEnabled +{ + return fullScripting; +} + +/** +

+ Enable or disable creation of unknown objects. Normally you get nil if you + request for non-existant object. If flag is YES + then by requesting non-existant object, name for that object is created + and it is set no STNil. +

+

+ Note: This method will be probably removed (moved to Smalltalk language bundle). +

+ */ +-(void)setCreatesUnknownObjects:(BOOL)flag +{ + createsUnknownObjects = flag; +} + +/** + Returns YES if unknown objects are being created. + */ +-(BOOL)createsUnknownObjects +{ + return createsUnknownObjects; +} + +/** + Returns a dictionary of all named objects in the environment. +*/ +- (NSMutableDictionary *)objectDictionary +{ + return objectDictionary; +} + +/* ----------------------------------------------------------------------- + Objects + ----------------------------------------------------------------------- */ + +/** + Register object anObject with name objName. + */ + +- (void)setObject:(id)anObject + forName:(NSString *)objName +{ + if(anObject) + { + [objectDictionary setObject:anObject forKey:objName]; + } + else + { + [objectDictionary setObject:STNil forKey:objName]; + } +} + +/** + Remove object named objName. + */ +- (void)removeObjectWithName:(NSString *)objName +{ + [objectDictionary removeObjectForKey:objName]; +} + +/** + + */ +- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict +{ + [objectDictionary addEntriesFromDictionary:dict]; +} + +/** + Return object with name objName. 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, nil is + returned. + */ + +- (id)objectWithName:(NSString *)objName +{ + id obj; + + obj = [objectDictionary objectForKey:objName]; + + if(!obj) + { + return [parentContext objectWithName:objName]; + } + + return obj; +} + +- (STObjectReference *)objectReferenceForObjectWithName:(NSString *)name +{ + STObjectReference *ref; + id target = objectDictionary; + + if( ![self objectWithName:name] ) + { + if([[self knownObjectNames] containsObject:name]) + { + /* FIXME: What I meant by this? */ + target = nil; + } + else if(createsUnknownObjects) + { + [objectDictionary setObject:STNil forKey:name]; + } + } + + ref = [[STObjectReference alloc] initWithIdentifier:name + target:target]; + + return AUTORELEASE(ref); +} + +- (NSArray *)knownObjectNames +{ + NSMutableArray *array = [NSMutableArray array]; + + [array addObjectsFromArray:[objectDictionary allKeys]]; + + return [NSArray arrayWithArray:array]; +} +@end diff --git a/Frameworks/StepTalk/STConversation.h b/Frameworks/StepTalk/STConversation.h index b300a46..c713e4c 100644 --- a/Frameworks/StepTalk/STConversation.h +++ b/Frameworks/StepTalk/STConversation.h @@ -28,7 +28,7 @@ @class STLanguage; @class STEngine; -@class STEnvironment; +@class STContext; @interface STConversation:NSObject { @@ -37,18 +37,22 @@ + conversationWithApplication:(NSString *)appName language:(NSString *)langName; */ -+ conversationWithEnvironment:(STEnvironment *)env - language:(NSString *)langName; - -- initWithEnvironment:(STEnvironment *)env - language:(NSString *)aString; +/* ++ conversationWithContext:(STContext *)aContext + language:(NSString *)aLanguage; +*/ +- initWithContext:(STContext *)aContext + language:(NSString *)aLanguage; - (void)setLanguage:(NSString *)newLanguage; - (NSString *)language; -- (STEnvironment *)environment; +- (STContext *)context; + - (BOOL)isResumable; - (BOOL)resume; - (id)runScriptFromString:(NSString *)aString; + +- (NSArray *)knownLanguages; @end diff --git a/Frameworks/StepTalk/STConversation.m b/Frameworks/StepTalk/STConversation.m index f731c66..538c655 100644 --- a/Frameworks/StepTalk/STConversation.m +++ b/Frameworks/StepTalk/STConversation.m @@ -3,7 +3,7 @@ Copyright (c) 2002 Free Software Foundation - Written by: Stefan Urbanek + Written by: Stefan Urbanek Date: 2003 Sep 21 This file is part of the StepTalk project. @@ -28,20 +28,20 @@ #import -#import "STEngine.h" #import "STEnvironment.h" +#import "STEngine.h" #import "STLanguage.h" // FIXME: add these two: // @class STDistantEnvironment; // @class STDistantConversation; -@interface STConcreteLocalConversation:NSObject +@interface STConcreteLocalConversation:STConversation { STLanguage *lanuage; STEngine *engine; NSString *languageName; - STEnvironment *environment; + STContext *context; } @end @@ -52,7 +52,8 @@ { STEnvironment *env = [STEnvironment environmentWithDefaultDescription]; - return AUTORELEASE([[self alloc] initWithEnvironment:env language:nil]); + NSLog(@"DEPRECATED"); + return AUTORELEASE([[self alloc] initWithContext:env language:nil]); } /** Creates a new conversation with environment created using default description and language with name langName. */ @@ -61,6 +62,7 @@ { STConversation *c; + NSLog(@"Warning: conversationWithEnvironment:language: is deprecated"); /* FIXME: use this: if([env isKindOfClass:[STDistantEnvironment class]]) { @@ -71,17 +73,26 @@ c = [[STConcreteLocalConversation alloc] initWithEnvironment:env language:langName]; } */ - c = [[STConcreteLocalConversation alloc] initWithEnvironment:env language:langName]; + c = [[STConcreteLocalConversation alloc] initWithContext:env language:langName]; return AUTORELEASE(c); } - initWithEnvironment:(STEnvironment *)env language:(NSString *)langName +{ + NSLog(@"Warning: initWithEnvironment:language: is deprecated"); + + return [self initWithContext:env language:langName]; +} + +- initWithContext:(STContext *)aContext + language:(NSString *)aLanguage { [self dealloc]; - return [[STConcreteLocalConversation alloc] initWithEnvironment:env language:langName]; + return [[STConcreteLocalConversation alloc] initWithContext:aContext + language:aLanguage]; } - (void)setLanguage:(NSString *)newLanguage @@ -97,6 +108,8 @@ } - (STEnvironment *)environment { + NSLog(@"Warning: -environment in STConversation is deprecated, use -context"); + [self subclassResponsibility:_cmd]; return nil; } @@ -114,6 +127,14 @@ [self subclassResponsibility:_cmd]; return NO; } + +/** Returns all languages that are known in the receiver. Should be used by + remote calls instead of NSLanguage query which gives local list of + languages. */ +- (NSArray *)knownLanguages +{ + return [STLanguage allLanguageNames]; +} @end @implementation STConcreteLocalConversation @@ -123,40 +144,45 @@ language:(NSString *)langName { STConversation *c; - c = [[self alloc] initWithEnvironment:env language:langName]; + + NSLog(@"WARNING: +[STConversaion conversationWithEnvironment:language:] is deprecated, " + @" use conversationWithContext:language: instead."); + + c = [[self alloc] initWithContext:env language:langName]; return AUTORELEASE(c); } - initWithEnvironment:(STEnvironment *)env language:(NSString *)langName +{ + NSLog(@"WARNING: -[STConversaion initWithEnvironment:language:] is deprecated, " + @" use initWithContext:language: instead."); + + return [self initWithContext:env language:langName]; +} + +- initWithContext:(STContext *)aContext + language:(NSString *)aLanguage { self = [super init]; - if(!env) - { - [NSException raise:@"STConversationException" - format:@"Unspecified environment for a conversation"]; - [self dealloc]; - return nil; - } - - if(!langName || [langName isEqual:@""]) + if(!aLanguage || [aLanguage isEqual:@""]) { languageName = RETAIN([STLanguage defaultLanguageName]); } else { - languageName = RETAIN(langName); + languageName = RETAIN(aLanguage); } - environment = RETAIN(env); + context = RETAIN(aContext); return self; } - (void)dealloc { RELEASE(languageName); - RELEASE(environment); + RELEASE(context); RELEASE(engine); [super dealloc]; } @@ -183,14 +209,22 @@ } - (STEnvironment *)environment { - return environment; + NSLog(@"WARNING: -[STConversaion environment] is deprecated, " + @" use -context instead."); + + return context; } +- (STContext *)context +{ + return context; +} + - (id)runScriptFromString:(NSString *)aString { if(!engine) { [self _createEngine]; } - return [engine executeCode: aString inEnvironment:environment]; + return [engine executeCode: aString inEnvironment:context]; } @end diff --git a/Frameworks/StepTalk/STEnvironment.h b/Frameworks/StepTalk/STEnvironment.h index 8ce3f76..75bf606 100644 --- a/Frameworks/StepTalk/STEnvironment.h +++ b/Frameworks/StepTalk/STEnvironment.h @@ -27,7 +27,7 @@ */ -#import +#import @class NSBundle; @class NSDictionary; @@ -38,16 +38,11 @@ @class STObjectReference; @class STEnvironmentDescription; -@interface STEnvironment:NSObject +@interface STEnvironment:STContext { - NSMutableDictionary *defaultPool; - STEnvironmentDescription *description; NSMutableDictionary *classes; /* from description */ - BOOL fullScripting; - BOOL createsUnknownObjects; - NSMutableDictionary *infoCache; NSMutableDictionary *objectFinders; @@ -63,14 +58,6 @@ - initWithDefaultDescription; - initWithDescription:(bycopy STEnvironmentDescription *)aDescription; -/** Full scripting */ - -- (void)setFullScriptingEnabled:(BOOL)flag; -- (BOOL)fullScriptingEnabled; - --(void)setCreatesUnknownObjects:(BOOL)flag; --(BOOL)createsUnknownObjects; - /** Modules */ - (void)loadModule:(NSString *)moduleName; @@ -80,22 +67,10 @@ - (void)addClassesWithNames:(NSArray *)names; -/** Named objects and object references */ - -- (NSMutableDictionary *)objectDictionary; -- (void)setObject:(id)anObject - forName:(NSString *)objName; -- (void)removeObjectWithName:(NSString *)objName; -- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict; -- (id)objectWithName:(NSString *)objName; - -- (STObjectReference *)objectReferenceForObjectWithName:(NSString *)name; - /** Distributed objects */ - (void)registerObjectFinder:(id)finder name:(NSString*)name; - (void)registerObjectFinderNamed:(NSString *)name; - (void)removeObjectFinderWithName:(NSString *)name; -- (NSArray *)knownObjectNames; /** Selector translation */ diff --git a/Frameworks/StepTalk/STEnvironment.m b/Frameworks/StepTalk/STEnvironment.m index 9ff0bf6..ee90772 100644 --- a/Frameworks/StepTalk/STEnvironment.m +++ b/Frameworks/StepTalk/STEnvironment.m @@ -145,7 +145,6 @@ STEnvironment *sharedEnvironment = nil; self = [super init]; - defaultPool = [[NSMutableDictionary alloc] init]; infoCache = [[NSMutableDictionary alloc] init]; description = RETAIN(aDescription); @@ -192,7 +191,6 @@ STEnvironment *sharedEnvironment = nil; - (void)dealloc { - RELEASE(defaultPool); RELEASE(description); RELEASE(infoCache); @@ -202,46 +200,6 @@ STEnvironment *sharedEnvironment = nil; [super dealloc]; } -/** - Enable or disable full scripting. When full scripting is enabled, - you may send any message to any object. - */ -- (void)setFullScriptingEnabled:(BOOL)flag -{ - fullScripting = flag; -} - -/** - Returns YES if full scripting is enabled. - */ -- (BOOL)fullScriptingEnabled -{ - return fullScripting; -} - -/** -

- Enable or disable creation of unknown objects. Normally you get nil if you - request for non-existant object. If flag is YES - then by requesting non-existant object, name for that object is created - and it is set no STNil. -

-

- Note: This method will be probably removed (moved to Smalltalk language bundle). -

- */ --(void)setCreatesUnknownObjects:(BOOL)flag -{ - createsUnknownObjects = flag; -} - -/** - Returns YES if unknown objects are being created. - */ --(BOOL)createsUnknownObjects -{ - return createsUnknownObjects; -} /** Add classes specified by the names in the names array. @@ -323,51 +281,10 @@ STEnvironment *sharedEnvironment = nil; return YES; } -/** - Returns a dictionary of all named objects in the environment. -*/ -- (NSMutableDictionary *)objectDictionary -{ - return defaultPool; -} - /* ----------------------------------------------------------------------- Objects ----------------------------------------------------------------------- */ -/** - Register object anObject with name objName. - */ - -- (void)setObject:(id)anObject - forName:(NSString *)objName -{ - if(anObject) - { - [defaultPool setObject:anObject forKey:objName]; - } - else - { - [defaultPool setObject:STNil forKey:objName]; - } -} - -/** - Remove object named objName. - */ -- (void)removeObjectWithName:(NSString *)objName -{ - [defaultPool removeObjectForKey:objName]; -} - -/** - - */ -- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict -{ - [defaultPool addEntriesFromDictionary:dict]; -} - /** Return object with name objName. If object is not found int the object dictionary, then object finders are used to try to find the object. @@ -382,7 +299,7 @@ STEnvironment *sharedEnvironment = nil; id obj; id finder; - obj = [defaultPool objectForKey:objName]; + obj = [super objectWithName:objName]; if(!obj) { @@ -392,7 +309,7 @@ STEnvironment *sharedEnvironment = nil; obj = [finder objectWithName:objName]; if(obj) { - [defaultPool setObject:obj forKey:objName]; + [self setName:objName forObject:obj]; break; } } @@ -401,31 +318,6 @@ STEnvironment *sharedEnvironment = nil; return obj; } -- (STObjectReference *)objectReferenceForObjectWithName:(NSString *)name -{ - STObjectReference *ref; - id pool = defaultPool; - - if( ![self objectWithName:name] ) - { - if([[self knownObjectNames] containsObject:name]) - { - pool = nil; - } - else if(createsUnknownObjects) - { - [defaultPool setObject:STNil forKey:name]; - } - } - - ref = [STObjectReference alloc]; - - [ref initWithObjectName:name - pool:defaultPool]; - - return AUTORELEASE(ref); -} - /* FIXME: rewrite, it is too sloooooow */ - (STClassInfo *)findClassInfoForObject:(id)anObject { @@ -589,7 +481,7 @@ STEnvironment *sharedEnvironment = nil; NSEnumerator *enumerator; id finder; - [array addObjectsFromArray:[defaultPool allKeys]]; + [array addObjectsFromArray:[super knownObjectNames]]; enumerator = [objectFinders objectEnumerator]; while( (finder = [enumerator nextObject]) ) diff --git a/Frameworks/StepTalk/STFunctions.m b/Frameworks/StepTalk/STFunctions.m index e5d0bb2..21f3f61 100644 --- a/Frameworks/StepTalk/STFunctions.m +++ b/Frameworks/StepTalk/STFunctions.m @@ -30,11 +30,13 @@ #import "STExterns.h" #import +#import #import #import #import #import +@class STContext; NSString *STFindResource(NSString *name, NSString *resourceDir, @@ -57,19 +59,23 @@ NSString *STFindResource(NSString *name, file = [file stringByAppendingPathComponent:resourceDir]; file = [file stringByAppendingPathComponent:name]; - if( [manager fileExistsAtPath:file isDirectory:NO] ) + if( [manager fileExistsAtPath:file] ) { return file; } file = [file stringByAppendingPathExtension:extension]; - if( [manager fileExistsAtPath:file isDirectory:NO] ) + if( [manager fileExistsAtPath:file] ) { return file; } } - return nil; + + return [[NSBundle bundleForClass:[STContext class]] + pathForResource:name + ofType:extension + inDirectory:resourceDir]; } NSArray *STFindAllResources(NSString *resourceDir, NSString *extension) diff --git a/Frameworks/StepTalk/STLanguage.m b/Frameworks/StepTalk/STLanguage.m index fb596c4..3d45979 100644 --- a/Frameworks/StepTalk/STLanguage.m +++ b/Frameworks/StepTalk/STLanguage.m @@ -124,6 +124,8 @@ static NSDictionary *fileTypeDictionary = nil; path = [path stringByAppendingPathComponent:STLanguagesConfigFile]; + /* FIXME: use defaults instead. calling task with given argument is a bug*/ + if( ![fm fileExistsAtPath:path]) { NSLog(@"Creating lanugages configuration file..."); diff --git a/Frameworks/StepTalk/STObjectReference.h b/Frameworks/StepTalk/STObjectReference.h index 874fe6a..bc360ef 100644 --- a/Frameworks/StepTalk/STObjectReference.h +++ b/Frameworks/StepTalk/STObjectReference.h @@ -27,24 +27,20 @@ #import @class NSString; -@class NSMutableDictionary; @interface STObjectReference:NSObject { - NSString *key; - NSMutableDictionary *pool; + NSString *identifier; + id target; } -- initWithObjectName:(NSString *)name - pool:(NSMutableDictionary *)aPool; +- initWithIdentifier:(NSString *)ident + target:(id)anObject; - (void)setObject:anObject; -- object; +- (id)object; -- (NSString *)objectName; -- (void)setObjectName:(NSString *)newName; - -- (NSMutableDictionary *) pool; -- (void)setPool:(NSMutableDictionary *) aDict; +- (NSString *)identifier; +- (id) target; @end diff --git a/Frameworks/StepTalk/STObjectReference.m b/Frameworks/StepTalk/STObjectReference.m index 6e96739..c0b1847 100644 --- a/Frameworks/StepTalk/STObjectReference.m +++ b/Frameworks/StepTalk/STObjectReference.m @@ -34,57 +34,43 @@ #import @implementation STObjectReference -- initWithObjectName:(NSString *)name pool:(NSMutableDictionary *)aPool +- initWithIdentifier:(NSString *)ident + target:(id)anObject; { self = [super init]; + identifier = [ident copy]; + target = RETAIN(anObject); - key = RETAIN(name); - pool = RETAIN(aPool); - return self; -} - +} - (void)dealloc { - RELEASE(key); - RELEASE(pool); + RELEASE(identifier); + RELEASE(target); [super dealloc]; } +- (NSString *)identifier +{ + return identifier; +} +- (id) target +{ + return target; +} - (void)setObject:anObject { - if(anObject) + if(!anObject) { - [pool setObject:anObject forKey:key]; + anObject = STNil; } - else - { - [pool setObject:STNil forKey:key]; - } -} + [(NSMutableDictionary *)target setObject:anObject forKey:identifier]; +} - object { - return [pool objectForKey:key]; -} - -- (NSString *)objectName -{ - return key; -} -- (void)setObjectName:(NSString *)newName -{ - ASSIGN(key,newName); -} - -- (NSMutableDictionary *) pool -{ - return pool; -} -- (void)setPool:(NSMutableDictionary *) aDict -{ - ASSIGN(pool,aDict); + return [(NSDictionary *)target objectForKey:identifier]; } @end diff --git a/Frameworks/StepTalk/ScriptingInfo.plist b/Frameworks/StepTalk/ScriptingInfo.plist index 764b7a4..4dfac15 100644 --- a/Frameworks/StepTalk/ScriptingInfo.plist +++ b/Frameworks/StepTalk/ScriptingInfo.plist @@ -8,6 +8,8 @@ STScriptsManager, STBundleInfo, STEngine, - STScriptObject + STScriptObject, + STConversation, + STContext ); } diff --git a/Languages/Smalltalk/ChangeLog b/Languages/Smalltalk/ChangeLog index 748f468..58d8eb2 100644 --- a/Languages/Smalltalk/ChangeLog +++ b/Languages/Smalltalk/ChangeLog @@ -3,6 +3,11 @@ * Remove STMethodSignatureForSelector as it was deprecated because of inportability to OSX. +2004 Nov 2 Stefan Urbanek + + * Changed super of STBytecodes from NSData to NSObject - there were some + OSX issues + 2004 Jul 10 Stefan Urbanek * Applied patch from Alexander V. Diemand (fixed bug #9595) - fixed diff --git a/Languages/Smalltalk/STBytecodes.h b/Languages/Smalltalk/STBytecodes.h index 4cb274e..c448015 100644 --- a/Languages/Smalltalk/STBytecodes.h +++ b/Languages/Smalltalk/STBytecodes.h @@ -21,7 +21,7 @@ */ -#import +#import /* Bytecode table */ @@ -82,7 +82,7 @@ extern NSArray *STBytecodeNames; extern NSString *STBytecodeName(unsigned short code); extern NSString *STDissasembleBytecode(STBytecode bytecode); -@interface STBytecodes:NSData +@interface STBytecodes:NSObject { NSData *bytes; } diff --git a/Languages/Smalltalk/STBytecodes.m b/Languages/Smalltalk/STBytecodes.m index cdf085b..2591894 100644 --- a/Languages/Smalltalk/STBytecodes.m +++ b/Languages/Smalltalk/STBytecodes.m @@ -176,14 +176,22 @@ NSString *STDissasembleBytecode(STBytecode bytecode) return self; } */ -- (id) initWithBytes: (const void*)someBytes - length: (unsigned int)length + +/* FIXME: rewrite this class - it is a leftover */ + +- (id) initWithData: (NSData *)data { - bytes = [[NSData alloc] initWithBytes:someBytes - length:length]; + self = [super init]; + + bytes = RETAIN(data); + return self; } +- (NSData *)data +{ + return bytes; +} - (void)dealloc { RELEASE(bytes); diff --git a/Languages/Smalltalk/STCompiledMethod.m b/Languages/Smalltalk/STCompiledMethod.m index 39be0a0..6a9b920 100644 --- a/Languages/Smalltalk/STCompiledMethod.m +++ b/Languages/Smalltalk/STCompiledMethod.m @@ -45,7 +45,7 @@ [method initWithSelector:[pattern selector] argumentCount:[[pattern arguments] count] - bytecodesData:[code bytecodes] + bytecodesData:[[code bytecodes] data] literals:[code literals] temporariesCount:[code temporariesCount] stackSize:[code stackSize] diff --git a/Languages/Smalltalk/STCompiler.m b/Languages/Smalltalk/STCompiler.m index ef247cf..92a45e9 100644 --- a/Languages/Smalltalk/STCompiler.m +++ b/Languages/Smalltalk/STCompiler.m @@ -34,7 +34,6 @@ #import "Externs.h" #import -#import #import #import diff --git a/Tools/STEnvironmentProcess.h b/Tools/STEnvironmentProcess.h index 3427b3b..9a7bda6 100644 --- a/Tools/STEnvironmentProcess.h +++ b/Tools/STEnvironmentProcess.h @@ -1,6 +1,9 @@ #import +@class STConversation; + @interface STEnvironmentProcess:NSObject { } +- (STConversation *)createConversaion; @end diff --git a/Tools/stalk.m b/Tools/stalk.m index 4e85b0e..04340e3 100644 --- a/Tools/stalk.m +++ b/Tools/stalk.m @@ -116,7 +116,7 @@ [env setObject:target forName:objectName]; - conversation = [[STConversation alloc] initWithEnvironment:env + conversation = [[STConversation alloc] initWithContext:env language:nil]; } diff --git a/Tools/stexec.m b/Tools/stexec.m index 69eb1df..8eb24e2 100644 --- a/Tools/stexec.m +++ b/Tools/stexec.m @@ -69,8 +69,8 @@ /* FIXME: remove this or use some command-line flag */ [env setFullScriptingEnabled:enableFull]; - conversation = [[STConversation alloc] initWithEnvironment:env - language:nil]; + conversation = [[STConversation alloc] initWithContext:env + language:nil]; } - (int)processOption:(NSString *)option diff --git a/Tools/stupdate_languages.m b/Tools/stupdate_languages.m index e0f7c77..483749d 100644 --- a/Tools/stupdate_languages.m +++ b/Tools/stupdate_languages.m @@ -101,6 +101,11 @@ void update_languages(void) path = [path stringByAppendingPathComponent:STLanguagesConfigFile]; [dict writeToFile:path atomically:YES]; + + if([dict count] == 0) + { + NSLog(@"No StepTalk language bundles found."); + } }