libs-steptalk/Tools/stalk.m
David Ayers ddc9d205af * STEngine.h: Fixed declaration to match implementation to avoid
compiler warnings.
    * STEnvironment.h: Ditto.
    * STScriptsManager.h: Ditto.
    * STLanguage.h: Corrected declaration.
    * STScriptsManager.m: Added needed interface declaration.
    * GNUmakefile:  Added flags to show all warnings except for import.
    * Module/ObjectiveC/GNUmakefile:  Added flags to show all warnings
    except for import.
    * Module/Foundation/GNUmakefile:  Added flags to show all warnings
    except for import.
    * Module/AppKit/AppKitExceptions.m: Used variable to supress compiler
    warnings.
    * Module/AppKit/AppKitNotifications.m: Ditto.
    * Module/AppKit/GNUmakefile:  Added flags to show all warnings except
    for import.
    * Module/GDL2/GDL2Constants.m: Used variable to supress compiler
    warnings.
    * Module/GDL2/GNUmakefile: Added flags to show all warnings except
    for import.
    * Module/SimpleTranscripts/GNUmakefile: Added flags to show all warnings
    except for import.
    * Module/StepTalk/GNUmakefile: Added flags to show all warnings
    except for import.
    * Tools/stalk.m: Added needed interface declaration.
    * Tools/stupdate_languages.m: Corrected variable declaration and added
    cast.

ApplicationScripting
    * GNUmakefile: Added flags to be able to compile from the building
    directories and show all warnings except for import.
    * NSApplication+additions.m: Added import of needed headers.  Added
    interface declarations to supress compiler warnings.  Commented unused
    variables to supress compiler warnings.  Corrected variable types and
    added necessary casts.
    * STScriptingSupport.m: Added interface declaraions to supress
    compiler warnings.

Examples/Shell
    * GNUmakefile: Added flags to show all warnings except for import.
    * STShell.m: Unified name for private categories.

Examples/Server
    * ChangeLog: Added new file.
    * GNUmakefile: Added flags to show all warnings except for import.

Languages/Smalltalk/ChangeLog
    * GNUmakefile: Added flags to show all warnings except for import.
    * STBlock.m: Initialzed variables to supress compiler warnings.
    * STCompiledMethod.m: Added needed import.
    * STCompiler.m: Added missing declaration.  Wrapped declarations only
    needed for DEBUG into #ifdefs to supress compiler warnings.
    Initialzed variables to supress compiler warnings.
    * STExecutionContext.m: Unified name for private categories.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@16351 72102866-910b-0410-8b05-ffd578937521
2003-04-04 10:57:04 +00:00

179 lines
4.4 KiB
Objective-C

/**
stalk.m
Program for 'talking' to scriptable objects
Copyright (c) 2002 Free Software Foundation
Written by: Stefan Urbanek <urbanek@host.sk>
Date: 2000
This file is part of the StepTalk project.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA.
*/
#import "STExecutor.h"
#import <StepTalk/StepTalk.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSConnection.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSException.h>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSString.h>
#import <Foundation/NSFileManager.h>
@interface NSObject (STPrivateMethodDeclarations)
- (STEnvironment *)scriptingEnvironment;
@end
@interface Executor:STExecutor
{
NSString *hostName;
NSString *objectName;
id target;
}
- (void)setTargetWithName:(NSString *)name;
@end
@implementation Executor
- (void)dealloc
{
RELEASE(objectName);
RELEASE(hostName);
[super dealloc];
}
- (void)setTargetWithName:(NSString *)targetName
{
NSDebugLog(@"connecting object '%@' on host '%@'",targetName,hostName);
if(!targetName)
{
[NSException raise:STExecutorException
format:@"No target specified"];
}
target = [NSConnection rootProxyForConnectionWithRegisteredName:targetName
host:hostName];
/*
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(connectionDidDie:)
name:NSConnectionDidDieNotification
object:object];
*/
if(!target)
{
[NSException raise:STExecutorException
format:@"Unable to connect to target named '%@' "
@"on host '%@'",
targetName, hostName];
return;
}
ASSIGN(objectName,targetName);
}
- (void)createEnvironment
{
if([target respondsToSelector:@selector(scriptingEnvironment)])
{
env = [target scriptingEnvironment];
}
else
{
[NSException raise:STExecutorException
format:@"Target '%@' on host '%@' "
@"does not provide scripting environment.",
objectName, hostName];
}
RETAIN(env);
[env setObject:target forName:objectName];
}
- (int)processOption:(NSString *)option
{
if ([@"host" hasPrefix:option])
{
ASSIGN(hostName,[self nextArgument]);
if(!hostName)
{
[NSException raise:STExecutorException
format:@"Hostname expected"];
}
}
else
{
[NSException raise:STExecutorException
format:@"Unknown option -%@", option];
}
return NO;
}
-(void) beforeExecuting
{
[self setTargetWithName:[self nextArgument]];
}
- (void)printHelp
{
printf(
"stalk - 'talk' to objects with StepTalk script\n"
"Usage: stalk [options] target script [args ...] [ , script ...]\n"
" Options:\n"
"%s"
" -host hostName look for target on specified host\n",
STExecutorCommonOptions
);
}
@end
int main(int argc, const char **argv)
{
Executor *executor;
NSArray *args;
NSAutoreleasePool *pool;
NSProcessInfo *procInfo;
pool = [NSAutoreleasePool new];
procInfo = [NSProcessInfo processInfo];
if (procInfo == nil)
{
NSLog(@"Unable to get process information");
[pool release];
exit(1);
}
executor = [[Executor alloc] init];
args = [procInfo arguments];
[executor runWithArguments:args];
[pool release];
return 0;
}