Introduced contexts finally commited

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@20518 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Stefan Urbanek 2005-01-04 21:51:13 +00:00
parent 8417ff6e26
commit 732057a75f
27 changed files with 464 additions and 259 deletions

View file

@ -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

View file

@ -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;

View file

@ -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 */
}

View file

@ -13,7 +13,7 @@
"writeToFile:atomically:",
"writeToURL:atomically:"
)
}
};
};
Classes =

View file

@ -25,7 +25,7 @@
"<=" = "isLessOrEqualThan:";
">=" = "isGreatherOrEqualThan:";
}
};
};
NumberArithmetic =

View file

@ -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)

View file

@ -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::

View file

@ -0,0 +1,69 @@
/**
STContext
Scripting context
Copyright (c) 2002 Free Software Foundation
Written by: Stefan Urbanek <urbanek@host.sk>
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
<title>STEnvironment class reference</title>
*/
#import <Foundation/NSObject.h>
@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

View file

@ -0,0 +1,217 @@
/**
STContext
Scripting context
Copyright (c) 2004 Free Software Foundation
Written by: Stefan Urbanek <urbanek@host.sk>
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
<title>STEnvironment class reference</title>
*/
#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 <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <Foundation/NSInvocation.h>
@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;
}
/**
<p>
Enable or disable creation of unknown objects. Normally you get nil if you
request for non-existant object. If <var>flag</var> is YES
then by requesting non-existant object, name for that object is created
and it is set no STNil.
</p>
<p>
Note: This method will be probably removed (moved to Smalltalk language bundle).
</p>
*/
-(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 <var>anObject</var> with name <var>objName</var>.
*/
- (void)setObject:(id)anObject
forName:(NSString *)objName
{
if(anObject)
{
[objectDictionary setObject:anObject forKey:objName];
}
else
{
[objectDictionary setObject:STNil forKey:objName];
}
}
/**
Remove object named <var>objName</var>.
*/
- (void)removeObjectWithName:(NSString *)objName
{
[objectDictionary removeObjectForKey:objName];
}
/**
*/
- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict
{
[objectDictionary 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
{
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

View file

@ -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

View file

@ -3,7 +3,7 @@
Copyright (c) 2002 Free Software Foundation
Written by: Stefan Urbanek <urbanek@host.sk>
Written by: Stefan Urbanek
Date: 2003 Sep 21
This file is part of the StepTalk project.
@ -28,20 +28,20 @@
#import <Foundation/NSException.h>
#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 <var>langName</var>. */
@ -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

View file

@ -27,7 +27,7 @@
*/
#import <Foundation/NSObject.h>
#import <StepTalk/STContext.h>
@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 */

View file

@ -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;
}
/**
<p>
Enable or disable creation of unknown objects. Normally you get nil if you
request for non-existant object. If <var>flag</var> is YES
then by requesting non-existant object, name for that object is created
and it is set no STNil.
</p>
<p>
Note: This method will be probably removed (moved to Smalltalk language bundle).
</p>
*/
-(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 <var>names</var> 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 <var>anObject</var> with name <var>objName</var>.
*/
- (void)setObject:(id)anObject
forName:(NSString *)objName
{
if(anObject)
{
[defaultPool setObject:anObject forKey:objName];
}
else
{
[defaultPool setObject:STNil forKey:objName];
}
}
/**
Remove object named <var>objName</var>.
*/
- (void)removeObjectWithName:(NSString *)objName
{
[defaultPool removeObjectForKey:objName];
}
/**
*/
- (void)addNamedObjectsFromDictionary:(NSDictionary *)dict
{
[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.
@ -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]) )

View file

@ -30,11 +30,13 @@
#import "STExterns.h"
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSString.h>
@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)

View file

@ -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...");

View file

@ -27,24 +27,20 @@
#import <Foundation/NSObject.h>
@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

View file

@ -34,57 +34,43 @@
#import <Foundation/NSString.h>
@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

View file

@ -8,6 +8,8 @@
STScriptsManager,
STBundleInfo,
STEngine,
STScriptObject
STScriptObject,
STConversation,
STContext
);
}

View file

@ -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

View file

@ -21,7 +21,7 @@
*/
#import <Foundation/NSData.h>
#import <Foundation/NSObject.h>
/* Bytecode table */
@ -82,7 +82,7 @@ extern NSArray *STBytecodeNames;
extern NSString *STBytecodeName(unsigned short code);
extern NSString *STDissasembleBytecode(STBytecode bytecode);
@interface STBytecodes:NSData<NSCoding>
@interface STBytecodes:NSObject
{
NSData *bytes;
}

View file

@ -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);

View file

@ -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]

View file

@ -34,7 +34,6 @@
#import "Externs.h"
#import <StepTalk/STExterns.h>
#import <StepTalk/STObjectReference.h>
#import <StepTalk/STScriptObject.h>
#import <StepTalk/STSelector.h>

View file

@ -1,6 +1,9 @@
#import <Foundation/NSObject.h>
@class STConversation;
@interface STEnvironmentProcess:NSObject
{
}
- (STConversation *)createConversaion;
@end

View file

@ -116,7 +116,7 @@
[env setObject:target forName:objectName];
conversation = [[STConversation alloc] initWithEnvironment:env
conversation = [[STConversation alloc] initWithContext:env
language:nil];
}

View file

@ -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

View file

@ -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.");
}
}