From ecd3a33b3fee0ed2c5a9287ae7c5707ef1e0e0e6 Mon Sep 17 00:00:00 2001 From: Stefan Urbanek Date: Mon, 24 Nov 2003 09:43:42 +0000 Subject: [PATCH] Compiler warnings cleanup, Shell fixed git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@18145 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 ++ Examples/Shell/STShell.h | 1 - Examples/Shell/STShell.m | 29 +++++++----- Frameworks/StepTalk/NSInvocation+additions.h | 1 + Frameworks/StepTalk/NSInvocation+additions.m | 25 ++++++++++ Frameworks/StepTalk/STConversation.h | 8 +++- Frameworks/StepTalk/STConversation.m | 3 +- Frameworks/StepTalk/STFileScript.h | 2 +- Frameworks/StepTalk/STSelector.h | 6 ++- Frameworks/StepTalk/STSelector.m | 49 ++++++++++++++++++-- TODO | 43 +++++++++++------ Tools/stalk.m | 1 - Version | 2 +- 13 files changed, 136 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index b815314..5d791b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003 Nov 24 Stefan Urbanek + + * Few fixes, removed some compiler warnings. Fixed Shell to use + proper environment. + 2003 Nov 8 Stefan Urbanek * Updated tools to use STConversation object. diff --git a/Examples/Shell/STShell.h b/Examples/Shell/STShell.h index 247ab2c..b8418cb 100644 --- a/Examples/Shell/STShell.h +++ b/Examples/Shell/STShell.h @@ -36,7 +36,6 @@ @interface STShell:NSObject { STScriptsManager *scriptsManager; - STEnvironment *env; STConversation *conversation; NSString *prompt; diff --git a/Examples/Shell/STShell.m b/Examples/Shell/STShell.m index 3e7ee5b..cbd2fd1 100644 --- a/Examples/Shell/STShell.m +++ b/Examples/Shell/STShell.m @@ -142,18 +142,19 @@ int complete_handler(void) - (void)setEnvironment:(STEnvironment *)newEnv { - ASSIGN(env, newEnv); + [conversation setEnvironment:newEnv]; } - (STEnvironment *)environment { - return env; + return [conversation environment]; } - (void)run { - NSString *line; - id result; + STEnvironment *env = [conversation environment]; + NSString *line; + id result; [env setCreatesUnknownObjects:YES]; @@ -169,6 +170,8 @@ int complete_handler(void) [self showLine:@"Welcome to the StepTalk shell."]; + NSLog(@"Environment %@", env); + while(1) { line = [self readLine]; @@ -199,8 +202,9 @@ int complete_handler(void) } - (id)executeLine:(NSString *)line { - NSString *cmd; - id result = nil; + STEnvironment *env = [conversation environment]; + NSString *cmd; + id result = nil; /* FIXME: why? */ @@ -257,12 +261,13 @@ int complete_handler(void) - (int)completion { - NSEnumerator *enumerator; - NSMutableSet *set; - NSString *match; - NSString *tail; - NSString *str; - NSArray *array; + STEnvironment *env = [conversation environment]; + NSEnumerator *enumerator; + NSMutableSet *set; + NSString *match; + NSString *tail; + NSString *str; + NSArray *array; int pos = 0; int c; diff --git a/Frameworks/StepTalk/NSInvocation+additions.h b/Frameworks/StepTalk/NSInvocation+additions.h index a1e2d30..a47a077 100644 --- a/Frameworks/StepTalk/NSInvocation+additions.h +++ b/Frameworks/StepTalk/NSInvocation+additions.h @@ -32,6 +32,7 @@ id STObjectFromValueOfType(void *value, const char *type); @interface NSInvocation(STAdditions) + invocationWithTarget:(id)target selectorName:(NSString *)selectorName; ++ invocationWithTarget:(id)target selector:(SEL)selector; - (void)setArgumentAsObject:(id)anObject atIndex:(int)anIndex; - (id)getArgumentAsObjectAtIndex:(int)anIndex; diff --git a/Frameworks/StepTalk/NSInvocation+additions.m b/Frameworks/StepTalk/NSInvocation+additions.m index 69cbc78..afadb85 100644 --- a/Frameworks/StepTalk/NSInvocation+additions.m +++ b/Frameworks/StepTalk/NSInvocation+additions.m @@ -257,6 +257,31 @@ void STGetValueOfTypeFromObject(void *value, const char *type, id anObject) return invocation; } ++ invocationWithTarget:(id)target selector:(SEL)selector +{ + NSMethodSignature *signature; + NSInvocation *invocation; + + signature = [target methodSignatureForSelector:selector]; + + + if(!signature) + { + [NSException raise:STInternalInconsistencyException + format:@"No method signature for selector '%@' for " + @"receiver of type %@", + NSStringFromSelector(selector),[target className]]; + return nil; + } + + invocation = [NSInvocation invocationWithMethodSignature:signature]; + + [invocation setSelector:selector]; + [invocation setTarget:target]; + + return invocation; +} + - (void)setArgumentAsObject:(id)anObject atIndex:(int)anIndex { const char *type; diff --git a/Frameworks/StepTalk/STConversation.h b/Frameworks/StepTalk/STConversation.h index 7ccd933..a5bf91c 100644 --- a/Frameworks/StepTalk/STConversation.h +++ b/Frameworks/StepTalk/STConversation.h @@ -37,8 +37,12 @@ NSString *languageName; STEnvironment *environment; } -+ conversationInEnvironment:(STEnvironment *)env - language:(NSString *)langName; +/* ++ conversationWithApplication:(NSString *)appName + language:(NSString *)langName; +*/ ++ conversationWithEnvironment:(STEnvironment *)env + language:(NSString *)langName; - initWithEnvironment:(STEnvironment *)env language:(NSString *)aString; diff --git a/Frameworks/StepTalk/STConversation.m b/Frameworks/StepTalk/STConversation.m index 6a732a7..3219f9b 100644 --- a/Frameworks/StepTalk/STConversation.m +++ b/Frameworks/StepTalk/STConversation.m @@ -43,7 +43,7 @@ } /** Creates a new conversation with environment created using default description and language with name langName. */ -+ conversationInEnvironment:(STEnvironment *)env ++ conversationWithEnvironment:(STEnvironment *)env language:(NSString *)langName { STConversation *c; @@ -114,6 +114,7 @@ { [self _createEngine]; } + NSLog(@"Run script in %@", environment); return [engine executeCode: aString inEnvironment:environment]; } @end diff --git a/Frameworks/StepTalk/STFileScript.h b/Frameworks/StepTalk/STFileScript.h index b68c3bc..ea2ef46 100644 --- a/Frameworks/StepTalk/STFileScript.h +++ b/Frameworks/StepTalk/STFileScript.h @@ -40,5 +40,5 @@ - (NSString *)scriptName; - (NSString *)localizedName; - (NSString *)scriptDescription; -- (NSComparisonResult)compareByLocalizedName:(STScript *)aScript; +- (NSComparisonResult)compareByLocalizedName:(STFileScript *)aScript; @end diff --git a/Frameworks/StepTalk/STSelector.h b/Frameworks/StepTalk/STSelector.h index 3b769a1..98170d9 100644 --- a/Frameworks/StepTalk/STSelector.h +++ b/Frameworks/StepTalk/STSelector.h @@ -28,11 +28,13 @@ @interface STSelector:NSObject { - SEL sel; + NSString *selectorName; + SEL sel; } +- initWithName:(NSString *)aString; - initWithSelector:(SEL)aSel; - (SEL)selectorValue; -- (NSString *)stringValue; +- (NSString *)selectorName; @end diff --git a/Frameworks/StepTalk/STSelector.m b/Frameworks/StepTalk/STSelector.m index f5e9cf4..56f183f 100644 --- a/Frameworks/StepTalk/STSelector.m +++ b/Frameworks/StepTalk/STSelector.m @@ -25,27 +25,70 @@ */ #import "STSelector.h" +#import "STObjCRuntime.h" + +#import +#import @implementation STSelector +- initWithName:(NSString *)aString +{ + [super init]; + + selectorName = RETAIN(aString); + + return self; +} + - initWithSelector:(SEL)aSel { [super init]; sel = aSel; return self; } +- (void)dealloc +{ + RELEASE(selectorName); + [super dealloc]; +} - (SEL)selectorValue { + if(sel == 0) + { + sel = STSelectorFromString(selectorName); + } return sel; } - (NSString *)description { - return NSStringFromSelector(sel); + return [NSString stringWithFormat:@"#%@", [self selectorName]]; } -- (NSString *)stringValue +- (NSString *)selectorName { - return NSStringFromSelector(sel); + if(!selectorName) + { + selectorName = RETAIN(NSStringFromSelector(sel)); + } + + return selectorName; +} + +- (void)encodeWithCoder:(NSCoder *)coder +{ + // [super encodeWithCoder: coder]; + + [coder encodeObject:selectorName]; +} + +- initWithCoder:(NSCoder *)decoder +{ + self = [super init]; // super initWithCoder: decoder]; + + [decoder decodeValueOfObjCType: @encode(id) at: &selectorName]; + + return self; } @end diff --git a/TODO b/TODO index 9ba8939..9242fe9 100644 --- a/TODO +++ b/TODO @@ -1,20 +1,33 @@ TODO list - 1 handle 'connection did die' notification for distant objects in STEnvironment - 2 fix class-info lookup for proxies in STEnvironment - 3 implement NSRect object - 5 Smalltalk: separate compiler and compilation context - 9 create a 'Shell' scripting environment -11 Create ApplicationScripting framework, instead of bundle. It should offer +HIGH PRIORITY + +- implement NSRect object +- Rewrite Smalltalk compiler (grammar) + + Remove STBytecodeInterpreter and use only STCompiler. How? + Simply convert language constructions into 'command' objects like + SmalltalkStatement, SmalltalkPrimary, SmalltalkMethodSend, ... + and implement executeInEnvironment:context:receiver: + +- Update application scripting to use STConversation + +LOW PRIORITY + +UNDEFINED + +- handle 'connection did die' notification for distant objects in STEnvironment +- fix class-info lookup for proxies in STEnvironment +- Smalltalk: separate compiler and compilation context +- create a 'Shell' scripting environment +- Create ApplicationScripting framework, instead of bundle. It should offer passive application scripting (without linking) and active app. scripting (linking with the framewotk). Give it some reasonable name, becauase that one is already used by Apple -13 Change source directory structure (see DevelopmentNotes.txt in Doumentation) -14 Add framework list into environment description -15 Change Modules to Framework -16 Remove StepTalk modules -17 Fill implementation of STScriptObject, STMethod and related STEngine methods -18 Rewrite Smalltalk compiler (grammar) -19 Remove empty directories (Source, Modules/StepTalk) -20 Replace STMethod languageName with map table of method class->engine class -21 Update application scripting to use STConversation +- Add framework list into environment description +- Change Modules to Frameworks +- Fill implementation of STScriptObject, STMethod and related STEngine methods +- Remove empty directories (Source, Modules/StepTalk) +- Replace STMethod languageName with map table of method class->engine class + + diff --git a/Tools/stalk.m b/Tools/stalk.m index 12eb197..f061279 100644 --- a/Tools/stalk.m +++ b/Tools/stalk.m @@ -97,7 +97,6 @@ after moving from STEngnie to STConversation */ - (void)createConversation { - STEnvironmentDescription *desc; STEnvironment *env; if([target respondsToSelector:@selector(scriptingEnvironment)]) diff --git a/Version b/Version index ceab5f4..861788f 100644 --- a/Version +++ b/Version @@ -4,7 +4,7 @@ # The version number of this release. MAJOR_VERSION=0 MINOR_VERSION=8 -SUBMINOR_VERSION=1 +SUBMINOR_VERSION=2 STEPTALK_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}