diff --git a/ChangeLog b/ChangeLog index 124c4e6..f4d7e77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,15 @@ +2002 Jun 14 + + * Modules/ObjectiveC: new module + 2002 Jun 10 * NSObject+additions: removed -className as it was added to the base library +2002 Jun 9 + + * Version 0.6.0 released + 2002 Jun 8 * STEnvironmentDescription: added module amd finder list; little code diff --git a/Modules/GNUmakefile b/Modules/GNUmakefile index f4421e7..160dfd7 100644 --- a/Modules/GNUmakefile +++ b/Modules/GNUmakefile @@ -37,6 +37,7 @@ endif SUBPROJECTS = \ SimpleTranscript \ Foundation \ + ObjectiveC \ $(APPKIT) -include GNUMakefile.preamble diff --git a/Modules/ObjectiveC/GNUmakefile b/Modules/ObjectiveC/GNUmakefile new file mode 100644 index 0000000..18bf624 --- /dev/null +++ b/Modules/ObjectiveC/GNUmakefile @@ -0,0 +1,50 @@ +# +# ObjectiveC module +# +# Copyright (C)2002 Stefan Urbanek +# +# Written by: Stefan Urbanek +# Date: 2002 Jun 14 +# +# 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. +# + +GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles + +include $(GNUSTEP_MAKEFILES)/common.make + +BUNDLE_NAME = ObjectiveC + +ObjectiveC_OBJC_FILES = \ + ObjectiveCModule.m \ + ObjectiveCRuntime.m \ + NSObject+additions.m + +ObjectiveC_PRINCIPAL_CLASS = ObjectiveCModule + + +ObjectiveC_BUNDLE_LIBS += -lStepTalk +ADDITIONAL_INCLUDE_DIRS += -I../../Source/Headers +ADDITIONAL_LIB_DIRS += -L../../Source/$(GNUSTEP_OBJ_DIR) + + +BUNDLE_EXTENSION := .stmodule +BUNDLE_INSTALL_DIR:=$(GNUSTEP_INSTALLATION_DIR)/Library/StepTalk/Modules + +-include GNUmakefile.preamble +include $(GNUSTEP_MAKEFILES)/bundle.make +-include GNUMakefile.postamble diff --git a/Modules/ObjectiveC/NSObject+additions.h b/Modules/ObjectiveC/NSObject+additions.h new file mode 100644 index 0000000..434341e --- /dev/null +++ b/Modules/ObjectiveC/NSObject+additions.h @@ -0,0 +1,36 @@ +/** + NSObject+additions + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 14 + + 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 NSArray; + +@interface NSObject(ObjectiveCRuntime) +- (NSArray *)methodNames; ++ (NSArray *)methodNames; ++ (NSArray *)instanceMethodNames; ++ (NSArray *)instanceVariableNames; +@end diff --git a/Modules/ObjectiveC/NSObject+additions.m b/Modules/ObjectiveC/NSObject+additions.m new file mode 100644 index 0000000..524fe7d --- /dev/null +++ b/Modules/ObjectiveC/NSObject+additions.m @@ -0,0 +1,107 @@ +/** + NSObject+additions + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 14 + + 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 "NSObject+additions.h" + +#import + +#import + +static NSArray *methods_for_class(Class class) +{ + NSMutableArray *array = [NSMutableArray array]; + struct objc_method_list *methods; + SEL sel; + int i; + + if(!class) + return nil; + + methods = class->methods; + + array = ; + + while(methods) + { + for(i = 0; i < methods->method_count; i++) + { + sel = methods->method_list[i].method_name; + [array addObject:NSStringFromSelector(sel)]; + } + + methods = methods->method_next; + } + + return [NSArray arrayWithArray:array]; +} + +static NSArray *ivars_for_class(Class class) +{ + NSMutableArray *array; + struct objc_ivar_list* ivars; + const char *cname; + int i; + + if(!class) + return nil; + + array = [NSMutableArray array]; + + ivars = class->ivars; + + if(ivars) + { + for(i=0;iivar_count;i++) + { + cname = ivars->ivar_list[i].ivar_name; + [array addObject:[NSString stringWithCString:cname]]; + } + } + + return [NSArray arrayWithArray:array]; +} + +@implementation NSObject(ObjectiveCRuntime) ++ (NSArray *)instanceMethodNames +{ + return methods_for_class(self); +} + +- (NSArray *)methodNames +{ + return [[self class] instanceMethodNames]; +} + ++ (NSArray *)methodNames +{ + return methods_for_class(class_get_meta_class(self)); +} + ++ (NSArray *)instanceVariableNames +{ + return ivars_for_class(self); +} +@end diff --git a/Modules/ObjectiveC/ObjectiveCInfo.plist b/Modules/ObjectiveC/ObjectiveCInfo.plist new file mode 100644 index 0000000..7b13f14 --- /dev/null +++ b/Modules/ObjectiveC/ObjectiveCInfo.plist @@ -0,0 +1,4 @@ +{ + STClasses = ( + ); +} diff --git a/Modules/ObjectiveC/ObjectiveCModule.h b/Modules/ObjectiveC/ObjectiveCModule.h new file mode 100644 index 0000000..62b9c81 --- /dev/null +++ b/Modules/ObjectiveC/ObjectiveCModule.h @@ -0,0 +1,31 @@ +/** + ObjectiveCModule.h + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 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 ObjectiveCModule:STModule +@end + diff --git a/Modules/ObjectiveC/ObjectiveCModule.m b/Modules/ObjectiveC/ObjectiveCModule.m new file mode 100644 index 0000000..a518f95 --- /dev/null +++ b/Modules/ObjectiveC/ObjectiveCModule.m @@ -0,0 +1,40 @@ +/** + ObjectiveCModule.m + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 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 "ObjectiveCModule.h" +#import "ObjectiveCRuntime.h" + +#import +@class NSDictionary; + +@implementation ObjectiveCModule +- (NSDictionary *)namedObjects +{ + return [NSDictionary dictionaryWithObject:[ObjectiveCRuntime sharedRuntime] + forKey:@"Runtime"]; +} +@end + diff --git a/Modules/ObjectiveC/ObjectiveCRuntime.h b/Modules/ObjectiveC/ObjectiveCRuntime.h new file mode 100644 index 0000000..535d72a --- /dev/null +++ b/Modules/ObjectiveC/ObjectiveCRuntime.h @@ -0,0 +1,31 @@ +/** + ObjectiveCRuntime.m + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 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 ObjectiveCRuntime:NSObject +@end + diff --git a/Modules/ObjectiveC/ObjectiveCRuntime.m b/Modules/ObjectiveC/ObjectiveCRuntime.m new file mode 100644 index 0000000..2a08bc2 --- /dev/null +++ b/Modules/ObjectiveC/ObjectiveCRuntime.m @@ -0,0 +1,71 @@ +/** + ObjectiveCRuntime.m + + Copyright (c) 2002 Free Software Foundation + + Written by: Stefan Urbanek + Date: 2002 Jun 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 "ObjectiveCRuntime.h" + +#import + +#import + +static ObjectiveCRuntime *sharedRuntime=nil; + +@implementation ObjectiveCRuntime ++ sharedRuntime +{ + if(!sharedRuntime) + { + sharedRuntime = [[ObjectiveCRuntime alloc] init]; + } + return sharedRuntime; +} + +- (NSArray *)allClasses +{ + NSMutableArray *array; + Class class; + void *state = NULL; + + array = [NSMutableArray array]; + + while( (class = objc_next_class(&state)) ) + { + [array addObject:class]; + } + + return [NSArray arrayWithArray:array]; +} + +- (Class )classWithName:(NSString *)string +{ + return NSClassFromString(string); +} + +- (NSString *)nameOfClass:(Class)class +{ + return NSStringFromClass(class); +} +@end +