use remote scripting, reflect framework changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@21700 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Stefan Urbanek 2005-09-05 20:11:31 +00:00
parent 13f9ee9afc
commit 142ca84c8e
4 changed files with 120 additions and 47 deletions

View file

@ -1,3 +1,16 @@
2005 Aug 30
* use STLanguageManager instead of removed STLanguage
2005 Aug 15
* Added distant environments
* Removed named objects as they were causing troubles with distant
environments
* Suspend completion for distant environments
Warning: option 'environment' has different meaning. See stshell --help.
2003 Sep 21
* Added named objects FileManager, LastCommand and LastObject

View file

@ -47,6 +47,8 @@
BOOL updateCompletionList;
NSArray *completionList;
BOOL completionEnabled;
}
- initWithEnvironment:(STEnvironment *)env;

View file

@ -72,7 +72,7 @@ int complete_handler(void)
return sharedShell;
}
- initWithEnvironment:(STEnvironment *)env
- initWithConversation:(STConversation *)conv
{
self = [super init];
@ -89,7 +89,8 @@ int complete_handler(void)
scriptsManager = RETAIN([STScriptsManager defaultManager]);
prompt = @"StepTalk > ";
conversation = [[STConversation alloc] initWithContext:env language:nil];
conversation = RETAIN(conv);
/* FIXME: make this more clever for completion handler */
if(!sharedShell)
{
@ -152,26 +153,23 @@ int complete_handler(void)
- (void)run
{
STEnvironment *env = [conversation context];
STEnvironment *env;
NSString *line;
id result;
[env setCreatesUnknownObjects:YES];
/* Add standard objects */
[env setObject:self forName:@"Shell"];
[env setObject:self forName:@"Transcript"];
[env setObject:objectStack forName:@"Objects"];
[env setObject:[NSFileManager defaultManager] forName:@"FileManager"];
/* FIXME: This is unsafe !*/
[env setObject:env forName:@"Environment"];
[self showLine:@"Welcome to the StepTalk shell."];
// NSLog(@"Environment %@", env);
if(![conversation isKindOfClass:[STRemoteConversation class]])
{
completionEnabled = YES;
}
else
{
[self showLine:@"Note: Completion disabled for distant conversation"];
}
while(1)
{
line = [self readLine];
@ -202,7 +200,6 @@ int complete_handler(void)
}
- (id)executeLine:(NSString *)line
{
STEnvironment *env = [conversation context];
NSString *cmd;
id result = nil;
@ -210,14 +207,12 @@ int complete_handler(void)
cmd = [line stringByAppendingString:@" "];
NS_DURING
result = [conversation runScriptFromString:cmd];
[conversation interpretScript:cmd];
result = [conversation result];
NS_HANDLER
[self showException:localException];
NS_ENDHANDLER
[env setObject:line forName:@"LastCommand"];
[env setObject:result forName:@"LastObject"];
return result;
}
@ -261,7 +256,7 @@ int complete_handler(void)
- (int)completion
{
STEnvironment *env = [conversation context];
STEnvironment *env;
NSEnumerator *enumerator;
NSMutableSet *set;
NSString *match;
@ -271,6 +266,11 @@ int complete_handler(void)
int pos = 0;
int c;
if(!completionEnabled)
{
return 0;
}
if(rl_point <= 0)
{
return 0;
@ -305,6 +305,7 @@ int complete_handler(void)
}
}
env = [conversation context];
enumerator = [[env knownObjectNames] objectEnumerator];
while( (str = [enumerator nextObject]) )
{

View file

@ -38,11 +38,15 @@
@interface STShellTool:NSObject
{
NSArray *arguments;
unsigned int currentArg;
STConversation *conversation;
NSArray *arguments;
unsigned int currentArg;
NSString *envName;
NSString *languageName;
NSString *environmentName;
NSString *hostName;
NSString *typeName;
NSString *languageName;
}
- (int)parseArguments;
- (NSString *)nextArgument;
@ -92,14 +96,34 @@
}
else if ([@"environment" hasPrefix:arg])
{
RELEASE(envName);
envName = [self nextArgument];
if(!envName)
RELEASE(environmentName);
environmentName = [self nextArgument];
if(!environmentName)
{
[NSException raise:@"STShellToolException"
format:@"Environment name expected"];
}
}
else if ([@"host" hasPrefix:arg])
{
RELEASE(hostName);
hostName = [self nextArgument];
if(!hostName)
{
[NSException raise:@"STShellToolException"
format:@"Host name expected"];
}
}
else if ([@"type" hasPrefix:arg])
{
RELEASE(typeName);
typeName = [self nextArgument];
if(!typeName)
{
[NSException raise:@"STShellToolException"
format:@"Environment description (type) name expected"];
}
}
else if(!isOption)
{
break;
@ -128,36 +152,67 @@
{
currentArg--;
}
- (void)run
{
/* Method taken from stexec.m - look there for updates */
- (void)createConversation
{
STEnvironmentDescription *desc;
STEnvironment *env;
STShell *shell;
STEnvironment *environment;
[self parseArguments];
if(!envName || [envName isEqualToString:@""])
if(environmentName)
{
env = [STEnvironment environmentWithDefaultDescription];
/* user wants to connect to a distant environment */
conversation = [[STRemoteConversation alloc]
initWithEnvironmentName:environmentName
host:hostName
language:languageName];
if(!conversation)
{
NSLog(@"Unable to connect to %@@%@", environmentName, hostName);
return;
}
}
else
{
desc = [STEnvironmentDescription descriptionWithName:envName];
env = [STEnvironment environmentWithDescription:desc];
/* User wants local temporary environment */
if(!typeName || [typeName isEqualToString:@""])
{
environment = [STEnvironment environmentWithDefaultDescription];
}
else
{
desc = [STEnvironmentDescription descriptionWithName:typeName];
environment = [STEnvironment environmentWithDescription:desc];
}
/* Register basic objects: Environment, Transcript */
[environment setObject:environment forName:@"Environment"];
[environment loadModule:@"SimpleTranscript"];
[environment setCreatesUnknownObjects:YES];
/* FIXME: make this an option */
[environment setFullScriptingEnabled:YES];
conversation = [[STConversation alloc] initWithContext:environment
language:languageName];
}
}
/* FIXME: make this an option */
[env setFullScriptingEnabled:YES];
- (void)run
{
STShell *shell;
[self parseArguments];
[self createConversation];
shell = [[STShell alloc] initWithEnvironment:env];
if(!languageName || [languageName isEqualToString:@""])
{
languageName = [STLanguage defaultLanguageName];
languageName = [[STLanguageManager defaultManager] defaultLanguage];
}
[shell setLanguage:languageName];
[conversation setLanguage:languageName];
shell = [[STShell alloc] initWithConversation:conversation];
[shell run];
NSDebugLog(@"Exiting StepTalk shell");
@ -172,7 +227,9 @@
"Options are:\n"
" -help this text\n"
" -language lang use language lang\n"
" -environment env use scripting environment with name env\n",
" -environment env use scripting environment with name env\n"
" -host host find environment on host\n"
" -type desc use environment description with name 'desc'\n",
[[info processName] cString],[[info processName] cString]
);
}