diff --git a/Documentation/Reference/StepTalk.igsdoc b/Documentation/Reference/StepTalk.igsdoc
index d640ce2..e5ebc11 100644
--- a/Documentation/Reference/StepTalk.igsdoc
+++ b/Documentation/Reference/StepTalk.igsdoc
@@ -22,8 +22,10 @@
STEngine = STEngine;
STEnvironment = STEnvironment;
STLanguage = STLanguage;
+ STMethod = STMethod;
STObjectReference = STObjectReference;
STScript = STScript;
+ STScriptObject = STScriptObject;
STScriptsManager = STScriptsManager;
STSelector = STSelector;
STUndefinedObject = STUndefinedObject;
@@ -119,6 +121,9 @@
"-addClassesWithNames:" = {
STEnvironment = STEnvironment;
};
+ "-addMethod:" = {
+ STScriptObject = STScriptObject;
+ };
"-addNamedObjectsFromDictionary:" = {
STEnvironment = STEnvironment;
};
@@ -152,6 +157,12 @@
"-executeCode:inEnvironment:" = {
STEngine = STEngine;
};
+ "-executeMethod:forReceiver:withArguments:inEnvironment:" = {
+ STEngine = STEngine;
+ };
+ "-executeMethod:forScriptObject:" = {
+ STEngine = STEngine;
+ };
"-fileName" = {
STScript = STScript;
};
@@ -185,12 +196,18 @@
"-initWithFile:" = {
STScript = STScript;
};
+ "-initWithInstanceVariableNames:" = {
+ STScriptObject = STScriptObject;
+ };
"-initWithObjectName:pool:" = {
STObjectReference = STObjectReference;
};
"-initWithSelector:" = {
STSelector = STSelector;
};
+ "-instanceVariableNames" = {
+ STScriptObject = STScriptObject;
+ };
"-isClass" = {
"(STScripting)" = STScripting;
};
@@ -207,7 +224,9 @@
STScript = STScript;
};
"-languageName" = {
+ "(STMethod)" = STMethod;
STLanguage = STLanguage;
+ STMethod = STMethod;
};
"-loadModule:" = {
STEnvironment = STEnvironment;
@@ -215,6 +234,25 @@
"-localizedName" = {
STScript = STScript;
};
+ "-methodDictionary" = {
+ STScriptObject = STScriptObject;
+ };
+ "-methodFromSource:forReceiver:inEnvironment:" = {
+ STEngine = STEngine;
+ };
+ "-methodFromSource:forScriptObject:" = {
+ STEngine = STEngine;
+ };
+ "-methodName" = {
+ "(STMethod)" = STMethod;
+ STMethod = STMethod;
+ };
+ "-methodNames" = {
+ STScriptObject = STScriptObject;
+ };
+ "-methodWithName:" = {
+ STScriptObject = STScriptObject;
+ };
"-namedObjects" = {
STBundleInfo = STBundleInfo;
};
@@ -227,6 +265,9 @@
"-objectDictionary" = {
STEnvironment = STEnvironment;
};
+ "-objectForVariable:" = {
+ STScriptObject = STScriptObject;
+ };
"-objectName" = {
STObjectReference = STObjectReference;
};
@@ -251,6 +292,12 @@
"-registerObjectFinderNamed:" = {
STEnvironment = STEnvironment;
};
+ "-removeMethod:" = {
+ STScriptObject = STScriptObject;
+ };
+ "-removeMethodWithName:" = {
+ STScriptObject = STScriptObject;
+ };
"-removeObjectFinderWithName:" = {
STEnvironment = STEnvironment;
};
@@ -299,6 +346,9 @@
"-setObject:forName:" = {
STEnvironment = STEnvironment;
};
+ "-setObject:forVariable:" = {
+ STScriptObject = STScriptObject;
+ };
"-setObjectName:" = {
STObjectReference = STObjectReference;
};
@@ -312,6 +362,8 @@
STScriptsManager = STScriptsManager;
};
"-source" = {
+ "(STMethod)" = STMethod;
+ STMethod = STMethod;
STScript = STScript;
};
"-stringValue" = {
@@ -352,6 +404,9 @@
Headers/StepTalk/STLanguage.h = (
../Documentation/Reference/STLanguage.gsdoc
);
+ Headers/StepTalk/STMethod.h = (
+ ../Documentation/Reference/STMethod.gsdoc
+ );
Headers/StepTalk/STObjCRuntime.h = (
../Documentation/Reference/STObjCRuntime.gsdoc
);
@@ -361,6 +416,9 @@
Headers/StepTalk/STScript.h = (
../Documentation/Reference/STScript.gsdoc
);
+ Headers/StepTalk/STScriptObject.h = (
+ ../Documentation/Reference/STScriptObject.gsdoc
+ );
Headers/StepTalk/STScripting.h = (
../Documentation/Reference/STScripting.gsdoc
);
@@ -375,6 +433,7 @@
);
};
protocol = {
+ "(STMethod)" = STMethod;
"(STScripting)" = STScripting;
};
source = {
@@ -402,6 +461,9 @@
Headers/StepTalk/STLanguage.h = (
STLanguage.m
);
+ Headers/StepTalk/STMethod.h = (
+ STMethod.m
+ );
Headers/StepTalk/STObjCRuntime.h = (
STObjCRuntime.m
);
@@ -411,6 +473,9 @@
Headers/StepTalk/STScript.h = (
STScript.m
);
+ Headers/StepTalk/STScriptObject.h = (
+ STScriptObject.m
+ );
Headers/StepTalk/STScripting.h = (
STScripting.m
);
@@ -429,8 +494,10 @@
STEngine = NSObject;
STEnvironment = NSObject;
STLanguage = NSBundle;
+ STMethod = NSObject;
STObjectReference = NSObject;
STScript = NSObject;
+ STScriptObject = NSObject;
STScriptsManager = NSObject;
STSelector = NSObject;
STUndefinedObject = NSObject;
@@ -444,9 +511,11 @@
STExterns = "STExterns autogsdoc generated documentation";
STFunctions = "STFunctions autogsdoc generated documentation";
STLanguage = "STLanguage class documentation";
+ STMethod = "STMethod autogsdoc generated documentation";
STObjCRuntime = "STObjCRuntime autogsdoc generated documentation";
STObjectReference = "STObjectReference class documentation";
STScript = "STScript class documentation";
+ STScriptObject = "STScriptObject class documentation";
STScripting = "STScripting protocol documentation";
STScriptsManager = "STScriptsManager class documentation";
STSelector = "STSelector class documentation";
@@ -454,6 +523,11 @@
StepTalk = "StepTalk Documentation";
};
unitmethods = {
+ "(STMethod)" = {
+ "-languageName" = STMethod;
+ "-methodName" = STMethod;
+ "-source" = STMethod;
+ };
"(STScripting)" = {
"+classForScripting" = STScripting;
"+className" = STScripting;
@@ -495,6 +569,10 @@
"-defaultEnvironment" = STEngine;
"-executeCode:" = STEngine;
"-executeCode:inEnvironment:" = STEngine;
+ "-executeMethod:forReceiver:withArguments:inEnvironment:" = STEngine;
+ "-executeMethod:forScriptObject:" = STEngine;
+ "-methodFromSource:forReceiver:inEnvironment:" = STEngine;
+ "-methodFromSource:forScriptObject:" = STEngine;
"-setDefaultEnvironment:" = STEngine;
"-understandsCode:" = STEngine;
};
@@ -536,6 +614,11 @@
"-engine" = STLanguage;
"-languageName" = STLanguage;
};
+ STMethod = {
+ "-languageName" = STMethod;
+ "-methodName" = STMethod;
+ "-source" = STMethod;
+ };
STObjectReference = {
"-initWithObjectName:pool:" = STObjectReference;
"-object" = STObjectReference;
@@ -556,6 +639,18 @@
"-scriptName" = STScript;
"-source" = STScript;
};
+ STScriptObject = {
+ "-addMethod:" = STScriptObject;
+ "-initWithInstanceVariableNames:" = STScriptObject;
+ "-instanceVariableNames" = STScriptObject;
+ "-methodDictionary" = STScriptObject;
+ "-methodNames" = STScriptObject;
+ "-methodWithName:" = STScriptObject;
+ "-objectForVariable:" = STScriptObject;
+ "-removeMethod:" = STScriptObject;
+ "-removeMethodWithName:" = STScriptObject;
+ "-setObject:forVariable:" = STScriptObject;
+ };
STScriptsManager = {
"+defaultManager" = STScriptsManager;
"-allScripts" = STScriptsManager;
diff --git a/Frameworks/GNUmakefile b/Frameworks/GNUmakefile
new file mode 100644
index 0000000..f96ccf1
--- /dev/null
+++ b/Frameworks/GNUmakefile
@@ -0,0 +1,33 @@
+#
+# Main Makefile for the StepTalk
+#
+# Copyright (C) 2000 Stefan Urbanek
+#
+# Written by: Stefan Urbanek
+#
+# This file is part of the StepTalk
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
+#
+
+include $(GNUSTEP_MAKEFILES)/common.make
+
+SUBPROJECTS = \
+ StepTalk
+
+-include GNUMakefile.preamble
+include $(GNUSTEP_MAKEFILES)/aggregate.make
+-include GNUMakefile.postamble
+
diff --git a/Source/Environments/AppKit.stenv b/Frameworks/StepTalk/Environments/AppKit.stenv
similarity index 100%
rename from Source/Environments/AppKit.stenv
rename to Frameworks/StepTalk/Environments/AppKit.stenv
diff --git a/Frameworks/StepTalk/Environments/Common.stenv b/Frameworks/StepTalk/Environments/Common.stenv
new file mode 100644
index 0000000..0a95bb1
--- /dev/null
+++ b/Frameworks/StepTalk/Environments/Common.stenv
@@ -0,0 +1,17 @@
+/** Common.stenv
+ * Common scripting environment description
+ */
+
+{
+ Name = "Common";
+
+ Bundles = (CommonEnvironment);
+
+ Import = ( "SymbolicSelectors",
+ "Foundation",
+ "AppKit",
+ "StepTalk"
+ );
+
+ Applications = ( All );
+}
diff --git a/Source/Environments/Distributed.stenv b/Frameworks/StepTalk/Environments/Distributed.stenv
similarity index 100%
rename from Source/Environments/Distributed.stenv
rename to Frameworks/StepTalk/Environments/Distributed.stenv
diff --git a/Source/Environments/Foundation-operators.stenv b/Frameworks/StepTalk/Environments/Foundation-operators.stenv
similarity index 100%
rename from Source/Environments/Foundation-operators.stenv
rename to Frameworks/StepTalk/Environments/Foundation-operators.stenv
diff --git a/Source/Environments/Foundation.stenv b/Frameworks/StepTalk/Environments/Foundation.stenv
similarity index 100%
rename from Source/Environments/Foundation.stenv
rename to Frameworks/StepTalk/Environments/Foundation.stenv
diff --git a/Source/Environments/Safe.stenv b/Frameworks/StepTalk/Environments/Safe.stenv
similarity index 100%
rename from Source/Environments/Safe.stenv
rename to Frameworks/StepTalk/Environments/Safe.stenv
diff --git a/Source/Environments/Standard.stenv b/Frameworks/StepTalk/Environments/Standard.stenv
similarity index 100%
rename from Source/Environments/Standard.stenv
rename to Frameworks/StepTalk/Environments/Standard.stenv
diff --git a/Source/Environments/StepTalk.stenv b/Frameworks/StepTalk/Environments/StepTalk.stenv
similarity index 100%
rename from Source/Environments/StepTalk.stenv
rename to Frameworks/StepTalk/Environments/StepTalk.stenv
diff --git a/Source/Environments/SymbolicSelectors.stenv b/Frameworks/StepTalk/Environments/SymbolicSelectors.stenv
similarity index 100%
rename from Source/Environments/SymbolicSelectors.stenv
rename to Frameworks/StepTalk/Environments/SymbolicSelectors.stenv
diff --git a/Frameworks/StepTalk/GNUmakefile b/Frameworks/StepTalk/GNUmakefile
new file mode 100644
index 0000000..f78f3d5
--- /dev/null
+++ b/Frameworks/StepTalk/GNUmakefile
@@ -0,0 +1,106 @@
+#
+# GNUmakefile
+#
+# Copyright (C) 2000 Stefan Urbanek
+#
+# This file is part of the StepTalk.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+include $(GNUSTEP_MAKEFILES)/common.make
+
+include ../Version
+
+LIBRARY_NAME = libStepTalk
+
+libStepTalk_OBJC_FILES = \
+ NSInvocation+additions.m \
+ STBehaviourInfo.m \
+ STBundleInfo.m \
+ STClassInfo.m \
+ STEngine.m \
+ STEnvironment.m \
+ STEnvironmentDescription.m \
+ STExterns.m \
+ STFunctions.m \
+ STLanguage.m \
+ STObjCRuntime.m \
+ STObjectReference.m \
+ STScript.m \
+ STScriptsManager.m \
+ STScripting.m \
+ STMethod.m \
+ STScriptObject.m \
+ STSelector.m \
+ STStructure.m \
+ STUndefinedObject.m \
+ NSNumber+additions.m \
+ NSObject+additions.m
+
+STEPTALK_HEADER_FILES = \
+ STBundleInfo.h \
+ STEngine.h \
+ STEnvironment.h \
+ STExterns.h \
+ STFunctions.h \
+ STLanguage.h \
+ STObjCRuntime.h \
+ STObjectReference.h \
+ STMethod.h \
+ STScriptObject.h \
+ STScript.h \
+ STScriptsManager.h \
+ STScripting.h \
+ STSelector.h \
+ STUndefinedObject.h \
+ NSInvocation+additions.h \
+ NSObject+additions.h
+
+libStepTalk_HEADER_FILES = $(STEPTALK_HEADER_FILES) \
+ StepTalk.h
+libStepTalk_HEADER_FILES_DIR = Headers/StepTalk
+
+libStepTalk_HEADER_FILES_INSTALL_DIR = StepTalk
+
+STEPTALK_LIBRARY_DIR = $(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk
+STEPTALK_ENVDEFS_DIR = $(STEPTALK_LIBRARY_DIR)/Environments
+
+ADDITIONAL_INCLUDE_DIRS += -I./Headers
+
+ADDITIONAL_CPPFLAGS += -pipe
+ADDITIONAL_OBJCFLAGS = -Wno-import -DSTEPTALK_VERSION=$(STEPTALK_VERSION)
+
+DOCUMENT_NAME = StepTalk
+
+StepTalk_DOC_INSTALL_DIR = Developer
+
+StepTalk_HEADER_FILES_DIR = $(HEADER_DIR)
+StepTalk_AGSDOC_FILES = StepTalk.gsdoc $(STEPTALK_HEADER_FILES)
+StepTalk_AGSDOC_FLAGS = \
+ -HeaderDirectory Headers/StepTalk \
+ -Up StepTalk \
+ -Declared StepTalk \
+ -DocumentationDirectory ../Documentation/Reference
+
+ifeq ($(GNUSTEP_TARGET_OS),mingw32)
+ libStepTalk_LIBRARIES_DEPEND_UPON += -lgnustep-base -lobjc
+endif
+
+-include GNUmakefile.preamble
+
+include $(GNUSTEP_MAKEFILES)/library.make
+include $(GNUSTEP_MAKEFILES)/documentation.make
+
+-include GNUmakefile.postamble
diff --git a/Frameworks/StepTalk/GNUmakefile.postamble b/Frameworks/StepTalk/GNUmakefile.postamble
new file mode 100644
index 0000000..10efca9
--- /dev/null
+++ b/Frameworks/StepTalk/GNUmakefile.postamble
@@ -0,0 +1,74 @@
+#
+# GNUmakefile.postamble
+#
+# Copyright (C) 2000 Stefan Urbanek
+#
+# This file is part of the StepTalk
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; see the file COPYING.LIB.
+# If not, write to the Free Software Foundation,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Project specific makefile rules
+#
+# Uncomment the targets you want.
+# The double colons (::) are important, do not make them single colons
+# otherwise the normal makefile rules will not be performed.
+#
+
+# Things to do before compiling
+# before-all::
+
+# Things to do after compiling
+# after-all::
+
+# Things to do before installing
+before-install::
+ $(MKDIRS) $(STEPTALK_LIBRARY_DIR)
+ $(MKDIRS) $(STEPTALK_ENVDEFS_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;\
+ )
+
+# Things to do before uninstalling
+# before-uninstall::
+
+# Things to do after uninstalling
+after-uninstall::
+ rm -rf $(STEPTALK_ENVDEFS_DIR)
+
+# Things to do before cleaning
+# before-clean::
+
+# Things to do after cleaning
+# after-clean::
+
+# Things to do before distcleaning
+# before-distclean::
+
+# Things to do after distcleaning
+# after-distclean::
+
+# Things to do before checking
+# before-check::
+
+# Things to do after checking
+# after-check::
+
diff --git a/Frameworks/StepTalk/NSInvocation+additions.h b/Frameworks/StepTalk/NSInvocation+additions.h
new file mode 100644
index 0000000..a1e2d30
--- /dev/null
+++ b/Frameworks/StepTalk/NSInvocation+additions.h
@@ -0,0 +1,40 @@
+/**
+ NSInvocation+additions.h
+ Various NSInvocation additions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+
+void STGetValueOfTypeFromObject(void *value, const char *type, id anObject);
+id STObjectFromValueOfType(void *value, const char *type);
+
+@interface NSInvocation(STAdditions)
++ invocationWithTarget:(id)target selectorName:(NSString *)selectorName;
+
+- (void)setArgumentAsObject:(id)anObject atIndex:(int)anIndex;
+- (id)getArgumentAsObjectAtIndex:(int)anIndex;
+- (id)returnValueAsObject;
+@end
+
diff --git a/Frameworks/StepTalk/NSInvocation+additions.m b/Frameworks/StepTalk/NSInvocation+additions.m
new file mode 100644
index 0000000..d53ab9c
--- /dev/null
+++ b/Frameworks/StepTalk/NSInvocation+additions.m
@@ -0,0 +1,325 @@
+/**
+ NSInvocation+additions
+ Various NSInvocation additions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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.
+
+ NSInvocation class additions
+
+ */
+
+#import
+
+#import
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+
+#if 0
+static Class NSNumber_class = nil;
+static Class NSString_class = nil;
+static Class NSValue_class = nil;
+#endif
+
+#define CASE_NUMBER_TYPE(otype,type,msgtype)\
+ case otype: object = [NSNumber numberWith##msgtype:*((type *)value)];\
+ NSDebugLLog(@"STStructure",\
+ @" is number value '%@'", object);\
+ break
+
+id STObjectFromValueOfType(void *value, const char *type)
+{
+ id object;
+
+ NSDebugLLog(@"STStructure",
+ @"object from value %p of of type '%c'",value,*type);
+
+ switch(*type)
+ {
+ case _C_ID:
+ case _C_CLASS:
+ object = *((id *)value);
+ NSDebugLLog(@"STStructure",
+ @" is object value %p", object);
+ break;
+ CASE_NUMBER_TYPE(_C_CHR,char,Char);
+ CASE_NUMBER_TYPE(_C_UCHR,unsigned char, UnsignedChar);
+ CASE_NUMBER_TYPE(_C_SHT,short,Short);
+ CASE_NUMBER_TYPE(_C_USHT,unsigned short,UnsignedShort);
+ CASE_NUMBER_TYPE(_C_INT,int,Int);
+ CASE_NUMBER_TYPE(_C_UINT,unsigned int,UnsignedInt);
+ CASE_NUMBER_TYPE(_C_LNG,long,Long);
+ CASE_NUMBER_TYPE(_C_ULNG,unsigned long,UnsignedLong);
+ CASE_NUMBER_TYPE(_C_LNG_LNG,long long,LongLong);
+ CASE_NUMBER_TYPE(_C_ULNG_LNG,unsigned long long,UnsignedLongLong);
+ CASE_NUMBER_TYPE(_C_FLT,float,Float);
+ CASE_NUMBER_TYPE(_C_DBL,double,Double);
+ case _C_PTR:
+ object = [NSValue valueWithPointer:*((void **)value)];
+ NSDebugLLog(@"STStructure",
+ @" is pointer value %p", *((void **)value));
+ break;
+ case _C_CHARPTR:
+ object = [NSString stringWithCString:*((char **)value)];
+ NSDebugLLog(@"STStructure",
+ @" is string value '%s'", *((char **)value));
+ break;
+ case _C_VOID:
+ object = nil;
+ break;
+ case _C_STRUCT_B:
+ object = [[STStructure alloc] initWithValue:value
+ type:type];
+ AUTORELEASE(object);
+ break;
+ case _C_SEL:
+ object = [[STSelector alloc] initWithSelector:*((SEL *)value)];
+ AUTORELEASE(object);
+ break;
+ case _C_BFLD:
+ case _C_UNDEF:
+ case _C_ATOM:
+ case _C_ARY_B:
+ case _C_ARY_E:
+ case _C_UNION_B:
+ case _C_UNION_E:
+ case _C_STRUCT_E:
+ default:
+ [NSException raise:STInvalidArgumentException
+ format:@"unhandled ObjC type '%s'",
+ type];
+
+ }
+ return object;
+}
+
+#define CASE_TYPE(otype,type,msgtype)\
+ case otype:(*((type *)value)) = [anObject msgtype##Value];\
+ NSDebugLLog(@"STStructure",\
+ @" is number value '%@'", anObject);\
+ break
+
+void STGetValueOfTypeFromObject(void *value, const char *type, id anObject)
+{
+ NSDebugLLog(@"STStructure",
+ @"value at %p from object '%@' of type '%c'",
+ value,anObject,*type);
+
+ switch(*type)
+ {
+ case _C_ID:
+ case _C_CLASS:
+ NSDebugLLog(@"STStructure",
+ @" is object value");
+ (*(id *)value) = anObject;
+ break;
+ CASE_TYPE(_C_CHR,char,char);
+ CASE_TYPE(_C_UCHR,unsigned char,unsignedChar);
+ CASE_TYPE(_C_SHT,short,short);
+ CASE_TYPE(_C_USHT,unsigned short,unsignedShort);
+ CASE_TYPE(_C_INT,int,int);
+ CASE_TYPE(_C_UINT,unsigned int,unsignedInt);
+ CASE_TYPE(_C_LNG,long,long);
+ CASE_TYPE(_C_ULNG,unsigned long,unsignedLong);
+ CASE_TYPE(_C_LNG_LNG,long long,longLong);
+ CASE_TYPE(_C_ULNG_LNG,unsigned long long,unsignedLongLong);
+ CASE_TYPE(_C_FLT,float,float);
+ CASE_TYPE(_C_DBL,double,double);
+ CASE_TYPE(_C_PTR,void *,pointer);
+ case _C_CHARPTR: /* FIXME: check if this is good (copy/no copy)*/
+ (*((const char **)value)) = [[anObject stringValue] cString];
+ NSDebugLLog(@"STStructure",
+ @" is cstring '%@'", [anObject stringValue]);
+ break;
+ case _C_STRUCT_B:
+ /* FIXME: chech for struct compatibility */
+ NSDebugLLog(@"STStructure",
+ @" is structure");
+ [(STStructure*)anObject getValue:value];
+ break;
+
+ case _C_SEL:
+ (*((SEL *)value)) = [anObject selectorValue];
+ break;
+
+ case _C_BFLD:
+ case _C_VOID:
+ case _C_UNDEF:
+ case _C_ATOM:
+ case _C_ARY_B:
+ case _C_ARY_E:
+ case _C_UNION_B:
+ case _C_UNION_E:
+ case _C_STRUCT_E:
+ default:
+ [NSException raise:STInvalidArgumentException
+ format:@"unhandled ObjC type '%s'",
+ type];
+ }
+}
+
+
+@implementation NSInvocation(STAdditions)
+#if 0
+/* with this method it does not work, it is not posiible to create an
+ invocation*/
++ (void)initialize
+{
+ NSNumber_class = [NSNumber class];
+ NSString_class = [NSString class];
+ NSValue_class = [NSValue class];
+}
+#endif
+
++ invocationWithTarget:(id)target selectorName:(NSString *)selectorName
+{
+ NSMethodSignature *signature;
+ NSInvocation *invocation;
+ SEL sel;
+ BOOL requiresRegistration = NO;
+
+ // NSLog(@"GETTING SELECTOR %@", selectorName);
+ sel = NSSelectorFromString(selectorName);
+
+ if(!sel)
+ {
+ // NSLog(@"REGISTERING SELECTOR");
+ char *name = [selectorName cString];
+
+ sel = sel_register_name(name);
+
+ if(!sel)
+ {
+ [NSException raise:STInternalInconsistencyException
+ format:@"Unable to register selector '%@'",
+ selectorName];
+ return nil;
+ }
+ requiresRegistration = YES;
+ }
+
+ signature = [target methodSignatureForSelector:sel];
+
+ /* FIXME: this is workaround for gnustep DO bug (hight priority) */
+
+ if(requiresRegistration)
+ {
+ // NSLog(@"REGISTERING SELECTOR TYPES");
+ sel = sel_register_typed_name([selectorName cString], [signature methodReturnType]);
+ // NSLog(@"REGISTERED %@", NSStringFromSelector(sel));
+
+ }
+
+ if(!signature)
+ {
+ [NSException raise:STInternalInconsistencyException
+ format:@"No method signature for selector '%@' for "
+ @"receiver of type %@",
+ selectorName,[target className]];
+ return nil;
+ }
+
+ invocation = [NSInvocation invocationWithMethodSignature:signature];
+
+ [invocation setSelector:sel];
+ [invocation setTarget:target];
+
+ return invocation;
+}
+
+- (void)setArgumentAsObject:(id)anObject atIndex:(int)anIndex
+{
+ const char *type;
+ void *value;
+
+ type = [[self methodSignature] getArgumentTypeAtIndex:anIndex];
+ value = NSZoneMalloc(STMallocZone,objc_sizeof_type(type));
+
+ STGetValueOfTypeFromObject(value, type, anObject);
+
+ [self setArgument:(void *)value atIndex:anIndex];
+ NSZoneFree(STMallocZone,value);
+}
+- (id)getArgumentAsObjectAtIndex:(int)anIndex
+{
+ const char *type;
+ void *value;
+ id object;
+
+ type = [[self methodSignature] getArgumentTypeAtIndex:anIndex];
+
+ value = NSZoneMalloc(STMallocZone,objc_sizeof_type(type));
+ [self getArgument:value atIndex:anIndex];
+
+ object = STObjectFromValueOfType(value,type);
+
+ NSZoneFree(STMallocZone,value);
+
+ return object;
+}
+- (id)returnValueAsObject
+{
+ const char *type;
+ int returnLength;
+ void *value;
+ id returnObject = nil;
+
+ NSMethodSignature *signature = [self methodSignature];
+
+ type = [signature methodReturnType];
+ returnLength = [signature methodReturnLength];
+
+ NSDebugLLog(@"STSending",
+ @" return type '%s', buffer length %i",type,returnLength);
+
+ if(returnLength!=0)
+ {
+ value = NSZoneMalloc(STMallocZone,returnLength);
+ [self getReturnValue:value];
+
+ if( *type == _C_VOID )
+ {
+ returnObject = [self target];
+ }
+ else
+ {
+ returnObject = STObjectFromValueOfType(value, type);
+ }
+
+ NSZoneFree(STMallocZone,value);
+ NSDebugLLog(@"STSending",
+ @" returned object %@",returnObject);
+ }
+ else
+ {
+ returnObject = [self target];
+ }
+
+ return returnObject;
+}
+@end
+
diff --git a/Frameworks/StepTalk/NSNumber+additions.h b/Frameworks/StepTalk/NSNumber+additions.h
new file mode 100644
index 0000000..6d474c4
--- /dev/null
+++ b/Frameworks/StepTalk/NSNumber+additions.h
@@ -0,0 +1,52 @@
+/**
+ NSNumber-additions.h
+ Various methods for NSNumber
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+@interface NSNumber (STAdditions)
+- add:(NSNumber *)number;
+- subtract:(NSNumber *)number;
+- multiply:(NSNumber *)number;
+- divide:(NSNumber *)number;
+- (unsigned int)isLessThan:(NSNumber *)number;
+- (BOOL)isGreatherThan:(NSNumber *)number;
+- (BOOL)isLessOrEqualThan:(NSNumber *)number;
+- (BOOL)isGreatherOrEqualThan:(NSNumber *)number;
+@end
+
+
+@interface NSNumber (STLogicOperations)
+- (unsigned int)or:(NSNumber *)number;
+- (unsigned int)and:(NSNumber *)number;
+- (unsigned int)not;
+@end
+
+@interface NSNumber (STStructure)
+- rangeWith:(int)length;
+- pointWith:(float)y;
+- sizeWith:(float)h;
+@end
diff --git a/Frameworks/StepTalk/NSNumber+additions.m b/Frameworks/StepTalk/NSNumber+additions.m
new file mode 100644
index 0000000..0aab532
--- /dev/null
+++ b/Frameworks/StepTalk/NSNumber+additions.m
@@ -0,0 +1,133 @@
+/**
+ NSNumber-additions.h
+ Various methods for NSNumber
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+
+#import
+#import
+
+#import
+
+#include
+
+@implementation NSNumber (STAdditions)
+- add:(NSNumber *)number
+{
+ return [NSNumber numberWithDouble:([self doubleValue]
+ + [number doubleValue])];
+}
+- subtract:(NSNumber *)number
+{
+ return [NSNumber numberWithDouble:([self doubleValue]
+ - [number doubleValue])];
+}
+- multiply:(NSNumber *)number
+{
+ return [NSNumber numberWithDouble:([self doubleValue]
+ * [number doubleValue])];
+}
+- divide:(NSNumber *)number
+{
+ if([number doubleValue] == 0.0)
+ {
+ [NSException raise:STGenericException
+ format:@"Division by zero"];
+ return self;
+ }
+
+
+ return [NSNumber numberWithDouble:([self doubleValue]
+ / [number doubleValue])];
+}
+
+- modulo:(NSNumber *)number
+{
+ if([number doubleValue] == 0.0)
+ {
+ [NSException raise:STGenericException
+ format:@"Division by zero"];
+ return self;
+ }
+
+
+ return [NSNumber numberWithDouble:(fmod([self doubleValue],
+ [number doubleValue]))];
+}
+- (unsigned int)isLessThan:(NSNumber *)number
+{
+ return ([self doubleValue] < [number doubleValue]);
+}
+
+- (BOOL)isGreatherThan:(NSNumber *)number
+{
+ return ([self doubleValue] > [number doubleValue]);
+}
+
+- (BOOL)isLessOrEqualThan:(NSNumber *)number
+{
+ return ([self doubleValue] <= [number doubleValue]);
+}
+- (BOOL)isGreatherOrEqualThan:(NSNumber *)number
+{
+ return ([self doubleValue] >= [number doubleValue]);
+}
+@end
+
+
+@implementation NSNumber (STLogicOperations)
+- (unsigned int)or:(NSNumber *)number
+{
+ return ([self intValue] | [number intValue]);
+}
+
+- (unsigned int)and:(NSNumber *)number
+{
+ return ([self intValue] & [number intValue]);
+}
+
+- (unsigned int)not
+{
+ /* FIXME */
+ return ![self intValue];
+}
+
+@end
+
+@implementation NSNumber (STStructure)
+- rangeWith:(int)length
+{
+ return [STStructure structureWithRange:NSMakeRange([self intValue], length)];
+}
+- pointWith:(float)y
+{
+ return [STStructure structureWithPoint:NSMakePoint([self floatValue], y)];
+}
+- sizeWith:(float)h
+{
+ return [STStructure structureWithSize:NSMakeSize([self floatValue], h)];
+}
+@end
diff --git a/Frameworks/StepTalk/NSObject+additions.h b/Frameworks/StepTalk/NSObject+additions.h
new file mode 100644
index 0000000..58ab9ba
--- /dev/null
+++ b/Frameworks/StepTalk/NSObject+additions.h
@@ -0,0 +1,31 @@
+/**
+ NSObject-additions.h
+ Various methods for NSObject
+
+ Copyright (c) 2002 Free Software Foundation
+
+ 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
+
+ */
+
+#import
+
+@interface NSObject (STAdditions)
+- (BOOL)isSame:(id)anObject;
+- (BOOL)isNil;
+- (BOOL)notNil;
+@end
diff --git a/Frameworks/StepTalk/NSObject+additions.m b/Frameworks/StepTalk/NSObject+additions.m
new file mode 100644
index 0000000..6ed6e01
--- /dev/null
+++ b/Frameworks/StepTalk/NSObject+additions.m
@@ -0,0 +1,27 @@
+/**
+ NSObject-additions.m
+ Various methods for NSObject
+
+ Copyright (c) 2002 Free Software Foundation
+
+ This file is part of the StepTalk project.
+
+ */
+
+#import
+
+@implementation NSObject (STAdditions)
+- (BOOL)isSame:(id)anObject
+{
+ return self == anObject;
+}
+- (BOOL)isNil
+{
+ return NO;
+}
+- (BOOL)notNil
+{
+ return YES;
+}
+@end
+
diff --git a/Frameworks/StepTalk/STBehaviourInfo.h b/Frameworks/StepTalk/STBehaviourInfo.h
new file mode 100644
index 0000000..af3a834
--- /dev/null
+++ b/Frameworks/StepTalk/STBehaviourInfo.h
@@ -0,0 +1,66 @@
+/**
+ STBehaviourInfo.h
+ Scripting definition: behaviour information
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#include
+
+@class NSString;
+@class NSDictionary;
+@class NSMutableDictionary;
+@class NSMutableSet;
+@class NSSet;
+
+@interface STBehaviourInfo:NSObject
+{
+ NSString *name;
+
+ NSMutableDictionary *selectorMap;
+
+ NSMutableSet *allowMethods;
+ NSMutableSet *denyMethods;
+}
+- initWithName:(NSString *)aString;
+
+- (NSString*)behaviourName;
+
+- (void)setTranslation:(NSString *)aSelector
+ forSelector:(NSString *)aString;
+
+- (void)removeTranslationForSelector:(NSString *)aString;
+- (NSDictionary *)selectorMap;
+- (void)addTranslationsFromDictionary:(NSDictionary *)map;
+
+- (void)allowMethods:(NSSet *)set;
+- (void)denyMethods:(NSSet *)set;
+
+- (void)allowMethod:(NSString *)methodName;
+- (void)denyMethod:(NSString *)methodName;
+
+- (NSSet *)allowedMethods;
+- (NSSet *)deniedMethods;
+
+- (void)adopt:(STBehaviourInfo *)info;
+@end
diff --git a/Frameworks/StepTalk/STBehaviourInfo.m b/Frameworks/StepTalk/STBehaviourInfo.m
new file mode 100644
index 0000000..6d5233f
--- /dev/null
+++ b/Frameworks/StepTalk/STBehaviourInfo.m
@@ -0,0 +1,137 @@
+/**
+ STBehaviourInfo.m
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+@implementation STBehaviourInfo
+- initWithName:(NSString *)aString
+{
+ self = [super init];
+ selectorMap = [[NSMutableDictionary alloc] init];
+ allowMethods = [[NSMutableSet alloc] init];
+ denyMethods = [[NSMutableSet alloc] init];
+
+ name = RETAIN(aString);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(selectorMap);
+ RELEASE(allowMethods);
+ RELEASE(denyMethods);
+ RELEASE(name);
+
+ [super dealloc];
+}
+
+- (NSString*)behaviourName
+{
+ return name;
+}
+
+- (void)adopt:(STBehaviourInfo *)info
+{
+ [self addTranslationsFromDictionary:[info selectorMap]];
+ [self allowMethods:[info allowedMethods]];
+ [self denyMethods:[info deniedMethods]];
+}
+
+- (NSDictionary *)selectorMap
+{
+ return selectorMap;
+}
+
+- (void)removeTranslationForSelector:(NSString *)aString
+{
+ [selectorMap removeObjectForKey:aString];
+}
+
+- (void)setTranslation:(NSString *)translation
+ forSelector:(NSString *)selector
+{
+ [selectorMap setObject:translation forKey:selector];
+}
+
+- (void)addMethodsFromArray:(NSArray *)methods
+{
+ NSEnumerator *enumerator;
+ NSString *sel;
+
+ enumerator = [methods objectEnumerator];
+ while( (sel = [enumerator nextObject]) )
+ {
+ [self setTranslation:sel forSelector:sel];
+ }
+}
+
+- (void)addTranslationsFromDictionary:(NSDictionary *)map
+{
+ [selectorMap addEntriesFromDictionary:map];
+}
+- (void)allowMethods:(NSSet *)set
+{
+ [allowMethods unionSet:set];
+ [denyMethods minusSet:allowMethods];
+}
+
+- (void)denyMethods:(NSSet *)set;
+{
+ [denyMethods unionSet:set];
+ [allowMethods minusSet:denyMethods];
+}
+
+- (void)allowMethod:(NSString *)methodName;
+{
+ [allowMethods addObject:methodName];
+ [denyMethods removeObject:methodName];
+}
+
+- (void)denyMethod:(NSString *)methodName;
+{
+ [denyMethods addObject:methodName];
+ [allowMethods removeObject:methodName];
+}
+
+- (NSSet *)allowedMethods
+{
+ return AUTORELEASE([allowMethods copy]);
+}
+
+- (NSSet *)deniedMethods
+{
+ return AUTORELEASE([denyMethods copy]);
+}
+@end
diff --git a/Frameworks/StepTalk/STBundleInfo.h b/Frameworks/StepTalk/STBundleInfo.h
new file mode 100644
index 0000000..95155c6
--- /dev/null
+++ b/Frameworks/StepTalk/STBundleInfo.h
@@ -0,0 +1,61 @@
+/**
+ STBundleInfo.h
+ Bundle scripting information
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2003 Jan 22
+
+ 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
+
+ */
+
+#import
+
+@class NSArray;
+
+@interface STBundleInfo:NSObject
+{
+ NSBundle *bundle;
+ BOOL useAllClasses;
+ NSArray *publicClasses;
+ NSArray *allClasses;
+ NSDictionary *objectReferenceDictionary;
+ NSString *scriptingInfoClassName;
+ Class scriptingInfoClass;
+}
++ infoForBundle:(NSBundle *)aBundle;
+- initWithBundle:(NSBundle *)aBundle;
+
+- (NSDictionary *)objectReferenceDictionary;
+
+- (NSDictionary *)namedObjects;
+
+- (NSArray *)publicClassNames;
+- (NSArray *)allClassNames;
+@end
+
+@interface NSBundle(STAdditions)
++ (NSArray *)stepTalkBundleNames;
++ stepTalkBundleWithName:(NSString *)moduleName;
+- (NSDictionary *)scriptingInfoDictionary;
+
++ (NSArray *)allFrameworkNames;
++ (NSString *)pathForFrameworkWithName:(NSString *)aName;
++ (NSBundle *)bundleForFrameworkWithName:(NSString *)aName;
+@end
diff --git a/Frameworks/StepTalk/STBundleInfo.m b/Frameworks/StepTalk/STBundleInfo.m
new file mode 100644
index 0000000..ccaa439
--- /dev/null
+++ b/Frameworks/StepTalk/STBundleInfo.m
@@ -0,0 +1,387 @@
+/**
+ STBundleInfo.h
+ Bundle scripting information
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2003 Jan 22
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+static NSMutableDictionary *bundleInfoDict;
+
+@protocol STScriptingInfoClass
++ (NSDictionary *)namedObjectsForScripting;
+@end
+
+@interface STBundleInfo(STPrivateMethods)
+- (void) _bundleDidLoad:(NSNotification *)notif;
+- (void)_initializeScriptingInfoClass;
+@end
+
+@implementation NSBundle(STAdditions)
+/** Get list of all StepTalk bundles from Library/StepTalk/Bundles */
++ (NSArray *)stepTalkBundleNames
+{
+ NSArray *bundles;
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSMutableArray *names = [NSMutableArray array];
+ NSString *name;
+
+ bundles = STFindAllResources(@"Bundles", STModuleExtension);
+
+ enumerator = [bundles objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ name = [path lastPathComponent];
+ name = [name stringByDeletingPathExtension];
+ [names addObject:name];
+ }
+
+ bundles = STFindAllResources(@"Modules", STModuleExtension);
+
+ enumerator = [bundles objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ name = [path lastPathComponent];
+ name = [name stringByDeletingPathExtension];
+ [names addObject:name];
+ }
+
+ return AUTORELEASE([NSArray arrayWithArray:names]);
+}
+
++ stepTalkBundleWithName:(NSString *)moduleName
+{
+ NSString *file = STFindResource(moduleName, @"Bundles",
+ @"bundle");
+ if(!file)
+ {
+ file = STFindResource(moduleName, STModulesDirectory,
+ STModuleExtension);
+
+ if(!file)
+ {
+ NSLog(@"Could not find bundle with name '%@'", moduleName);
+ return nil;
+ }
+ }
+
+ return AUTORELEASE([[self alloc] initWithPath:file]);
+}
+- (NSDictionary *)scriptingInfoDictionary
+{
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSString *file;
+
+ file = [self pathForResource:@"ScriptingInfo" ofType:@"plist"];
+
+ if([manager fileExistsAtPath:file])
+ {
+ return [NSDictionary dictionaryWithContentsOfFile:file];
+ }
+ else
+ {
+ return nil;
+ }
+}
+/** Return names of all available frameworks in the system. */
++ (NSArray *)allFrameworkNames
+{
+ NSMutableArray *names = [NSMutableArray array];
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSArray *paths;
+ NSEnumerator *fenum;
+ NSEnumerator *penum;
+ NSString *path;
+ NSString *file;
+ NSString *name;
+
+ paths = NSStandardLibraryPaths();
+
+ penum = [paths objectEnumerator];
+
+ while( (path = [penum nextObject]) )
+ {
+
+ path = [path stringByAppendingPathComponent:@"Frameworks"];
+
+ fenum = [[manager directoryContentsAtPath:path] objectEnumerator];
+
+ if( ![manager fileExistsAtPath:path isDirectory:NO] )
+ {
+ continue;
+ }
+
+ while( (file = [fenum nextObject]) )
+ {
+ if( [[file pathExtension] isEqualToString:@"framework"] )
+ {
+ name = [[file lastPathComponent] stringByDeletingPathExtension];
+ [names addObject:name];
+ }
+ }
+ }
+
+ return names;
+}
+
+/** Return path for framework with name aName. */
++ (NSString *)pathForFrameworkWithName:(NSString *)aName
+{
+ NSMutableArray *names = [NSMutableArray array];
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSArray *paths;
+ NSEnumerator *fenum;
+ NSEnumerator *penum;
+ NSString *path;
+ NSString *file;
+ NSString *name;
+
+ paths = NSStandardLibraryPaths();
+
+ penum = [paths objectEnumerator];
+
+ while( (path = [penum nextObject]) )
+ {
+
+ path = [path stringByAppendingPathComponent:@"Frameworks"];
+
+ fenum = [[manager directoryContentsAtPath:path] objectEnumerator];
+
+ if( ![manager fileExistsAtPath:path isDirectory:NO] )
+ {
+ continue;
+ }
+
+ while( (file = [fenum nextObject]) )
+ {
+ if( [[file pathExtension] isEqualToString:@"framework"] )
+ {
+ name = [[file lastPathComponent] stringByDeletingPathExtension];
+ if([name isEqualToString:aName])
+ {
+ return [path stringByAppendingPathComponent:file];
+ }
+ }
+ }
+ }
+
+ return nil;
+}
+
+/** Return bundle for framework with name aName. */
++ (NSBundle *)bundleForFrameworkWithName:(NSString *)aName
+{
+ return [self bundleWithPath:[self pathForFrameworkWithName:aName]];;
+}
+
+@end
+
+@implementation STBundleInfo
++ infoForBundle:(NSBundle *)aBundle
+{
+ return AUTORELEASE([[self alloc] initWithBundle:aBundle]);
+}
+/** Initialize info with bundle aBundle.
+
+
+*/
+- initWithBundle:(NSBundle *)aBundle
+{
+ STBundleInfo *info;
+ NSString *flagString;
+ NSDictionary *dict;
+ if(!aBundle)
+ {
+ [NSException raise:@"STBundleException"
+ format:@"Nil bundle specified"];
+ [self dealloc];
+ return nil;
+ }
+
+ info = [bundleInfoDict objectForKey:[aBundle bundlePath]];
+
+ if(info)
+ {
+ [self dealloc];
+ return RETAIN(info);
+ }
+
+ dict = [aBundle scriptingInfoDictionary];
+
+ if(!dict)
+ {
+ NSLog(@"Warning: Bundle '%@' does not provide scripting capabilities.",
+ [aBundle bundlePath]);
+ [self dealloc];
+ return nil;
+ }
+
+ ASSIGN(bundle, aBundle);
+
+#if 0
+ /* FIXME: remove observer somewhere */
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(_bundleDidLoad:)
+ name:NSBundleDidLoadNotification
+ object:self];
+#endif
+
+ flagString = [dict objectForKey:@"UseAllClasses"];
+ flagString = [flagString lowercaseString];
+
+ useAllClasses = [flagString isEqualToString:@"yes"];
+
+ if([dict objectForKey: @"STClasses"])
+ {
+ NSLog(@"WARNING: Use 'Classes' instead of 'STClasses' in "
+ @"ScriptingInfo.plist for bundle '%@'", [aBundle bundlePath]);
+
+ publicClasses = [dict objectForKey:@"STClasses"];
+ }
+ else
+ {
+ publicClasses = [dict objectForKey:@"Classes"];
+ }
+ RETAIN(publicClasses);
+
+
+ if([dict objectForKey: @"STScriptingInfoClass"])
+ {
+ NSLog(@"WARNING: Use 'ScriptingInfoClass' instead of 'STScriptingInfoClass' in "
+ @"ScriptingInfo.plist for bundle '%@'", [aBundle bundlePath]);
+
+ scriptingInfoClassName = [dict objectForKey:@"STScriptingInfoClass"];
+ }
+ else
+ {
+ scriptingInfoClassName = [dict objectForKey:@"ScriptingInfoClass"];
+ }
+ RETAIN(scriptingInfoClassName);
+
+ objectReferenceDictionary = [dict objectForKey:@"Objects"];
+
+ if(!bundleInfoDict)
+ {
+ bundleInfoDict = [[NSMutableDictionary alloc] init];
+ }
+
+ [bundleInfoDict setObject:self forKey:[bundle bundlePath]];
+
+ return self;
+}
+
+- (void) _bundleDidLoad:(NSNotification *)notif
+{
+ NSLog(@"Module '%@' loaded", [bundle bundlePath]);
+
+ if([notif object] != self)
+ {
+ NSLog(@"STBundle: That's not me!");
+ return;
+ }
+
+ allClasses = [[notif userInfo] objectForKey:NSLoadedClasses];
+ RETAIN(allClasses);
+
+ NSLog(@"All classes are %@");
+}
+
+- (NSArray *)publicClassNames
+{
+ if(useAllClasses)
+ {
+ if(!allClasses)
+ {
+ [self _initializeScriptingInfoClass];
+ }
+ return allClasses;
+ }
+ else
+ {
+ return publicClasses;
+ }
+}
+
+/** Return an array of all class names. */
+- (NSArray *)allClassNames
+{
+ /* FIXME: not implemented; */
+ NSLog(@"Warning: All bundle classes requested, using public classes only.");
+ return publicClasses;
+}
+
+/** Return a dictionary of named objects. Named objects are get from scripting
+ info class specified in ScriptingInfo.plist.*/
+- (NSDictionary *)namedObjects
+{
+ if(!scriptingInfoClass)
+ {
+ [self _initializeScriptingInfoClass];
+ }
+
+ return [(id)scriptingInfoClass namedObjectsForScripting];
+}
+
+- (void)_initializeScriptingInfoClass
+{
+ scriptingInfoClass = [bundle classNamed:scriptingInfoClassName];
+
+ if(!scriptingInfoClass)
+ {
+ NSDebugLog(@"No scripting info class for bundle '%@'",[bundle bundlePath]);
+#if 0
+ [NSException raise:@"STBundleException"
+ format:@"Unable to get scripting info class '%@' for "
+ @"bundle '%@'",
+ scriptingInfoClassName, [bundle bundlePath]];
+
+#endif
+ }
+}
+
+/** This method is for application scripting support. Return dictionary
+ containing object references where a key is name of an object and
+ value is a path to the object relative to application delegate.
+*/
+- (NSDictionary *)objectReferenceDictionary
+{
+ return objectReferenceDictionary;
+}
+
+@end
diff --git a/Frameworks/StepTalk/STClassInfo.h b/Frameworks/StepTalk/STClassInfo.h
new file mode 100644
index 0000000..9500294
--- /dev/null
+++ b/Frameworks/StepTalk/STClassInfo.h
@@ -0,0 +1,51 @@
+/**
+ STClassInfo.h
+ Objective-C class wrapper
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+@class NSString;
+@class NSMutableDictionary;
+
+@interface STClassInfo:STBehaviourInfo
+{
+ STClassInfo *superclass;
+ NSString *superclassName;
+ BOOL allowAll;
+
+ NSMutableDictionary *selectorCache;
+}
+- (NSString *)translationForSelector:(NSString *)aString;
+
+- (void)setSuperclassInfo:(STClassInfo *)classInfo;
+- (STClassInfo *)superclassInfo;
+
+- (void)setSuperclassName:(NSString *)aString;
+- (NSString *)superclassName;
+
+- (void)setAllowAllMethods:(BOOL)flag;
+- (BOOL)allowAllMethods;
+@end
diff --git a/Frameworks/StepTalk/STClassInfo.m b/Frameworks/StepTalk/STClassInfo.m
new file mode 100644
index 0000000..00ba1f2
--- /dev/null
+++ b/Frameworks/StepTalk/STClassInfo.m
@@ -0,0 +1,140 @@
+/**
+ STClassInfo.m
+ Objective-C class wrapper
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+
+@implementation STClassInfo
+- initWithName:(NSString *)aString
+
+{
+ [super initWithName:aString];
+
+ selectorCache = [[NSMutableDictionary alloc] init];
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(selectorCache);
+ [super dealloc];
+}
+
+- (void)setSuperclassInfo:(STClassInfo *)classInfo
+{
+ ASSIGN(superclass,classInfo);
+}
+
+- (STClassInfo *)superclassInfo
+{
+ return superclass;
+}
+- (void) setSuperclassName:(NSString *)aString
+{
+ ASSIGN(superclassName,aString);
+}
+- (NSString *)superclassName
+{
+ return superclassName;
+}
+
+- (NSString *)translationForSelector:(NSString *)aString
+{
+
+ NSString *sel;
+
+ NSDebugLLog(@"STSending",@"Translate '%@' in %@:%@. (%i)",
+ aString, [self behaviourName],superclassName, allowAll);
+
+ sel = [selectorCache objectForKey:aString];
+
+ if(sel)
+ {
+ return sel;
+ }
+
+ sel = [selectorMap objectForKey:aString];
+
+ if(!sel)
+ {
+ /* Lookup for super selector maping */
+ if(superclass)
+ {
+ sel = [superclass translationForSelector:aString];
+
+ if(sel &&
+ ([denyMethods containsObject:sel] ||
+ (!allowAll && ![allowMethods containsObject:sel])))
+ {
+ sel = nil;
+ }
+ else if([allowMethods containsObject:aString])
+ {
+ sel = aString;
+ }
+ }
+ else if(allowAll || [allowMethods containsObject:aString])
+ {
+ sel = aString;
+ }
+
+ NSDebugLLog(@"STSending",@" translated '%@' deny %i allow %i all %i",
+ sel, [denyMethods containsObject:sel],
+ [allowMethods containsObject:sel],
+ allowAll);
+
+ }
+
+ NSDebugLLog(@"STSending",@" Return '%@' (%@)",
+ sel, [self behaviourName]);
+ if(sel)
+ {
+ [selectorCache setObject:sel forKey:aString];
+ }
+
+ return sel;
+}
+
+- (void)setAllowAllMethods:(BOOL)flag
+{
+ allowAll = flag;
+}
+
+- (BOOL)allowAllMethods
+{
+ return allowAll;
+}
+@end
+
diff --git a/Frameworks/StepTalk/STEngine.h b/Frameworks/StepTalk/STEngine.h
new file mode 100644
index 0000000..6273fc8
--- /dev/null
+++ b/Frameworks/StepTalk/STEngine.h
@@ -0,0 +1,64 @@
+/**
+ STEngine.h
+ Scripting engine
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+#import
+
+@class STEnvironment;
+@class STLanguageEngine;
+@class STMethod;
+
+/** STEngine is abstract class for language engines used to intepret scripts.*/
+@interface STEngine:NSObject
+{
+ STEnvironment *defaultEnvironment;
+}
+
+/** Instance creation */
++ (STEngine *) engineForLanguageWithName:(NSString *)name;
++ (STEngine *) engineForFileType:(NSString *)fileType;
+
+/** Scripting Environment */
+- (STEnvironment *)defaultEnvironment;
+- (void) setDefaultEnvironment:(STEnvironment *)anEnvironment;
+
+- (id) executeCode:(NSString *)code;
+
+- (id) executeCode:(NSString *)code
+ inEnvironment:(STEnvironment *)env;
+
+- (BOOL)understandsCode:(NSString *)code;
+
+/* Methods */
+- (STMethod *)methodFromSource:(NSString *)sourceString
+ forReceiver:(id)receiver
+ inEnvironment:(STEnvironment *)env;
+- (id) executeMethod:(id )aMethod
+ forReceiver:(id)anObject
+ withArguments:(NSArray *)args
+ inEnvironment:(STEnvironment *)env;
+@end
diff --git a/Frameworks/StepTalk/STEngine.m b/Frameworks/StepTalk/STEngine.m
new file mode 100644
index 0000000..5375421
--- /dev/null
+++ b/Frameworks/StepTalk/STEngine.m
@@ -0,0 +1,149 @@
+/**
+ STEngine.m
+ Scripting engine
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+
+#import
+#import
+
+NSZone *STMallocZone = NULL;
+
+void _STInitMallocZone(void)
+{
+ if(!STMallocZone)
+ {
+ STMallocZone = NSCreateZone(NSPageSize(),NSPageSize(),NO);
+ }
+
+}
+
+@implementation STEngine
++ (void)initialize
+{
+ _STInitMallocZone();
+
+ if(!STNil)
+ {
+ STNil = (STUndefinedObject *)NSAllocateObject([STUndefinedObject class],
+ 0, STMallocZone);
+ }
+}
+
+/**
+ Return a scripting engine for the language used in files of type
+ fileType
+*/
++ (STEngine *) engineForFileType:(NSString *)fileType
+{
+ STLanguage *language = [STLanguage languageForFileType:fileType];
+
+ return [language engine];
+}
+
+/**
+ Return a scripting engine for language with specified name.
+*/
++ (STEngine *) engineForLanguageWithName:(NSString *)name
+{
+ if(!name)
+ {
+ NSLog(@"No language name given");
+ return NULL;
+ }
+
+ return [[STLanguage languageWithName:name] engine];
+}
+
+- (void)dealloc
+{
+ RELEASE(defaultEnvironment);
+
+ [super dealloc];
+}
+
+/** Return the default scripting environment for the engine. */
+- (STEnvironment *)defaultEnvironment
+{
+ return defaultEnvironment;
+}
+
+/** Set the default scripting environment for the engine. */
+- (void) setDefaultEnvironment:(STEnvironment *)anEnvironment
+{
+ ASSIGN(defaultEnvironment,anEnvironment);
+}
+
+/** Execude source code code in default scripting environment. */
+- (id) executeCode:(NSString *)code
+{
+ return [self executeCode:code
+ inEnvironment:defaultEnvironment];
+}
+
+/** Execude source code code in an environment env.
+ This is the method, that has to be implemented by those who are writing
+ a language engine.
+
+*/
+- (id) executeCode:(NSString *)code
+ inEnvironment:(STEnvironment *)env
+{
+ [self subclassResponsibility:_cmd];
+
+ return nil;
+}
+
+- (BOOL)understandsCode:(NSString *)code
+{
+ [self subclassResponsibility:_cmd];
+
+ return NO;
+}
+
+- (STMethod *)methodFromSource:(NSString *)sourceString
+ forReceiver:(id)receiver
+ inEnvironment:(STEnvironment *)env
+{
+ [self subclassResponsibility:_cmd];
+ return nil;
+}
+- (id) executeMethod:(id )aMethod
+ forReceiver:(id)anObject
+ withArguments:(NSArray *)args
+ inEnvironment:(STEnvironment *)env;
+{
+ [self subclassResponsibility:_cmd];
+ return nil;
+}
+
+@end
diff --git a/Frameworks/StepTalk/STEnvironment.h b/Frameworks/StepTalk/STEnvironment.h
new file mode 100644
index 0000000..9e3e2f1
--- /dev/null
+++ b/Frameworks/StepTalk/STEnvironment.h
@@ -0,0 +1,104 @@
+/**
+ STEnvironment
+ Scripting environment
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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 STEnvironment:NSObject
+{
+ NSMutableDictionary *defaultPool;
+
+ STEnvironmentDescription *description;
+ NSMutableDictionary *classes; /* from description */
+
+ BOOL fullScripting;
+ BOOL createsUnknownObjects;
+
+ NSMutableDictionary *infoCache;
+
+ NSMutableDictionary *objectFinders;
+
+ NSMutableArray *loadedBundles;
+}
+/** Creating environment */
++ (STEnvironment *)defaultScriptingEnvironment;
+
++ environmentWithDescriptionName:(NSString *)descName;
++ environmentWithDescription:(STEnvironmentDescription *)aDescription;
+
+- initDefault;
+- initWithDescriptionName:(NSString *)descName;
+- initWithDescription:(STEnvironmentDescription *)aDescription;
+
+/** Full scripting */
+
+- (void)setFullScriptingEnabled:(BOOL)flag;
+- (BOOL)fullScriptingEnabled;
+
+-(void)setCreatesUnknownObjects:(BOOL)flag;
+-(BOOL)createsUnknownObjects;
+
+/** Modules */
+
+- (void)loadModule:(NSString *)moduleName;
+
+- (void)includeFramework:(NSString *)frameworkName;
+- (BOOL)includeBundle:(NSBundle *)aBundle;
+
+- (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 */
+
+- (NSString *)translateSelector:(NSString *)aString forReceiver:(id)anObject;
+@end
diff --git a/Frameworks/StepTalk/STEnvironment.m b/Frameworks/StepTalk/STEnvironment.m
new file mode 100644
index 0000000..ed69b89
--- /dev/null
+++ b/Frameworks/StepTalk/STEnvironment.m
@@ -0,0 +1,617 @@
+/**
+ STEnvironment
+ Scripting environment
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+@interface STEnvironment(STPrivateMethods)
+- (STClassInfo *)findClassInfoForObject:(id)anObject;
+@end
+
+@implementation STEnvironment
+/**
+ Creates and initialises scripting environment using standard description.
+ */
++ (STEnvironment *)defaultScriptingEnvironment
+{
+ NSString *name;
+
+ name = [STEnvironmentDescription defaultEnvironmentDescriptionName];
+
+ return [self environmentWithDescriptionName:name];
+}
+
+/**
+ Creates and initialises scripting environment using description with name
+ descName.
+ */
++ environmentWithDescriptionName:(NSString *)descName
+{
+ return AUTORELEASE([[self alloc] initWithDescriptionName:descName]);
+}
+
+/**
+ Creates and initialises scripting environment using environment description
+ description.
+ */
++ environmentWithDescription:(STEnvironmentDescription *)aDescription
+{
+ return AUTORELEASE([[self alloc] initWithDescription:aDescription]);
+}
+
+/**
+ Initialises scripting environment using default description.
+
+
+ */
+- initDefault
+{
+ NSString *name;
+
+ name = [STEnvironmentDescription defaultEnvironmentDescriptionName];
+
+ return [self initWithDescriptionName:name];
+}
+/**
+ Initialises scripting environment using description with name
+ descName.
+
+
+ */
+- initWithDescriptionName:(NSString *)descName
+{
+ return [self initWithDescription:
+ [STEnvironmentDescription descriptionWithName:descName]];
+}
+
+/**
+ Initialises scripting environment using scripting description
+ aDescription.
+ */
+- initWithDescription:(STEnvironmentDescription *)aDescription
+{
+ NSEnumerator *enumerator;
+ NSString *name;
+
+ self = [super init];
+
+ defaultPool = [[NSMutableDictionary alloc] init];
+ infoCache = [[NSMutableDictionary alloc] init];
+
+ description = RETAIN(aDescription);
+ classes = [description classes];
+
+ /* Load modules */
+ enumerator = [[description modules] objectEnumerator];
+
+ while( (name = [enumerator nextObject]) )
+ {
+ [self loadModule:name];
+ }
+
+ /* Register finders */
+ enumerator = [[description objectFinders] objectEnumerator];
+
+ while( (name = [enumerator nextObject]) )
+ {
+ [self registerObjectFinderNamed:name];
+ }
+
+ RETAIN(description);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(defaultPool);
+ RELEASE(description);
+
+ RELEASE(infoCache);
+ RELEASE(objectFinders);
+ RELEASE(loadedBundles);
+
+ [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.
+ This method is used internally to add classes provided by modules.
+*/
+- (void)addClassesWithNames:(NSArray *)names
+{
+ [self addNamedObjectsFromDictionary:STClassDictionaryWithNames(names)];
+}
+
+/**
+ Load StepTalk module with the name moduleName. Modules are stored
+ in the Library/StepTalk/Modules directory.
+ */
+
+- (void) loadModule:(NSString *)moduleName
+{
+ NSBundle *bundle;
+
+ bundle = [NSBundle stepTalkBundleWithName:moduleName];
+
+ [self includeBundle:bundle];
+}
+
+/**
+ Include scripting capabilities advertised by the framework with name
+ frameworkName. If the framework is already loaded, nothing
+ happens.
+*/
+- (BOOL)includeFramework:(NSString *)frameworkName
+{
+ NSBundle *bundle;
+
+ bundle = [NSBundle bundleForFrameworkWithName:frameworkName];
+
+ if(!bundle)
+ {
+ return NO;
+ }
+
+ return [self includeBundle:bundle];
+}
+
+/**
+ Include scripting capabilities advertised by the bundle
+ aBundle. If the bundle is already loaded, nothing
+ happens.
+*/
+- (BOOL)includeBundle:(NSBundle *)aBundle
+{
+ STBundleInfo *info;
+
+ /* Ignore already included bundles. */
+ if([loadedBundles containsObject:[aBundle bundlePath]])
+ {
+ NSDebugLog(@"Bundle '%@' already included.", [aBundle bundlePath]);
+ return;
+ }
+
+ info = [STBundleInfo infoForBundle:aBundle];
+
+ if(!info)
+ {
+ return NO;
+ }
+
+ [self addNamedObjectsFromDictionary:[info namedObjects]];
+
+ [self addClassesWithNames:[info publicClassNames]];
+
+ if(!loadedBundles)
+ {
+ loadedBundles = [[NSMutableArray alloc] init];
+ }
+
+ /* FIXME: is this sufficient? */
+ [loadedBundles addObject:[aBundle bundlePath]];
+
+ 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.
+ 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
+{
+ NSEnumerator *enumerator;
+ id obj;
+ id finder;
+
+ obj = [defaultPool objectForKey:objName];
+
+ if(!obj)
+ {
+ enumerator = [objectFinders objectEnumerator];
+ while( (finder = [enumerator nextObject]) )
+ {
+ obj = [finder objectWithName:objName];
+ if(obj)
+ {
+ [defaultPool setObject:obj forKey:objName];
+ break;
+ }
+ }
+ }
+
+ 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
+{
+ STClassInfo *info = nil;
+ NSString *className;
+ NSString *origName;
+ Class class;
+
+ if(!anObject)
+ {
+ anObject = STNil;
+ }
+
+ /* FIXME: temporary solution */
+ if( [anObject isProxy] )
+ {
+ NSDebugLog(@"FIXME: receiver is a distant object");
+ info = [classes objectForKey:@"NSProxy"];
+
+ if(!info)
+ {
+ return [classes objectForKey:@"All"];
+ }
+
+ return info;
+ }
+
+ if([anObject respondsToSelector:@selector(classForScripting)])
+ {
+ class = [anObject classForScripting];
+ }
+ else
+ {
+ class = [anObject class];
+ }
+
+ className = [anObject className];
+
+ if([anObject isClass])
+ {
+ origName = className = [className stringByAppendingString:@" class"];
+
+ NSDebugLLog(@"STSending",
+ @"Looking for class info '%@'...",
+ className);
+
+ info = [infoCache objectForKey:className];
+
+ if(info)
+ {
+ return info;
+ }
+
+ while( !(info = [classes objectForKey:className]) )
+ {
+ class = [class superclass];
+
+ if(!class)
+ {
+ break;
+ }
+
+ className = [[class className] stringByAppendingString:@" class"];
+ NSDebugLLog(@"STSending",
+ @" ... %@?",className);
+ }
+ }
+ else
+ {
+ origName = className;
+
+ NSDebugLLog(@"STSending",
+ @"Looking for class info '%@' (instance)...",
+ className);
+
+ info = [infoCache objectForKey:className];
+ if(info)
+ {
+ return info;
+ }
+
+ while( !(info = [classes objectForKey:className]) )
+ {
+ class = [class superclass];
+ if(!class)
+ {
+ break;
+ }
+ className = [class className];
+ NSDebugLLog(@"STSending",
+ @" ... %@?",className);
+ }
+ }
+
+ if(!info)
+ {
+ NSDebugLLog(@"STSending",
+ @"No class info '%@'",
+ className);
+ return nil;
+ }
+
+ NSDebugLLog(@"STSending",
+ @"Found class info '%@'",
+ className);
+
+ [infoCache setObject:info forKey:origName];
+ return info;
+}
+
+- (NSString *)translateSelector:(NSString *)aString forReceiver:(id)anObject
+{
+ STClassInfo *class;
+ NSString *selector;
+
+ class = [self findClassInfoForObject:anObject];
+
+ NSDebugLLog(@"STSending",
+ @"Lookup selector '%@' class %@", aString, [class behaviourName]);
+
+ selector = [class translationForSelector:aString];
+
+ NSDebugLLog(@"STSending",
+ @"Found selector '%@'",selector);
+
+#ifdef DEBUG
+ if(! [selector isEqualToString:aString])
+ {
+ NSDebugLLog(@"STSending",
+ @"using selector '%@' instead of '%@'",
+ selector,aString);
+ }
+#endif
+
+ if(!selector && fullScripting )
+ {
+ NSDebugLLog(@"STSending",
+ @"using selector '%@' (full scriptig)",
+ aString);
+
+ selector = AUTORELEASE([aString copy]);
+ }
+
+ if(!selector)
+ {
+ [NSException raise:STScriptingException
+ format:@"Receiver of type %@ denies selector '%@'",
+ [anObject className],aString];
+
+ /* if exception is ignored, then try to use original selector */
+ selector = AUTORELEASE([aString copy]);
+ }
+
+
+ return selector;
+}
+
+- (NSArray *)knownObjectNames
+{
+ NSMutableArray *array = [NSMutableArray array];
+ NSEnumerator *enumerator;
+ id finder;
+
+ [array addObjectsFromArray:[defaultPool allKeys]];
+
+ enumerator = [objectFinders objectEnumerator];
+ while( (finder = [enumerator nextObject]) )
+ {
+ [array addObjectsFromArray:[finder knownObjectNames]];
+ }
+
+ return [NSArray arrayWithArray:array];
+}
+
+/** Register object finder finder under the name name */
+- (void)registerObjectFinder:(id)finder name:(NSString*)name
+{
+ if(!objectFinders)
+ {
+ objectFinders = [[NSMutableDictionary alloc] init];
+ }
+
+ [objectFinders setObject:finder forKey:name];
+}
+
+/** Register object finder named name. This method will try to find
+ an object finder bundle in Library/StepTalk/Finders directories.
+*/
+- (void)registerObjectFinderNamed:(NSString *)name
+{
+ NSBundle *bundle;
+ NSString *path;
+ id finder;
+
+ if([objectFinders objectForKey:name])
+ {
+ return;
+ }
+
+ path = STFindResource(name, @"Finders", @"bundle");
+
+ if(!path)
+ {
+ NSLog(@"Unknown object finder with name '%@'", name);
+ return;
+ }
+
+ NSDebugLog(@"Finder '%@'", path);
+
+ bundle = [NSBundle bundleWithPath:path];
+ if(!bundle)
+ {
+ NSLog(@"Unable to load object finder bundle '%@'", path);
+ return;
+ }
+
+ finder = [[[bundle principalClass] alloc] init];
+ if(!finder)
+ {
+ NSLog(@"Unable to create object finder from '%@'", path);
+ return;
+ }
+
+ [self registerObjectFinder:finder name:name];
+}
+
+/** Remove object finder with name name */
+- (void)removeObjectFinderWithName:(NSString *)name
+{
+ [objectFinders removeObjectForKey:name];
+}
+
+@end
diff --git a/Frameworks/StepTalk/STEnvironmentDescription.h b/Frameworks/StepTalk/STEnvironmentDescription.h
new file mode 100644
index 0000000..8e56126
--- /dev/null
+++ b/Frameworks/StepTalk/STEnvironmentDescription.h
@@ -0,0 +1,66 @@
+/**
+ STEnvironmentDescription.h
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000 Jun 16
+
+ 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
+
+ */
+
+#import
+
+enum
+{
+ STUndefinedRestriction,
+ STAllowAllRestriction,
+ STDenyAllRestriction
+};
+
+@class NSDictionary;
+@class NSMutableArray;
+@class NSMutableDictionary;
+
+@interface STEnvironmentDescription:NSObject
+{
+ NSMutableArray *usedDefs;
+ NSMutableDictionary *classes;
+ NSMutableDictionary *behaviours;
+ NSMutableDictionary *aliases;
+ NSMutableArray *modules;
+ NSMutableArray *finders;
+
+ int restriction;
+}
++ (NSString *)defaultEnvironmentDescriptionName;
+
++ descriptionWithName:(NSString *)descriptionName;
++ descriptionFromDictionary:(NSDictionary *)dictionary;
+
+- initWithName:(NSString *)defName;
+- initFromDictionary:(NSDictionary *)def;
+
+- (void)updateFromDictionary:(NSDictionary *)def;
+- (void)updateClassWithName:(NSString *)className description:(NSDictionary *)def;
+
+- (NSMutableDictionary *)classes;
+- (NSArray *)modules;
+- (NSArray *)objectFinders;
+@end
+
diff --git a/Frameworks/StepTalk/STEnvironmentDescription.m b/Frameworks/StepTalk/STEnvironmentDescription.m
new file mode 100644
index 0000000..885b3c0
--- /dev/null
+++ b/Frameworks/StepTalk/STEnvironmentDescription.m
@@ -0,0 +1,495 @@
+/**
+ STEnvironmentDescription.m
+ Compiled scripting environment description
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000 Jun 16
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+static NSDictionary *dictForDescriptionWithName(NSString *defName)
+{
+ NSString *file;
+ NSDictionary *dict;
+
+ file = STFindResource(defName,
+ STScriptingEnvironmentsDirectory,
+ STScriptingEnvironmentExtension);
+
+ if(!file)
+ {
+ [NSException raise:STGenericException
+ format: @"Could not find "
+ @"environment description with name '%@'.",
+ defName];
+ return nil;
+ }
+
+ dict = [NSDictionary dictionaryWithContentsOfFile:file];
+
+ if(!dict)
+ {
+ [NSException raise:STGenericException
+ format:@"Error while opening "
+ @"environment description with name '%@'.",
+ defName];
+
+ return nil;
+ }
+
+ return dict;
+}
+
+@interface STEnvironmentDescription(PrivateMethods)
+- (void)updateFromDictionary:(NSDictionary *)def;
+- (void)updateUseListFromDictionary:(NSDictionary *)def;
+- (void)updateBehavioursFromDictionary:(NSDictionary *)aDict;
+- (void)updateBehaviour:(STBehaviourInfo *)behInfo
+ description:(NSDictionary *)def;
+- (void)updateClassesFromDictionary:(NSDictionary *)def;
+- (void)updateClassWithName:(NSString *)className description:(NSDictionary *)def;
+- (void)updateAliasesFromDictionary:(NSDictionary *)def;
+- (void)fixupScriptingDescription;
+- (void)resolveSuperclasses;
+
+- (void)updateUseList:(NSArray *)array;
+- (void)updateModuleList:(NSArray *)array;
+- (void)updateFinderList:(NSArray *)array;
+@end
+
+@implementation STEnvironmentDescription
++ (NSString *)defaultEnvironmentDescriptionName
+{
+ NSUserDefaults *defs;
+ NSString *name;
+
+ defs = [NSUserDefaults standardUserDefaults];
+ name = [defs objectForKey:@"STDefaultEnvironmentDescriptionName"];
+
+ if(!name || [name isEqualToString:@""])
+ {
+ name = [NSString stringWithString:@"Standard"];
+ }
+
+ return name;
+}
+
++ descriptionWithName:(NSString *)descriptionName
+{
+ return AUTORELEASE([[self alloc] initWithName:descriptionName]);
+}
++ descriptionFromDictionary:(NSDictionary *)dictionary
+{
+ return AUTORELEASE([[self alloc] initFromDictionary:dictionary]);
+}
+- (void)dealloc
+{
+ RELEASE(usedDefs);
+ RELEASE(classes);
+ RELEASE(behaviours);
+ RELEASE(aliases);
+ RELEASE(modules);
+ RELEASE(finders);
+
+ [super dealloc];
+}
+
+- initWithName:(NSString *)defName;
+{
+ return [self initFromDictionary:dictForDescriptionWithName(defName)];
+}
+
+- initFromDictionary:(NSDictionary *)def
+{
+ if(!def)
+ {
+ [self dealloc];
+ return nil;
+ }
+
+ [self updateFromDictionary:def];
+ [self fixupScriptingDescription];
+
+ return self;
+}
+
+- (void)updateFromDictionary:(NSDictionary *)def
+{
+ NSString *str;
+ BOOL saveFlag = restriction;
+
+ if(!def)
+ {
+ NSLog(@"Warning: nil dictionary for environmet description update");
+ return;
+ };
+
+ str = [def objectForKey:@"DefaultRestriction"];
+
+ if(str)
+ {
+ str = [str lowercaseString];
+
+ if([str isEqualToString:@"allowall"])
+ {
+ restriction = STAllowAllRestriction;
+ }
+ else if([str isEqualToString:@"denyall"])
+ {
+ restriction = STDenyAllRestriction;
+ }
+ else
+ {
+ [NSException raise:STGenericException
+ format:@"Invalid default restriction rule '%@'.",
+ str];
+ return;
+ }
+ }
+
+ [self updateUseList:[def objectForKey:@"Use"]];
+ [self updateModuleList:[def objectForKey:@"Modules"]];
+ [self updateFinderList:[def objectForKey:@"Finders"]];
+ [self updateBehavioursFromDictionary:[def objectForKey:@"Behaviours"]];
+ [self updateClassesFromDictionary:[def objectForKey:@"Classes"]];
+ [self updateAliasesFromDictionary:[def objectForKey:@"Aliases"]];
+
+ restriction = saveFlag;
+}
+
+- (void)updateUseList:(NSArray *)array
+{
+ NSEnumerator *enumerator;
+ NSString *str;
+
+ enumerator = [array objectEnumerator];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ if(!usedDefs)
+ {
+ usedDefs = [[NSMutableArray alloc] init];
+ }
+
+ if( ![usedDefs containsObject:str] )
+ {
+ [usedDefs addObject:str];
+ [self updateFromDictionary:dictForDescriptionWithName(str)];
+ }
+
+ }
+}
+
+- (void)updateModuleList:(NSArray *)array
+{
+ NSEnumerator *enumerator;
+ NSString *str;
+
+ enumerator = [array objectEnumerator];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ if(!modules)
+ {
+ modules = [[NSMutableArray alloc] init];
+ }
+
+ if( ![modules containsObject:str] )
+ {
+ [modules addObject:str];
+ }
+ }
+}
+
+- (void)updateFinderList:(NSArray *)array
+{
+ NSEnumerator *enumerator;
+ NSString *str;
+
+ enumerator = [array objectEnumerator];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ if(!finders)
+ {
+ finders = [[NSMutableArray alloc] init];
+ }
+
+ if( ![finders containsObject:str] )
+ {
+ [finders addObject:str];
+ }
+ }
+}
+
+- (void)updateBehavioursFromDictionary:(NSDictionary *)dict
+{
+ NSEnumerator *enumerator;
+ NSString *name;
+
+ STBehaviourInfo *behInfo;
+
+ enumerator = [dict keyEnumerator];
+
+ while( (name = [enumerator nextObject]) )
+ {
+ if([behaviours objectForKey:name])
+ {
+ [NSException raise:STGenericException
+ format:@"Behaviour '%@' defined more than once.",
+ name];
+ return;
+ }
+
+ if(!behaviours)
+ {
+ behaviours = [[NSMutableDictionary alloc] init];
+ }
+
+ behInfo = [[STBehaviourInfo alloc] initWithName:name];
+ [behaviours setObject:behInfo forKey:name];
+
+ [self updateBehaviour:behInfo description:[dict objectForKey:name]];
+ }
+
+}
+
+- (void)updateBehaviour:(STBehaviourInfo *)behInfo
+ description:(NSDictionary *)def
+{
+ NSString *str;
+ NSEnumerator *enumerator;
+ STBehaviourInfo *useInfo;
+
+
+ enumerator = [[def objectForKey:@"Use"] objectEnumerator];
+ while( (str = [enumerator nextObject]) )
+ {
+ useInfo = [behaviours objectForKey:str];
+ if(!useInfo)
+ {
+ [NSException raise:STGenericException
+ format:@"Undefined behaviour '%@'.",
+ str];
+ return;
+ }
+
+ [behInfo adopt:useInfo];
+ }
+
+ [behInfo allowMethods:[NSSet setWithArray:[def objectForKey:@"AllowMethods"]]];
+ [behInfo denyMethods:[NSSet setWithArray:[def objectForKey:@"DenyMethods"]]];
+
+ [behInfo addTranslationsFromDictionary:[def objectForKey:@"SymbolicSelectors"]];
+
+ [behInfo addTranslationsFromDictionary:[def objectForKey:@"Aliases"]];
+}
+
+- (void)updateClassesFromDictionary:(NSDictionary *)dict
+{
+ NSEnumerator *enumerator;
+ NSString *str;
+
+ enumerator = [dict keyEnumerator];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ [self updateClassWithName:str
+ description:[dict objectForKey:str]];
+ }
+
+}
+
+- (void)updateClassWithName:(NSString *)className description:(NSDictionary *)def
+{
+ STClassInfo *class;
+ NSString *superName;
+ NSString *flag;
+ NSString *str;
+
+ BOOL newClass = NO;
+
+ if(!classes)
+ {
+ classes = [[NSMutableDictionary alloc] init];
+ }
+
+ class = [classes objectForKey:className];
+
+ if( !class )
+ {
+ class = [[STClassInfo alloc] initWithName:className];
+ [classes setObject:class forKey:className];
+ newClass = YES;
+ }
+
+ str = [def objectForKey:@"Super"];
+ superName = [class superclassName];
+
+ if(str && (![str isEqualToString:superName]))
+ {
+ if(newClass | (superName == nil))
+ {
+ [class setSuperclassName:str];
+ }
+ else
+ {
+ [NSException raise:STGenericException
+ format:@"Trying to change superclass of '%@' "
+ @"from '%@' to '%@'",
+ className,[class superclassName],str];
+ return;
+ }
+ }
+
+ [self updateBehaviour:class description:def];
+
+ flag = [def objectForKey:@"Restriction"];
+
+ NSDebugLLog(@"STEnvironment", @"Class %@ restriction %@ (default %i)",
+ className, flag, restriction);
+
+ if(flag)
+ {
+ flag = [flag lowercaseString];
+
+ if([flag isEqualToString:@"allowall"])
+ {
+ [class setAllowAllMethods:YES];
+ }
+ else if([flag isEqualToString:@"denyall"])
+ {
+ [class setAllowAllMethods:NO];
+ }
+ else
+ {
+ [NSException raise:STGenericException
+ format:@"Invalid method restriction rule '%@'.",
+ flag];
+ return;
+ }
+ }
+ else
+ {
+ if(restriction == STAllowAllRestriction)
+ {
+ [class setAllowAllMethods:YES];
+ }
+ else if (restriction == STDenyAllRestriction)
+ {
+ [class setAllowAllMethods:NO];
+ }
+ }
+}
+
+- (void)updateAliasesFromDictionary:(NSDictionary *)dict
+{
+ NSEnumerator *enumerator;
+ NSString *str;
+
+ enumerator = [dict keyEnumerator];
+
+ while( (str = [enumerator nextObject]) )
+ {
+ [aliases setObject:str forKey:[dict objectForKey:str]];
+ }
+}
+
+- (NSMutableDictionary *)classes
+{
+ return classes;
+}
+
+- (NSArray *)modules
+{
+ return [NSArray arrayWithArray:modules];
+}
+
+- (NSArray *)objectFinders
+{
+ return [NSArray arrayWithArray:finders];
+}
+
+
+- (void)fixupScriptingDescription
+{
+ [self resolveSuperclasses];
+}
+
+- (void)resolveSuperclasses
+{
+ NSEnumerator *enumerator;
+ STClassInfo *superclass;
+ STClassInfo *class;
+ NSString *className;
+
+ enumerator = [classes objectEnumerator];
+
+ while( (class = [enumerator nextObject]) )
+ {
+ if([[class behaviourName] isEqualToString:@"All"])
+ {
+ continue;
+ }
+
+ className = [class superclassName];
+
+ if( (className == nil) || [className isEqualToString:@"nil"] )
+ {
+ superclass = [classes objectForKey:@"All"];
+
+ if(!superclass)
+ {
+ continue;
+ }
+ }
+ else
+ {
+ superclass = [classes objectForKey:className];
+ }
+
+ if(!superclass)
+ {
+ [NSException raise:STGenericException
+ format:@"Resolving superclasses: "
+ @"Could not find class '%@'.", className];
+ return;
+ }
+
+ [class setSuperclassInfo:superclass];
+ }
+}
+@end
diff --git a/Frameworks/StepTalk/STExterns.h b/Frameworks/StepTalk/STExterns.h
new file mode 100644
index 0000000..3a5f376
--- /dev/null
+++ b/Frameworks/StepTalk/STExterns.h
@@ -0,0 +1,57 @@
+/**
+ STExterns.h
+ Misc. variables
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+ */
+
+@class NSString;
+@class STUndefinedObject;
+
+extern STUndefinedObject *STNil;
+
+/* exceptions */
+
+extern NSString *STGenericException; /* can be ignored */
+extern NSString *STInvalidArgumentException;
+extern NSString *STInternalInconsistencyException; /* not recoverable */
+extern NSString *STScriptingException;
+
+extern NSString *STLibraryDirectory;
+
+extern NSString *STScriptExtension;
+extern NSString *STScriptsDirectory;
+
+extern NSString *STScriptingEnvironmentsDirectory;
+extern NSString *STScriptingEnvironmentExtension;
+
+extern NSString *STModulesDirectory;
+extern NSString *STModuleExtension;
+
+extern NSString *STLanguageBundlesDirectory;
+extern NSString *STLanguageBundleExtension;
+
+extern NSString *STLanguagesConfigFile;
+
+/* malloc zone */
+extern NSZone *STMallocZone;
+
diff --git a/Frameworks/StepTalk/STExterns.m b/Frameworks/StepTalk/STExterns.m
new file mode 100644
index 0000000..d8ea6db
--- /dev/null
+++ b/Frameworks/StepTalk/STExterns.m
@@ -0,0 +1,55 @@
+/**
+ STExterns.m
+ Misc. variables
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+
+NSString *STGenericException = @"STGenericException";
+NSString *STInvalidArgumentException = @"STInvalidArgumentException";
+NSString *STInternalInconsistencyException = @"STInternalInconsistencyException";
+NSString *STRangeException = @"STRangeException";
+NSString *STScriptingException = @"STScriptingException";
+
+NSString *STCompilerSyntaxException = @"STCompilerSyntaxException";
+NSString *STCompilerGenericException = @"STCompilerGenericException";
+NSString *STCompilerInconsistencyException = @"STCompilerInconsistencyException";
+
+NSString *STInterpreterGenericException = @"STInterpreterGenericException";
+NSString *STInvalidBytecodeException = @"STInterpreterInvalidBytecodeException";
+NSString *STInterpreterInconsistencyException = @"STInterpreterInconsistencyException";
+
+
+NSString *STLibraryDirectory = @"StepTalk";
+NSString *STScriptsDirectory = @"Scripts";
+
+NSString *STModulesDirectory = @"Modules";
+NSString *STModuleExtension = @"bundle";
+
+NSString *STScriptingEnvironmentsDirectory = @"Environments";
+NSString *STScriptingEnvironmentExtension = @"stenv";
+
+NSString *STLanguageBundlesDirectory = @"Languages";
+NSString *STLanguageBundleExtension = @"stlanguage";
+
+NSString *STLanguagesConfigFile = @"Languages.plist";
diff --git a/Frameworks/StepTalk/STFunctions.h b/Frameworks/StepTalk/STFunctions.h
new file mode 100644
index 0000000..08b8746
--- /dev/null
+++ b/Frameworks/StepTalk/STFunctions.h
@@ -0,0 +1,38 @@
+/**
+ STFunctions.h
+ Misc. functions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+
+#import
+
+@class NSString;
+
+NSArray *STFindAllResources(NSString *resourceDir, NSString *extension);
+NSString *STFindResource(NSString *name,
+ NSString *resourceDir,
+ NSString *extension);
+NSString *STUserConfigPath(void);
+
diff --git a/Frameworks/StepTalk/STFunctions.m b/Frameworks/StepTalk/STFunctions.m
new file mode 100644
index 0000000..b7c46b4
--- /dev/null
+++ b/Frameworks/StepTalk/STFunctions.m
@@ -0,0 +1,130 @@
+/**
+ STFunctions.m
+ Misc. functions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+
+
+NSString *STFindResource(NSString *name,
+ NSString *resourceDir,
+ NSString *extension)
+{
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSArray *paths;
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSString *file;
+
+ paths = NSStandardLibraryPaths();
+
+ enumerator = [paths objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+
+ file = [path stringByAppendingPathComponent:STLibraryDirectory];
+ file = [file stringByAppendingPathComponent:resourceDir];
+ file = [file stringByAppendingPathComponent:name];
+
+ if( [manager fileExistsAtPath:file isDirectory:NO] )
+ {
+ return file;
+ }
+
+ file = [file stringByAppendingPathExtension:extension];
+
+ if( [manager fileExistsAtPath:file isDirectory:NO] )
+ {
+ return file;
+ }
+ }
+ return nil;
+}
+
+NSArray *STFindAllResources(NSString *resourceDir, NSString *extension)
+{
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSDirectoryEnumerator *dirs;
+
+ NSArray *paths;
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSString *file;
+ NSMutableArray *resources = [NSMutableArray array];
+
+ paths = NSStandardLibraryPaths();
+
+ enumerator = [paths objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ path = [path stringByAppendingPathComponent:STLibraryDirectory];
+ path = [path stringByAppendingPathComponent:resourceDir];
+
+ if( ![manager fileExistsAtPath:path] )
+ {
+ continue;
+ }
+
+ dirs = [manager enumeratorAtPath:path];
+
+ while( (file = [dirs nextObject]) )
+ {
+ if( [[[dirs directoryAttributes] fileType]
+ isEqualToString:NSFileTypeDirectory]
+ && [[file pathExtension] isEqualToString:extension])
+ {
+ file = [path stringByAppendingPathComponent:file];
+ [resources addObject:file];
+ }
+ }
+ }
+
+ return [NSArray arrayWithArray:resources];
+}
+
+NSString *STUserConfigPath(void)
+{
+ NSString *path = nil;
+ NSArray *paths;
+
+ paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
+ NSUserDomainMask, YES);
+ path = [paths objectAtIndex: 0];
+
+ path = [path stringByAppendingPathComponent:STLibraryDirectory];
+ path = [path stringByAppendingPathComponent:@"Configuration"];
+
+ return path;
+}
diff --git a/Frameworks/StepTalk/STLanguage.h b/Frameworks/StepTalk/STLanguage.h
new file mode 100644
index 0000000..ddcb10f
--- /dev/null
+++ b/Frameworks/StepTalk/STLanguage.h
@@ -0,0 +1,46 @@
+/**
+ STLanguage.h
+ StepTalk language bundle
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2001 Oct 24
+
+ 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
+
+ */
+
+#import
+
+@class STEngine;
+
+@interface STLanguage:NSBundle
++ (NSArray *)allLanguageNames;
++ (NSString *)defaultLanguageName;
++ (NSArray *)allKnownFileTypes;
+
++ languageWithName:(NSString *)languageName;
++ languageWithPath:(NSString *)path;
+
++ (NSString *)languageNameForFileType:(NSString *)fileType;
++ (STLanguage *)languageForFileType:(NSString *)fileType;
+
+- (NSString *)languageName;
+
+- (STEngine *)engine;
+@end
diff --git a/Frameworks/StepTalk/STLanguage.m b/Frameworks/StepTalk/STLanguage.m
new file mode 100644
index 0000000..8deff38
--- /dev/null
+++ b/Frameworks/StepTalk/STLanguage.m
@@ -0,0 +1,224 @@
+/**
+ STLanguage.m
+ StepTalk language bundle
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2001 Oct 24
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+static NSDictionary *fileTypeDictionary = nil;
+
+@implementation STLanguage
+/** Returns an array containing the names of all available languages*/
++ (NSArray *)allLanguageNames
+{
+ NSArray *bundles;
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSMutableArray *languages = [NSMutableArray array];
+ STLanguage *lang;
+
+ bundles = STFindAllResources(STLanguageBundlesDirectory,
+ STLanguageBundleExtension);
+
+ enumerator = [bundles objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ lang = [STLanguage languageWithPath:path];
+
+ [languages addObject:[lang languageName]];
+ }
+
+ return AUTORELEASE([languages copy]);
+}
+
+/** Returns the name of default scripting language specified by the
+ STDefaultLanguageName default. If there is no such default in user's
+ defaults database, then Smalltalk is used. */
+
++ (NSString *)defaultLanguageName
+{
+ NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
+ NSString *name= [defs objectForKey:@"STDefaultLanguageName"];
+
+ if(!name)
+ {
+ return @"Smalltalk";
+ }
+ else
+ {
+ return name;
+ }
+}
+
+/** Returns language bundle for a language with name languageName */
++ languageWithName:(NSString *)languageName
+{
+ NSString *file = STFindResource(languageName, STLanguageBundlesDirectory,
+ STLanguageBundleExtension);
+ if(!file)
+ {
+ NSLog(@"Could not find language with name '%@'", languageName);
+ return nil;
+ }
+
+ return [self languageWithPath:file];
+
+}
+
+/** Returns language bundle for language with name languageName. */
++ languageWithPath:(NSString *)path
+{
+ if(!path)
+ {
+ return nil;
+ }
+
+ return AUTORELEASE([[STLanguage alloc] initWithPath:path]);
+}
+/** Update information about handling various files with StepTalk. */
++ (NSDictionary *)updateFileTypeDictionary
+{
+ NSString *path = STUserConfigPath();
+ NSFileManager *fm = [NSFileManager defaultManager];
+ NSTask *task;
+ NSDictionary *dict;
+
+ RELEASE(fileTypeDictionary);
+
+ path = [path stringByAppendingPathComponent:STLanguagesConfigFile];
+
+ if( ![fm fileExistsAtPath:path])
+ {
+ NSLog(@"Creating lanugages configuration file...");
+ task = [NSTask launchedTaskWithLaunchPath:@"stupdate_languages"
+ arguments:nil];
+ [task waitUntilExit];
+ }
+
+ if( ![fm fileExistsAtPath:path])
+ {
+ [NSException raise:STGenericException
+ format:@"Unable to get languages configuration file"];
+ return nil;
+ }
+
+ dict = [NSDictionary dictionaryWithContentsOfFile:path];
+ fileTypeDictionary = [dict objectForKey:@"STFileTypes"];
+
+ RETAIN(fileTypeDictionary);
+}
+/** Returns name of a language used by files of type fileType. */
++ (NSString *)languageNameForFileType:(NSString *)fileType
+{
+ if(!fileTypeDictionary)
+ {
+ [self updateFileTypeDictionary];
+ }
+
+ return [fileTypeDictionary objectForKey:fileType];
+}
+
+/** Return all known types (extensions) of StepTalk script files */
++ (NSArray *)allKnownFileTypes
+{
+ if(!fileTypeDictionary)
+ {
+ [self updateFileTypeDictionary];
+ }
+
+ return [fileTypeDictionary allKeys];
+}
+
+/** Returns the language bundle for a language used by files of type
+ fileType. */
++ (STLanguage *)languageForFileType:(NSString *)fileType
+{
+ NSString *langName = [STLanguage languageNameForFileType:fileType];
+
+ if(langName)
+ {
+ return [STLanguage languageWithName:langName];
+ }
+
+ [NSException raise:STGenericException
+ format:@"Unknown language for file type '%@'", fileType];
+
+ return nil;
+}
+
+/** Returns the name of the language */
+- (NSString *)languageName
+{
+ NSString *name;
+
+ name = [[self infoDictionary] objectForKey:@"STLanguageName"];
+
+ if(!name)
+ {
+
+ name = [[self bundlePath] lastPathComponent];
+ name = [name stringByDeletingPathExtension];
+ }
+
+ return name;
+}
+
+/** Returns a scripting engine provided by the language. */
+- (STEngine *)engine
+{
+ NSString *className =[[self infoDictionary] objectForKey:@"STEngine"];
+ Class engineClass = nil;
+ STEngine *engine;
+
+ if(className)
+ {
+ engineClass = [self classNamed:className];
+ }
+
+ if(!engineClass)
+ {
+ engineClass = [self principalClass];
+ }
+
+ engine = [[engineClass alloc] init];
+
+ return AUTORELEASE(engine);
+}
+
+@end
diff --git a/Frameworks/StepTalk/STMethod.h b/Frameworks/StepTalk/STMethod.h
new file mode 100644
index 0000000..21e12ac
--- /dev/null
+++ b/Frameworks/StepTalk/STMethod.h
@@ -0,0 +1,33 @@
+/**
+ STMethod
+
+ Copyright (c) 2003 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2003 Aug 6
+
+ 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
+
+@protocol STMethod
+- (NSString *)source;
+- (NSString *)methodName;
+- (NSString *)languageName;
+@end
diff --git a/Frameworks/StepTalk/STMethod.m b/Frameworks/StepTalk/STMethod.m
new file mode 100644
index 0000000..d281c65
--- /dev/null
+++ b/Frameworks/StepTalk/STMethod.m
@@ -0,0 +1,29 @@
+/**
+ STMethod
+
+ Copyright (c) 2003 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2003 Aug 6
+
+ 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
+
+/* Nothig here */
diff --git a/Frameworks/StepTalk/STObjCRuntime.h b/Frameworks/StepTalk/STObjCRuntime.h
new file mode 100644
index 0000000..0d0649b
--- /dev/null
+++ b/Frameworks/StepTalk/STObjCRuntime.h
@@ -0,0 +1,44 @@
+/**
+ STObjCRuntime.m
+ Objective C runtime additions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+
+@class NSMutableDictionary;
+@class NSString;
+@class NSValue;
+@class NSMethodSignature;
+
+extern NSMutableDictionary *STAllObjectiveCClasses(void);
+extern NSMutableDictionary *STGetFoundationConstants(void);
+extern NSDictionary *STClassDictionaryWithNames(NSArray *classNames);
+extern NSArray *STAllObjectiveCSelectors(void);
+
+extern NSValue *STValueFromSelector(SEL sel);
+extern SEL STSelectorFromValue(NSValue *val);
+extern SEL STSelectorFromString(NSString *aString);
+extern NSMethodSignature *STMethodSignatureForSelector(SEL sel);
+
diff --git a/Frameworks/StepTalk/STObjCRuntime.m b/Frameworks/StepTalk/STObjCRuntime.m
new file mode 100644
index 0000000..43412f1
--- /dev/null
+++ b/Frameworks/StepTalk/STObjCRuntime.m
@@ -0,0 +1,262 @@
+/**
+ STObjCRuntime.m
+ Objective C runtime additions
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+#define SELECTOR_TYPES_COUNT 6
+
+static const char *selector_types[] =
+ {
+ "@8@0:4",
+ "@12@0:4@8",
+ "@16@0:4@8@12",
+ "@20@0:4@8@12@16",
+ "@24@0:4@8@12@16@20",
+ "@28@0:4@8@12@16@20@24"
+ };
+
+NSMutableDictionary *STAllObjectiveCClasses(void)
+{
+ NSString *name;
+ NSMutableDictionary *dict;
+ void *state = NULL;
+ Class class;
+
+ dict = [NSMutableDictionary dictionary];
+
+ while( (class = objc_next_class(&state)) )
+ {
+ name = [NSString stringWithCString:class_get_class_name(class)];
+
+ [dict setObject:class forKey:name];
+ }
+
+// NSLog(@"%i Objective-C classes found",[dict count]);
+
+ return dict;
+}
+
+NSDictionary *STClassDictionaryWithNames(NSArray *classNames)
+{
+ NSEnumerator *enumerator = [classNames objectEnumerator];
+ NSString *className;
+ NSMutableDictionary *dict = [NSMutableDictionary dictionary];
+ Class class;
+
+ while( (className = [enumerator nextObject]) )
+ {
+ class = NSClassFromString(className);
+ if(class)
+ {
+ [dict setObject:NSClassFromString(className) forKey:className];
+ }
+ else
+ {
+ NSLog(@"Warning: Class with name '%@' not found", className);
+ }
+ }
+
+ return [NSDictionary dictionaryWithDictionary:dict];
+}
+
+NSValue *STValueFromSelector(SEL sel)
+{
+ return [NSValue value:&sel withObjCType:@encode(SEL)];
+}
+
+SEL STSelectorFromValue(NSValue *val)
+{
+ SEL sel;
+ [val getValue:&sel];
+ return sel;
+}
+
+SEL STSelectorFromString(NSString *aString)
+{
+ const char *name = [aString cString];
+ const char *ptr;
+ int argc = 0;
+
+ SEL sel;
+
+ sel = NSSelectorFromString(aString);
+ if(!sel)
+ {
+
+ ptr = name;
+
+ while(*ptr)
+ {
+ if(*ptr == ':')
+ {
+ argc ++;
+ }
+ ptr++;
+ }
+
+ if( argc < SELECTOR_TYPES_COUNT )
+ {
+ NSDebugLLog(@"STSending",
+ @"registering selector '%s' "
+ @"with %i arguments, types:'%s'",
+ name,argc,selector_types[argc]);
+
+ sel = sel_register_typed_name(name, selector_types[argc]);
+ }
+
+ if(!sel)
+ {
+ [NSException raise:STInternalInconsistencyException
+ format:@"Unable to register selector '%@'",
+ aString];
+ return NULL;
+ }
+ }
+ else
+ {
+ /* FIXME: temporary hack */
+ }
+
+ return sel;
+}
+
+SEL STCreateTypedSelector(SEL sel)
+{
+ const char *name = sel_get_name(sel);
+ const char *ptr;
+ int argc = 0;
+
+ SEL newSel;
+
+ ptr = name;
+
+ while(*ptr)
+ {
+ if(*ptr == ':')
+ {
+ argc ++;
+ }
+ ptr++;
+ }
+
+ if( argc < SELECTOR_TYPES_COUNT )
+ {
+ NSDebugLLog(@"STSending",
+ @"registering selector '%s' "
+ @"with %i arguments, types:'%s'",
+ name,argc,selector_types[argc]);
+
+ newSel = sel_register_typed_name(name, selector_types[argc]);
+ }
+
+ if(!newSel)
+ {
+ [NSException raise:STInternalInconsistencyException
+ format:@"Unable to register typed selector '%s'",
+ name];
+ return NULL;
+ }
+
+ return newSel;
+}
+
+NSMethodSignature *STMethodSignatureForSelector(SEL sel)
+{
+ char *types;
+
+ types = sel_get_type(sel);
+
+ if(!types)
+ {
+ sel = STCreateTypedSelector(sel);
+ types = sel_get_type(sel);
+ }
+ return [NSMethodSignature signatureWithObjCTypes:types];
+}
+
+
+static NSArray *selectors_from_list(struct objc_method_list *methods)
+{
+ NSMutableArray *array = [NSMutableArray array];
+ int count = methods->method_count;
+ int i;
+
+ for(i=0;imethod_list[i].method_name)];
+ }
+
+ if(methods->method_next)
+ {
+ [array addObjectsFromArray:selectors_from_list(methods->method_next)];
+ }
+
+ return array;
+}
+
+
+NSArray *STAllObjectiveCSelectors(void)
+{
+ NSMutableArray *array;
+ NSArray *methods;
+ Class class;
+ void *state = NULL;
+
+ array = [[NSMutableArray alloc] init];
+
+ while( (class = objc_next_class(&state)) )
+ {
+ if(class->methods)
+ {
+ methods = selectors_from_list(class->methods);
+ [array addObjectsFromArray:methods];
+ }
+ class = class->class_pointer;
+
+ if(class->methods)
+ {
+ methods = selectors_from_list(class->methods);
+ [array addObjectsFromArray:methods];
+ }
+ }
+
+ /* get rid of duplicates */
+ array = (NSMutableArray *)[[NSSet setWithArray:(NSArray *)array] allObjects];
+ array = (NSMutableArray *)[array sortedArrayUsingSelector:@selector(compare:)];
+
+ return array;
+}
diff --git a/Frameworks/StepTalk/STObjectReference.h b/Frameworks/StepTalk/STObjectReference.h
new file mode 100644
index 0000000..874fe6a
--- /dev/null
+++ b/Frameworks/StepTalk/STObjectReference.h
@@ -0,0 +1,50 @@
+/**
+ STObjectReference.h
+ Reference to object in NSDictionary.
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ This file is part of StepTalk.
+
+ 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
+ */
+
+#import
+
+@class NSString;
+@class NSMutableDictionary;
+
+@interface STObjectReference:NSObject
+{
+ NSString *key;
+ NSMutableDictionary *pool;
+}
+
+- initWithObjectName:(NSString *)name
+ pool:(NSMutableDictionary *)aPool;
+
+- (void)setObject:anObject;
+- object;
+
+- (NSString *)objectName;
+- (void)setObjectName:(NSString *)newName;
+
+- (NSMutableDictionary *) pool;
+- (void)setPool:(NSMutableDictionary *) aDict;
+@end
+
diff --git a/Frameworks/StepTalk/STObjectReference.m b/Frameworks/StepTalk/STObjectReference.m
new file mode 100644
index 0000000..00ee39b
--- /dev/null
+++ b/Frameworks/StepTalk/STObjectReference.m
@@ -0,0 +1,90 @@
+/**
+ STObjectReference.m
+ Reference to object in NSDictionary.
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ This file is part of StepTalk.
+
+ 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
+ */
+
+#import
+
+#import
+
+#import
+#import
+#import
+#import
+
+@implementation STObjectReference
+- initWithObjectName:(NSString *)name pool:(NSMutableDictionary *)aPool
+{
+ self = [super init];
+
+ key = RETAIN(name);
+ pool = RETAIN(aPool);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(key);
+ RELEASE(pool);
+
+ [super dealloc];
+}
+
+- (void)setObject:anObject
+{
+ if(anObject)
+ {
+ [pool setObject:anObject forKey:key];
+ }
+ else
+ {
+ [pool setObject:STNil forKey:key];
+ }
+}
+
+- 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);
+}
+@end
+
diff --git a/Frameworks/StepTalk/STScript.h b/Frameworks/StepTalk/STScript.h
new file mode 100644
index 0000000..695e113
--- /dev/null
+++ b/Frameworks/StepTalk/STScript.h
@@ -0,0 +1,47 @@
+/**
+ STScript
+
+ Copyright (c) 2002 Stefan Urbanek
+
+ Written by: Stefan Urbanek
+ Date: 2002 Mar 10
+
+ 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
+
+ */
+
+#import
+
+@interface STScript:NSObject
+{
+ NSString *fileName;
+ NSString *localizedName;
+ NSString *menuKey;
+ NSString *description;
+ NSString *language;
+}
++ scriptWithFile:(NSString *)file;
+
+- initWithFile:(NSString *)aFile;
+- (NSString *)fileName;
+- (NSString *)source;
+- (NSString *)scriptName;
+- (NSString *)localizedName;
+- (NSString *)scriptDescription;
+- (NSString *)language;
+- (NSComparisonResult)compareByLocalizedName:(STScript *)aScript;
+@end
diff --git a/Frameworks/StepTalk/STScript.m b/Frameworks/StepTalk/STScript.m
new file mode 100644
index 0000000..5d55ee9
--- /dev/null
+++ b/Frameworks/StepTalk/STScript.m
@@ -0,0 +1,186 @@
+/**
+ STScript
+
+ Copyright (c) 2002 Stefan Urbanek
+
+ Written by: Stefan Urbanek
+ Date: 2002 Mar 10
+
+ 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
+
+ */
+
+#import
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+
+@interface NSDictionary(LocalizedKey)
+- (id)localizedObjectForKey:(NSString *)key;
+@end
+
+@implementation NSDictionary(LocalizedKey)
+- (id)localizedObjectForKey:(NSString *)key
+{
+ NSEnumerator *enumerator;
+ NSDictionary *dict;;
+ NSString *language;
+ NSArray *languages;
+ id obj = nil;
+
+ languages = [NSUserDefaults userLanguages];
+
+ enumerator = [languages objectEnumerator];
+
+ while( (language = [enumerator nextObject]) )
+ {
+ dict = [self objectForKey:language];
+ obj = [dict objectForKey:key];
+
+ if(obj)
+ {
+ return obj;
+ }
+ }
+
+ return [[self objectForKey:@"Default"] objectForKey:key];
+}
+@end
+
+@implementation STScript
++ scriptWithFile:(NSString *)file
+{
+ STScript *script;
+
+ script = [[STScript alloc] initWithFile:file];
+
+ return AUTORELEASE(script);
+}
+/**
+ Create a new script from file aFile>. Script information will
+ be read from 'aFile.stinfo' file containing a dictionary property list.
+*/
+
+- initWithFile:(NSString *)aFile
+{
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSDictionary *info = nil;
+ NSString *infoFile;
+ BOOL isDir;
+
+ // infoFile = [aFile stringByDeletingPathExtension];
+ infoFile = [aFile stringByAppendingPathExtension: @"stinfo"];
+
+ if([manager fileExistsAtPath:infoFile isDirectory:&isDir] && !isDir )
+ {
+ info = [NSDictionary dictionaryWithContentsOfFile:infoFile];
+ }
+
+ self = [super init];
+
+ fileName = RETAIN(aFile);
+
+ localizedName = [info localizedObjectForKey:@"Name"];
+
+ if(!localizedName)
+ {
+ localizedName = [[fileName lastPathComponent]
+ stringByDeletingPathExtension];
+ }
+
+ RETAIN(localizedName);
+
+ menuKey = RETAIN([info localizedObjectForKey:@"MenuKey"]);
+ description = RETAIN([info localizedObjectForKey:@"Description"]);
+ language = [info localizedObjectForKey:@"Language"];
+
+ if(!language)
+ {
+ language = [STLanguage languageNameForFileType:[fileName pathExtension]];
+ }
+ if(!language)
+ {
+ language = @"Unknown";
+ }
+
+ RETAIN(language);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(fileName);
+ RELEASE(localizedName);
+ RELEASE(menuKey);
+ RELEASE(description);
+ RELEASE(language);
+ [super dealloc];
+}
+
+/** Return file name of the receiver. */
+- (NSString *)fileName
+{
+ return fileName;
+}
+
+/** Return menu item key equivalent for receiver. */
+- (NSString *)menuKey
+{
+ return menuKey;
+}
+
+/** Returns source string of the receiver script.*/
+- (NSString *)source
+{
+ return [NSString stringWithContentsOfFile:fileName];
+}
+
+/** Returns a script name by which the script is identified */
+- (NSString *)scriptName
+{
+ return fileName;
+}
+
+/** Returns localized name of the receiver script. */
+- (NSString *)localizedName
+{
+ return localizedName;
+}
+
+/** Returns localized description of the script. */
+- (NSString *)scriptDescription
+{
+ return description;
+}
+/** Returns language of the script. */
+- (NSString *)language
+{
+ return language;
+}
+
+/** Compare scripts by localized name. */
+- (NSComparisonResult)compareByLocalizedName:(STScript *)aScript
+{
+ return [localizedName caseInsensitiveCompare:[aScript localizedName]];
+}
+@end
diff --git a/Frameworks/StepTalk/STScriptObject.h b/Frameworks/StepTalk/STScriptObject.h
new file mode 100644
index 0000000..25a2edf
--- /dev/null
+++ b/Frameworks/StepTalk/STScriptObject.h
@@ -0,0 +1,28 @@
+/* 2003 Aug 5 */
+
+#import
+
+@class NSMutableDictionary;
+@class NSDictionary;
+@class NSArray;
+@class STMethod;
+
+@interface STScriptObject:NSObject
+{
+ NSMutableDictionary *ivars;
+ NSMutableDictionary *methods;
+}
+- initWithInstanceVariableNames:(NSString *)names;
+
+- (void)setObject:(id)anObject forVariable:(NSString *)aName;
+- (id)objectForVariable:(NSString *)aName;
+
+- (NSArray *)instanceVariableNames;
+
+- (void)addMethod:(STMethod *)aMethod;
+- (STMethod *)methodWithName:(NSString *)aName;
+- (void)removeMethod:(STMethod *)aMethod;
+- (void)removeMethodWithName:(NSString *)aName;
+- (NSArray *)methodNames;
+- (NSDictionary *)methodDictionary;
+@end
diff --git a/Frameworks/StepTalk/STScriptObject.m b/Frameworks/StepTalk/STScriptObject.m
new file mode 100644
index 0000000..dfddbe2
--- /dev/null
+++ b/Frameworks/StepTalk/STScriptObject.m
@@ -0,0 +1,59 @@
+/* 2003 Aug 5 */
+
+#import "StepTalk/STScriptObject.h"
+
+@implementation STScriptObject
+- initWithInstanceVariableNames:(NSString *)names
+{
+ self = [super init];
+
+ methods = [[NSMutableDictionary alloc] init];
+
+ return self;
+}
+- (void)dealloc
+{
+ RELEASE(methods);
+ RELEASE(ivars);
+ [super dealloc];
+}
+
+- (void)setObject:(id)anObject forVariable:(NSString *)aName
+{
+ [self _notImplemented:_cmd];
+}
+- (id)objectForVariable:(NSString *)aName
+{
+ [self _notImplemented:_cmd];
+}
+
+- (NSArray *)instanceVariableNames
+{
+ [self _notImplemented:_cmd];
+}
+
+- (void)addMethod:(STMethod *)aMethod
+{
+ [methods setObject:aMethod forKey:[aMethod methodName]];
+}
+- (STMethod *)methodWithName:(NSString *)aName
+{
+ return [methods objectForKey:aName];
+}
+- (void)removeMethod:(STMethod *)aMethod
+{
+ [self _notImplemented:_cmd];
+}
+- (void)removeMethodWithName:(NSString *)aName
+{
+ [methods removeObjectForKey:aName];
+}
+- (NSArray *)methodNames
+{
+ return [methods allKeys];
+}
+- (NSDictionary *)methodDictionary
+{
+ return [NSDictionary dictionaryWithDictionary:methods];
+}
+@end
diff --git a/Frameworks/StepTalk/STScripting.h b/Frameworks/StepTalk/STScripting.h
new file mode 100644
index 0000000..66ffe0e
--- /dev/null
+++ b/Frameworks/StepTalk/STScripting.h
@@ -0,0 +1,43 @@
+/**
+ STScripting.h
+ Scripting protocol
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+
+#import
+
+@class STEnvironment;
+
+@protocol STScripting
+- (BOOL)isClass;
++ (BOOL)isClass;
+- (NSString *)className;
++ (NSString *)className;
+- (Class) classForScripting;
++ (Class) classForScripting;
+@end
+
+
+@interface NSObject (STScripting)
+@end
diff --git a/Frameworks/StepTalk/STScripting.m b/Frameworks/StepTalk/STScripting.m
new file mode 100644
index 0000000..abaf52f
--- /dev/null
+++ b/Frameworks/StepTalk/STScripting.m
@@ -0,0 +1,66 @@
+/**
+ STScripting.m
+ Scripting protocol
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ STScripting protocol documentation
+
+ */
+
+#import
+
+@implementation NSObject (STScripting)
+/*
+- (id)replacementForScriptingInEnvironment:(STEnvironment *)env
+{
+ return self;
+}
+*/
+- (BOOL)isClass
+{
+ return NO;
+}
++ (BOOL)isClass
+{
+ return YES;
+}
+
++ (NSString *)className
+{
+ return NSStringFromClass(self);
+}
+- (NSString *)className
+{
+ return [[self class] className];
+}
+
+/*Subclasses should override this method to force use of another class */
+- (Class) classForScripting
+{
+ return [self class];
+}
++ (Class) classForScripting
+{
+ return [self class];
+}
+@end
diff --git a/Frameworks/StepTalk/STScriptsManager.h b/Frameworks/StepTalk/STScriptsManager.h
new file mode 100644
index 0000000..0e11884
--- /dev/null
+++ b/Frameworks/StepTalk/STScriptsManager.h
@@ -0,0 +1,51 @@
+/**
+ STScriptsManager
+
+ Copyright (c)2002 Stefan Urbanek
+
+ Written by: Stefan Urbanek
+ Date: 2002 Mar 10
+
+ 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
+
+ */
+
+#import
+
+@class NSArray;
+@class STScript;
+
+@interface STScriptsManager:NSObject
+{
+ NSString *scriptsDomainName;
+ NSArray *scriptSearchPaths;
+}
++ defaultManager;
+
+- initWithDomainName:(NSString *)name;
+
+- (NSString *)scriptsDomainName;
+
+- (void)setScriptSearchPathsToDefaults;
+- (NSArray *)scriptSearchPaths;
+- (void)setScriptSearchPaths:(NSArray *)anArray;
+
+- (NSArray *)validScriptSearchPaths;
+- (STScript *)scriptWithName:(NSString*)aString;
+
+- (NSArray *)allScripts;
+@end
diff --git a/Frameworks/StepTalk/STScriptsManager.m b/Frameworks/StepTalk/STScriptsManager.m
new file mode 100644
index 0000000..00818e1
--- /dev/null
+++ b/Frameworks/StepTalk/STScriptsManager.m
@@ -0,0 +1,294 @@
+/**
+ STScriptsManager
+
+ Copyright (c)2002 Stefan Urbanek
+
+ Written by: Stefan Urbanek
+ Date: 2002 Mar 10
+
+ 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
+
+ */
+
+#import
+
+#import
+#import
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+static STScriptsManager *sharedScriptsManager = nil;
+
+@interface STScriptsManager (STPriavteMethods)
+- (NSArray *)_scriptsAtPath:(NSString *)path;
+@end
+
+@implementation STScriptsManager
+
+/** Return default domain name for scripts. Usually this is application or
+process name.*/
++ (NSString *)defaultScriptsDomainName
+{
+ return [[NSProcessInfo processInfo] processName];
+}
+
+/** Returns default scripts manager for current process (application or tool). */
++ defaultManager
+{
+ if(!sharedScriptsManager)
+ {
+ sharedScriptsManager = [[STScriptsManager alloc] init];
+ }
+
+ return sharedScriptsManager;
+}
+
+- init
+{
+ return [self initWithDomainName:nil];
+}
+
+/**
+ Initializes the receiver to be used with domain named name.
+ If name is nil, default scripts domain name will be used.
+
+
+*/
+- initWithDomainName:(NSString *)name
+{
+ self = [super init];
+
+ if(!name)
+ {
+ name = [STScriptsManager defaultScriptsDomainName];
+ }
+
+ scriptsDomainName = RETAIN(name);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ RELEASE(scriptsDomainName);
+ [super dealloc];
+}
+
+
+/** Return name of script manager domain. */
+- (NSString *)scriptsDomainName
+{
+ return scriptsDomainName;
+}
+
+/* Sets script search paths to defaults. Default paths are (in this order):
+ /StepTalk/Scripts/.
+ /StepTalk/Scripts/Shared and
+ paths to Resource/Scripts in all loaded bundles including the main bundle.*/
+
+- (void)setScriptSearchPathsToDefaults
+{
+ NSMutableArray *scriptPaths = [NSMutableArray array];
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSString *str;
+ NSArray *paths;
+ NSBundle *bundle;
+
+ paths = NSStandardLibraryPaths();
+
+ enumerator = [paths objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ path = [path stringByAppendingPathComponent:STLibraryDirectory];
+ path = [path stringByAppendingPathComponent:@"Scripts"];
+
+ str = [path stringByAppendingPathComponent: scriptsDomainName];
+ [scriptPaths addObject:str];
+
+ str = [path stringByAppendingPathComponent:@"Shared"];
+ [scriptPaths addObject:str];
+ }
+
+ enumerator = [[NSBundle allBundles] objectEnumerator];
+
+ while( (bundle = [enumerator nextObject]) )
+ {
+ path = [bundle resourcePath];
+ path = [path stringByAppendingPathComponent:@"Scripts"];
+ [scriptPaths addObject:path];
+ }
+
+ RELEASE(scriptSearchPaths);
+ scriptSearchPaths = [[NSArray alloc] initWithArray:scriptPaths];
+}
+
+/**
+ Retrun an array of script search paths. Scripts are searched
+ in Library/StepTalk/Scripts/scriptsDomainName,
+ Library/StepTalk/Scripts/Shared and in all loaded bundles in
+ bundlePath/Resources/Scripts.
+*/
+
+- (NSArray *)scriptSearchPaths
+{
+ if(!scriptSearchPaths)
+ {
+ [self setScriptSearchPathsToDefaults];
+ }
+
+ return scriptSearchPaths;
+}
+
+/** Set script search paths to anArray. */
+- (void)setScriptSearchPaths:(NSArray *)anArray
+{
+ ASSIGN(scriptSearchPaths, anArray);
+}
+
+/** Return script search paths that are valid. That means that path exists and
+ is a directory. */
+- (NSArray *)validScriptSearchPaths
+{
+ NSMutableArray *scriptPaths = [NSMutableArray array];
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSEnumerator *enumerator;
+ NSString *path;
+ NSArray *paths;
+ BOOL isDir;
+
+ paths = [self scriptSearchPaths];
+
+ enumerator = [paths objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ if( [manager fileExistsAtPath:path isDirectory:&isDir] && isDir )
+ {
+ [scriptPaths addObject:path];
+ }
+ }
+
+ return [NSArray arrayWithArray:scriptPaths];
+}
+
+/**
+ Get a script with name aString for current scripting domain.
+*/
+- (STScript *)scriptWithName:(NSString*)aString
+{
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSEnumerator *pEnumerator;
+ NSEnumerator *sEnumerator;
+ NSString *path;
+ NSString *file;
+ NSString *str;
+ NSArray *paths;
+
+ paths = [self validScriptSearchPaths];
+
+ pEnumerator = [paths objectEnumerator];
+
+ while( (path = [pEnumerator nextObject]) )
+ {
+ sEnumerator = [[manager directoryContentsAtPath:path] objectEnumerator];
+
+ while( (file = [sEnumerator nextObject]) )
+ {
+
+ if( ! [[file pathExtension] isEqualToString:@"stinfo"] )
+ {
+ NSDebugLLog(@"STScriptManager", @"Script %@", file);
+
+ str = [file lastPathComponent];
+ str = [str stringByDeletingPathExtension];
+
+ if([str isEqualToString:aString])
+ {
+ return [STScript scriptWithFile:
+ [path stringByAppendingPathComponent:file]];
+ }
+ }
+ }
+
+ }
+
+ return nil;
+}
+
+- (NSArray *)_scriptsAtPath:(NSString *)path
+{
+ NSMutableArray *scripts = [NSMutableArray array];
+ NSFileManager *manager = [NSFileManager defaultManager];
+ NSEnumerator *enumerator;
+ NSString *file;
+ NSString *str;
+ NSString *ext;
+ NSArray *paths;
+ NSSet *types;
+
+ types = [NSSet setWithArray:[STLanguage allKnownFileTypes]];
+
+ enumerator = [[manager directoryContentsAtPath:path] objectEnumerator];
+
+ while( (file = [enumerator nextObject]) )
+ {
+
+ ext = [file pathExtension];
+ if( [types containsObject:ext] )
+ {
+ STScript *script;
+ NSLog(@"Found script %@", file);
+
+ script = [STScript scriptWithFile:
+ [path stringByAppendingPathComponent:file]];
+ [scripts addObject:script];
+ }
+ }
+
+ return [NSArray arrayWithArray:scripts];
+}
+
+/** Return list of all scripts for managed domain. */
+- (NSArray *)allScripts
+{
+ NSMutableArray *scripts = [NSMutableArray array];
+ NSEnumerator *enumerator;
+ NSString *path;
+
+ enumerator = [[self validScriptSearchPaths] objectEnumerator];
+
+ while( (path = [enumerator nextObject]) )
+ {
+ [scripts addObjectsFromArray:[self _scriptsAtPath:path]];
+ }
+
+ return [NSArray arrayWithArray:scripts];
+}
+@end
diff --git a/Frameworks/StepTalk/STSelector.h b/Frameworks/StepTalk/STSelector.h
new file mode 100644
index 0000000..3b769a1
--- /dev/null
+++ b/Frameworks/StepTalk/STSelector.h
@@ -0,0 +1,38 @@
+/*
+ STSelector
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2002 Feb 4
+
+ 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
+
+ */
+
+#import
+
+@interface STSelector:NSObject
+{
+ SEL sel;
+}
+- initWithSelector:(SEL)aSel;
+
+- (SEL)selectorValue;
+- (NSString *)stringValue;
+@end
+
diff --git a/Frameworks/StepTalk/STSelector.m b/Frameworks/StepTalk/STSelector.m
new file mode 100644
index 0000000..9c3e697
--- /dev/null
+++ b/Frameworks/StepTalk/STSelector.m
@@ -0,0 +1,51 @@
+/*
+ STSelector
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2002 Feb 4
+
+ 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
+
+ */
+
+#import
+
+@implementation STSelector
+- initWithSelector:(SEL)aSel
+{
+ [super init];
+ sel = aSel;
+ return self;
+}
+
+- (SEL)selectorValue
+{
+ return sel;
+}
+
+- (NSString *)description
+{
+ return NSStringFromSelector(sel);
+}
+
+- (NSString *)stringValue
+{
+ return NSStringFromSelector(sel);
+}
+@end
diff --git a/Frameworks/StepTalk/STStructure.h b/Frameworks/StepTalk/STStructure.h
new file mode 100644
index 0000000..b1f40bb
--- /dev/null
+++ b/Frameworks/StepTalk/STStructure.h
@@ -0,0 +1,90 @@
+/**
+ STStructure.h
+ C structure wrapper
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ This file is part of StepTalk.
+
+ 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
+ */
+
+#import
+#import
+#import
+
+// @class STRange;
+// @class STPoint;
+// @class STRect;
+@class NSString;
+@class NSMutableArray;
+
+@interface STStructure:NSObject
+{
+ NSString *structType;
+ NSString *name;
+ NSMutableArray *fields;
+}
++ structureWithValue:(void *)value type:(const char*)type;
++ structureWithRange:(NSRange)range;
++ structureWithPoint:(NSPoint)point;
++ structureWithRect:(NSRect)rect;
++ structureWithSize:(NSSize)size;
+
+- initWithValue:(void *)value type:(const char*)type;
+- (const char *)type;
+- (NSString *)structureName;
+
+- (void)getValue:(void *)value;
+
+- (NSRange)rangeValue;
+- (NSPoint)pointValue;
+- (NSRect)rectValue;
+- (NSSize)sizeValue;
+
+- valueAtIndex:(unsigned)index;
+- (void)setValue:anObject atIndex:(unsigned)index;
+
+- (int)intValueAtIndex:(unsigned)index;
+- (float)floatValueAtIndex:(unsigned)index;
+@end
+
+/*
+@interface STRange:STStructure
+- rangeWithLocation:(int)loc length:(int)length;
+- (int)location;
+- (int)length;
+@end
+
+@interface STPoint:STStructure
+- pointWithX:(float)x y:(float)y;
+- (float)x;
+- (float)y;
+@end
+
+@interface STRect:STStructure
+- rectWithX:(float)x y:(float)y width:(float)w heigth:(float)h;
+- rectWithOrigin:(NSPoint)origin size:(NSPoint)size;
+- (float)x;
+- (float)y;
+- (float)width;
+- (float)height;
+- (NSPoint)origin;
+- (NSPoint)size;
+@end
+*/
diff --git a/Frameworks/StepTalk/STStructure.m b/Frameworks/StepTalk/STStructure.m
new file mode 100644
index 0000000..65f45d1
--- /dev/null
+++ b/Frameworks/StepTalk/STStructure.m
@@ -0,0 +1,309 @@
+/**
+ STStructure.m
+ C structure wrapper
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ This file is part of StepTalk.
+
+ 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
+ */
+
+#import
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+@implementation STStructure
++ structureWithValue:(void *)value type:(const char*)type
+{
+ STStructure *str;
+ str = [[self alloc] initWithValue:value type:type];
+ return AUTORELEASE(str);
+}
++ structureWithRange:(NSRange)range
+{
+ STStructure *str;
+ str = [[self alloc] initWithValue:&range type:@encode(NSRange)];
+ return AUTORELEASE(str);
+}
+
++ structureWithPoint:(NSPoint)point
+{
+ STStructure *str;
+ str = [[self alloc] initWithValue:&point type:@encode(NSPoint)];
+ return AUTORELEASE(str);
+}
++ structureWithSize:(NSSize)size
+{
+ STStructure *str;
+ str = [[self alloc] initWithValue:&size type:@encode(NSSize)];
+ return AUTORELEASE(str);
+}
+
++ structureWithRect:(NSRect)rect
+{
+ STStructure *str;
+ str = [[self alloc] initWithValue:&rect type:@encode(NSRect)];
+ return AUTORELEASE(str);
+}
+
+- initWithValue:(void *)value type:(const char*)type
+{
+ const char *nameBeg;
+ int offset = 0;
+ int align;
+ int rem;
+
+
+ self = [super init];
+
+ NSDebugLLog(@"STStructure",
+ @"creating structure of type '%s' value ptr %p",type,value);
+
+ structType = [[NSString alloc] initWithCString:type];
+
+ fields = [[NSMutableArray alloc] init];
+
+ type++;
+
+ nameBeg = type;
+ while (*type != _C_STRUCT_E && *type++ != '=');
+ name = [[NSString alloc] initWithCString:nameBeg length:type-nameBeg];
+
+ while(*type != _C_STRUCT_E)
+ {
+ [fields addObject:STObjectFromValueOfType(((char *)value)+offset,type)];
+
+ offset += objc_sizeof_type(type);
+ type = objc_skip_typespec(type);
+
+ if(*type == _C_STRUCT_E)
+ {
+ break;
+ }
+
+ align = objc_alignof_type(type);
+ rem = offset % align;
+ if(rem != 0)
+ {
+ offset += align - rem;
+ }
+ }
+
+ return self;
+}
+- (void)dealloc
+{
+ RELEASE(fields);
+ RELEASE(structType);
+ RELEASE(name);
+ [super dealloc];
+}
+
+- (void)getValue:(void *)value
+{
+ const char *type = [structType cString];
+ int offset=0;
+ int align;
+ int rem;
+ int i = 0;
+
+ type++;
+ while (*type != _C_STRUCT_E && *type++ != '=');
+
+ while(*type != _C_STRUCT_E)
+ {
+ STGetValueOfTypeFromObject((void *)((char*)value+offset),
+ type,
+ [fields objectAtIndex:i++]);
+
+ offset += objc_sizeof_type(type);
+ type = objc_skip_typespec(type);
+
+ if(*type == _C_STRUCT_E)
+ {
+ break;
+ }
+ align = objc_alignof_type(type);
+ rem = offset % align;
+ if(rem != 0)
+ {
+ offset += align - rem;
+ }
+ }
+}
+
+- (const char *)type
+{
+ return [structType cString];
+}
+- (NSString *)structureName
+{
+ return name;
+}
+- (const char *)typeOfFieldAtIndex:(unsigned)index
+{
+ const char *type = [structType cString];
+
+ for(type += 1; *type != _C_STRUCT_E && index>0; index--)
+ {
+ type = objc_skip_argspec(type);
+ }
+
+ if(*type == _C_STRUCT_E)
+ {
+ [NSException raise:STInternalInconsistencyException
+ format:@"invalid structure field index"];
+ return 0;
+ }
+ return type;
+}
+- (NSRange)rangeValue
+{
+ /* FIXME: do some checking */
+ return NSMakeRange([self intValueAtIndex:0],[self intValueAtIndex:1]);
+}
+
+- (NSPoint)pointValue
+{
+ /* FIXME: do some checking */
+ return NSMakePoint([self floatValueAtIndex:0],[self floatValueAtIndex:1]);
+}
+
+- (NSSize)sizeValue
+{
+ /* FIXME: do some checking */
+ return NSMakeSize([self floatValueAtIndex:0],[self floatValueAtIndex:1]);
+}
+
+- (NSRect)rectValue
+{
+ NSPoint origin = [[fields objectAtIndex:0] pointValue];
+ NSSize size = [[fields objectAtIndex:1] sizeValue];
+ NSRect rect;
+
+ /* FIXME: do some checking */
+ rect.origin = origin;
+ rect.size = size;
+ return rect;
+}
+
+- valueAtIndex:(unsigned)index
+{
+ return [fields objectAtIndex:index];
+}
+- (void)setValue:anObject atIndex:(unsigned)index
+{
+ [fields replaceObjectAtIndex:index withObject:anObject];
+}
+
+- (int)intValueAtIndex:(unsigned)index
+{
+ return (int)[[fields objectAtIndex:index] intValue];
+}
+- (float)floatValueAtIndex:(unsigned)index
+{
+ return (float)[[fields objectAtIndex:index] floatValue];
+}
+
+/* NSRange */
+
+- (int)location
+{
+ return [[fields objectAtIndex:0] intValue];
+}
+
+- (int)length
+{
+ return [[fields objectAtIndex:1] intValue];
+}
+
+- (void)setLocation:(int)location
+{
+ [fields replaceObjectAtIndex:0 withObject: [NSNumber numberWithInt:location]];
+}
+
+- (void)setLength:(int)length
+{
+ [fields replaceObjectAtIndex:1 withObject: [NSNumber numberWithInt:length]];
+}
+
+/* NSPoint */
+
+- (float)x
+{
+ return [[fields objectAtIndex:0] floatValue];
+}
+
+- (void)setX:(float)x
+{
+ [fields replaceObjectAtIndex:0 withObject: [NSNumber numberWithFloat:x]];
+}
+
+- (float)y
+{
+ return [[fields objectAtIndex:1] floatValue];
+}
+
+- (void)setY:(float)y
+{
+ [fields replaceObjectAtIndex:1 withObject: [NSNumber numberWithFloat:y]];
+}
+
+/* NSSize */
+
+- (float)width
+{
+ return [[fields objectAtIndex:0] floatValue];
+}
+
+- (float)height
+{
+ return [[fields objectAtIndex:1] floatValue];
+}
+
+- (void)setWidth:(float)width
+{
+ [fields replaceObjectAtIndex:0 withObject: [NSNumber numberWithFloat:width]];
+}
+- (void)setHeight:(float)height
+{
+ [fields replaceObjectAtIndex:1 withObject: [NSNumber numberWithFloat:height]];
+}
+
+/* NSRect */
+
+- (id)origin
+{
+ NSLog(@"Origin %@", [fields objectAtIndex:0]);
+ return [fields objectAtIndex:0];
+}
+
+- (id)size
+{
+ NSLog(@"Size %@", [fields objectAtIndex:1]);
+ return [fields objectAtIndex:1] ;
+}
+
+@end
diff --git a/Frameworks/StepTalk/STUndefinedObject.h b/Frameworks/StepTalk/STUndefinedObject.h
new file mode 100644
index 0000000..c6735b1
--- /dev/null
+++ b/Frameworks/StepTalk/STUndefinedObject.h
@@ -0,0 +1,31 @@
+/**
+ STUndefinedObject.h
+ Wrapper for nil object
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2000
+
+ 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
+
+ */
+#import
+#import
+
+@interface STUndefinedObject:NSObject
+@end
diff --git a/Frameworks/StepTalk/STUndefinedObject.m b/Frameworks/StepTalk/STUndefinedObject.m
new file mode 100644
index 0000000..5793e03
--- /dev/null
+++ b/Frameworks/StepTalk/STUndefinedObject.m
@@ -0,0 +1,101 @@
+/**
+ STUndefinedObject.m
+ Wrapper for nil object
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ 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
+
+#import
+#import
+
+#import
+
+STUndefinedObject *STNil = nil;
+
+@implementation STUndefinedObject
++ (id) alloc
+{
+ return STNil;
+}
+
++ (id) allocWithZone: (NSZone*)z
+{
+ return STNil;
+}
+
++ (id) autorelease
+{
+ return self;
+}
+
+- (void) dealloc
+{
+ NSLog(@"Warning: Trying to dealloc STNil object");
+}
+
+- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel
+{
+ NSMethodSignature *signature = nil;
+
+ signature = [super methodSignatureForSelector:sel];
+
+ if(!signature)
+ {
+ signature = STMethodSignatureForSelector(sel);
+ }
+
+ return signature;
+}
+
+- (void) forwardInvocation: (NSInvocation*)anInvocation
+{
+ /* this object is deaf */
+}
+
+- (BOOL) isEqual: (id)anObject
+{
+ return ( (self == anObject) || (anObject == nil) );
+}
+
+- (void) release
+{
+ /* do nothing */
+}
+
+- (id) retain
+{
+ return self;
+}
+
+- (BOOL)isNil
+{
+ return YES;
+}
+
+- (BOOL)notNil
+{
+ return NO;
+}
+@end
+
diff --git a/Frameworks/StepTalk/StepTalk.gsdoc b/Frameworks/StepTalk/StepTalk.gsdoc
new file mode 100644
index 0000000..a156eba
--- /dev/null
+++ b/Frameworks/StepTalk/StepTalk.gsdoc
@@ -0,0 +1,39 @@
+
+
+
+
+
+ StepTalk Documentation
+
+
+
+
+
+
+ 0.7.1
+
+ 2003 Apr 22
+
+
+
+
+
+Introduction
+
+
+
+ StepTalk is a scripting framework for creating scriptable servers or
+ applications. StepTalk, when combined with the dynamism that the
+ Objective-C language provides, goes way beyond mere scripting. intro
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Frameworks/StepTalk/StepTalk.h b/Frameworks/StepTalk/StepTalk.h
new file mode 100644
index 0000000..6c42036
--- /dev/null
+++ b/Frameworks/StepTalk/StepTalk.h
@@ -0,0 +1,39 @@
+/**
+ StepTalk.h
+
+ Copyright (c) 2002 Free Software Foundation
+
+ Written by: Stefan Urbanek
+ Date: 2001 Nov 1
+
+ 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
+
+ */
+
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+#import
+
+#import
diff --git a/GNUmakefile b/GNUmakefile
index 250d770..d01a6a0 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -35,7 +35,7 @@ ifeq ($(appkit),no)
endif
SUBPROJECTS = \
- Source \
+ Frameworks \
Languages \
Finders \
Modules \
diff --git a/Languages/Smalltalk/STBytecodeInterpreter.m b/Languages/Smalltalk/STBytecodeInterpreter.m
index c681202..5eca123 100644
--- a/Languages/Smalltalk/STBytecodeInterpreter.m
+++ b/Languages/Smalltalk/STBytecodeInterpreter.m
@@ -65,8 +65,6 @@
- (void)returnValue:(id)value;
@end
-static STBytecodeInterpreter *sharedInterpreter = nil;
-
static SEL sendSelectorAtIndexSel;
static IMP sendSelectorAtIndexImp;
static SEL pushSel;
@@ -89,16 +87,17 @@ static Class NSInvocation_class = nil;
NSInvocation_class = [NSInvocation class];
}
-
-+ (STBytecodeInterpreter *)sharedInterpreter
++ interpreterWithEnvrionment:(STEnvironment *)env
{
- if(!sharedInterpreter)
- {
- sharedInterpreter = [[self alloc] init];
- }
- return sharedInterpreter;
+ return AUTORELEASE([[self alloc] initWithEnvironment:env]);
}
+- initWithEnvironment:(STEnvironment *)env
+{
+ self = [super init];
+ environment = RETAIN(env);
+ return self;
+}
- (void)setEnvironment:(STEnvironment *)env
{
ASSIGN(environment,env);
diff --git a/Languages/Smalltalk/STCompiledMethod.h b/Languages/Smalltalk/STCompiledMethod.h
index ef6a463..3fe1576 100644
--- a/Languages/Smalltalk/STCompiledMethod.h
+++ b/Languages/Smalltalk/STCompiledMethod.h
@@ -22,9 +22,11 @@
#import "STCompiledCode.h"
+#import
+
@class STMessage;
-@interface STCompiledMethod:STCompiledCode
+@interface STCompiledMethod:STCompiledCode
{
NSString *selector;
short argCount;
diff --git a/Languages/Smalltalk/STCompiler.h b/Languages/Smalltalk/STCompiler.h
index 01a53e5..82fa1fc 100644
--- a/Languages/Smalltalk/STCompiler.h
+++ b/Languages/Smalltalk/STCompiler.h
@@ -57,10 +57,6 @@ typedef struct _STParserContext
/*" Get source reader from parser context "*/
#define STParserContextGetReader(context)\
(((STParserContext *)context)->reader)
-#define STParserContextGetResult(context)\
- (((STParserContext *)context)->result)
-#define STParserContextSetResult(context, c)\
- ( ASSIGN(((STParserContext *)(context))->result, (c)) )
/*" Initialize parser context "*/
#define STParserContextInit(context,aCompiler,aReader) \
@@ -76,13 +72,16 @@ typedef struct _STParserContext
STSourceReader *reader;
STParserContext context;
+ STCompiledScript *resultScript;
+ STCompiledMethod *resultMethod;
+
NSMutableData *byteCodes;
NSMutableArray *tempVars;
NSMutableArray *externVars;
NSMutableArray *receiverVars;
NSMutableArray *literals;
- STCompiledScript *script;
+ BOOL isSingleMethod;
unsigned stackSize; /* Required stack size */
unsigned stackPos; /* Current stack pointer */
@@ -97,6 +96,8 @@ typedef struct _STParserContext
Class realNumberLiteralClass; /* default: NSNumber */
Class symbolLiteralClass; /* default: NSString */
}
++ compilerWithEnvironment:(STEnvironment *)env;
+- initWithEnvironment:(STEnvironment *)env;
/*" Environment "*/
- (void)setEnvironment:(STEnvironment *)env;
- (STSourceReader *)sourceReader;
diff --git a/Languages/Smalltalk/STCompiler.m b/Languages/Smalltalk/STCompiler.m
index e906d2c..9f6cd07 100644
--- a/Languages/Smalltalk/STCompiler.m
+++ b/Languages/Smalltalk/STCompiler.m
@@ -47,6 +47,31 @@
extern int STCparse(void *context);
+/* FIXME: rewrite parser
+
+ We need three kinds of grammars:
+
+ 1. = |
+
+ 2. = '[|' ']'
+ = | '!'
+ = |
+
+ 3. =
+