From 5e725064c3e20a51aef6849f384afafe6da7df9a Mon Sep 17 00:00:00 2001 From: Stefan Urbanek Date: Fri, 3 Oct 2003 16:30:06 +0000 Subject: [PATCH] Added ReadlineTranscript git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@17773 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 + Modules/ObjectiveC/NSObject+additions.m | 3 +- Modules/ReadlineTranscript/.cvsignore | 7 ++ Modules/ReadlineTranscript/GNUmakefile | 44 +++++++++ .../ReadlineTranscript/ReadlineTranscript.h | 35 +++++++ .../ReadlineTranscript/ReadlineTranscript.m | 96 +++++++++++++++++++ .../ReadlineTranscriptModule.h | 32 +++++++ .../ReadlineTranscriptModule.m | 41 ++++++++ .../ReadlineTranscript/ScriptingInfo.plist | 5 + Modules/ReadlineTranscript/test.st | 4 + Version | 2 +- 11 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 Modules/ReadlineTranscript/.cvsignore create mode 100644 Modules/ReadlineTranscript/GNUmakefile create mode 100644 Modules/ReadlineTranscript/ReadlineTranscript.h create mode 100644 Modules/ReadlineTranscript/ReadlineTranscript.m create mode 100644 Modules/ReadlineTranscript/ReadlineTranscriptModule.h create mode 100644 Modules/ReadlineTranscript/ReadlineTranscriptModule.m create mode 100644 Modules/ReadlineTranscript/ScriptingInfo.plist create mode 100644 Modules/ReadlineTranscript/test.st diff --git a/ChangeLog b/ChangeLog index 4caa7c5..a6a1b6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003 Oct 3 Stefan Urbanek + + * Added ReadlineTranscript module (Idea by Alexander Diemand) + 2003 Sep 24 Stefan Urbanek * STEnvironmentDescription: guard initialisation in Autorelease pool diff --git a/Modules/ObjectiveC/NSObject+additions.m b/Modules/ObjectiveC/NSObject+additions.m index 03a9e8c..b4cbf50 100644 --- a/Modules/ObjectiveC/NSObject+additions.m +++ b/Modules/ObjectiveC/NSObject+additions.m @@ -90,7 +90,8 @@ static NSArray *ivars_for_class(Class class) - (NSArray *)methodNames { - return [[self class] instanceMethodNames]; + return [[[self class] instanceMethodNames] + sortedArrayUsingSelector:@selector(compare:)]; } + (NSArray *)methodNames diff --git a/Modules/ReadlineTranscript/.cvsignore b/Modules/ReadlineTranscript/.cvsignore new file mode 100644 index 0000000..862e5dc --- /dev/null +++ b/Modules/ReadlineTranscript/.cvsignore @@ -0,0 +1,7 @@ +*.app +*.debug +*.profile +shared_*obj +*.bundle +*.stmodule +*.stlanguage diff --git a/Modules/ReadlineTranscript/GNUmakefile b/Modules/ReadlineTranscript/GNUmakefile new file mode 100644 index 0000000..b3421e6 --- /dev/null +++ b/Modules/ReadlineTranscript/GNUmakefile @@ -0,0 +1,44 @@ +# +# ReadlineTranscript module +# +# Copyright (C)2001 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., 675 Mass Ave, Cambridge, MA 02111, USA. +# + +include $(GNUSTEP_MAKEFILES)/common.make + +BUNDLE_NAME = ReadlineTranscript + +ReadlineTranscript_OBJC_FILES = \ + ReadlineTranscriptModule.m \ + ReadlineTranscript.m \ + +ReadlineTranscript_PRINCIPAL_CLASS = ReadlineTranscriptModule + +ReadlineTranscript_RESOURCE_FILES = ScriptingInfo.plist + +BUNDLE_INSTALL_DIR:=$(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk/Modules + +ReadlineTranscript_BUNDLE_LIBS = -lStepTalk -lreadline +ADDITIONAL_INCLUDE_DIRS += -I../../Frameworks/ + +ADDITIONAL_OBJCFLAGS = -Wall -Wno-import + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/bundle.make +-include GNUMakefile.postamble diff --git a/Modules/ReadlineTranscript/ReadlineTranscript.h b/Modules/ReadlineTranscript/ReadlineTranscript.h new file mode 100644 index 0000000..e212531 --- /dev/null +++ b/Modules/ReadlineTranscript/ReadlineTranscript.h @@ -0,0 +1,35 @@ +/** + ReadlineTranscript.h + StepTalk simple transcript + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2001 Apr 13 + + 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 ReadlineTranscript:NSObject ++ sharedTranscript; +- show:(id)anObject; +- showLine:(id)anObject; +- (NSString*)readLine:(NSString*)prompt; +@end diff --git a/Modules/ReadlineTranscript/ReadlineTranscript.m b/Modules/ReadlineTranscript/ReadlineTranscript.m new file mode 100644 index 0000000..15eef40 --- /dev/null +++ b/Modules/ReadlineTranscript/ReadlineTranscript.m @@ -0,0 +1,96 @@ +/** + ReadlineTranscript.m + StepTalk simple transcript + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2001 Apr 13 + + 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 "ReadlineTranscript.h" + +#import +#import + +#include +#include + +static Class NSString_class; +static Class NSNumber_class; + +static ReadlineTranscript *sharedTranscript; + +@implementation ReadlineTranscript:NSObject ++ (void)initialize +{ + NSString_class = [NSString class]; + NSNumber_class = [NSNumber class]; +} ++ sharedTranscript +{ + if(!sharedTranscript) + { + sharedTranscript = [[ReadlineTranscript alloc] init]; + } + + return sharedTranscript; +} +- show:(id)anObject +{ + NSString *string; + + if( [anObject isKindOfClass:NSString_class] ) + { + string = anObject; + } + else if ( [anObject isKindOfClass:NSNumber_class] ) + { + string = [anObject stringValue]; + } + else + { + string = [anObject description]; + } + + printf("%s", [string cString]); + + return self; +} + +- showLine:(id)anObject +{ + [self show:anObject]; + putchar('\n'); + + return self; +} +-(NSString*)readLine:(NSString*)prompt +{ + NSString *resret=nil; + char *res; + res = readline([prompt cString]); + if (res) + { + resret = [NSString stringWithCString: res]; + } + return resret; +} +@end diff --git a/Modules/ReadlineTranscript/ReadlineTranscriptModule.h b/Modules/ReadlineTranscript/ReadlineTranscriptModule.h new file mode 100644 index 0000000..2eebfe5 --- /dev/null +++ b/Modules/ReadlineTranscript/ReadlineTranscriptModule.h @@ -0,0 +1,32 @@ +/** + ReadlineTranscriptModule.h + Transcript module + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2001 May 18 + + 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 ReadlineTranscriptModule:NSObject +@end + diff --git a/Modules/ReadlineTranscript/ReadlineTranscriptModule.m b/Modules/ReadlineTranscript/ReadlineTranscriptModule.m new file mode 100644 index 0000000..c88aaca --- /dev/null +++ b/Modules/ReadlineTranscript/ReadlineTranscriptModule.m @@ -0,0 +1,41 @@ +/** + ReadlineTranscriptModule.m + Transcript module + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2001 May 18 + + 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 "ReadlineTranscriptModule.h" +#import "ReadlineTranscript.h" + +#import +#import + +@implementation ReadlineTranscriptModule ++ (NSDictionary *)namedObjectsForScripting +{ + return [NSDictionary dictionaryWithObject:[ReadlineTranscript sharedTranscript] + forKey:@"Transcript"]; +} +@end + diff --git a/Modules/ReadlineTranscript/ScriptingInfo.plist b/Modules/ReadlineTranscript/ScriptingInfo.plist new file mode 100644 index 0000000..f9b86f8 --- /dev/null +++ b/Modules/ReadlineTranscript/ScriptingInfo.plist @@ -0,0 +1,5 @@ +{ + ScriptingInfoClass = ReadlineTranscriptModule; + Classes = ( + ); +} diff --git a/Modules/ReadlineTranscript/test.st b/Modules/ReadlineTranscript/test.st new file mode 100644 index 0000000..5636e5f --- /dev/null +++ b/Modules/ReadlineTranscript/test.st @@ -0,0 +1,4 @@ +Environment loadModule:'ReadlineTranscript'. +Transcript showLine: 'Readline test'. +line := Transcript readLine:'Write something: '. +Transcript showLine: line uppercaseString. diff --git a/Version b/Version index 5751df7..ceab5f4 100644 --- a/Version +++ b/Version @@ -4,7 +4,7 @@ # The version number of this release. MAJOR_VERSION=0 MINOR_VERSION=8 -SUBMINOR_VERSION=0 +SUBMINOR_VERSION=1 STEPTALK_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}