mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-22 02:51:05 +00:00
ObjectiveC module added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@13889 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2b961fe6fe
commit
b98ab20521
10 changed files with 379 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -37,6 +37,7 @@ endif
|
|||
SUBPROJECTS = \
|
||||
SimpleTranscript \
|
||||
Foundation \
|
||||
ObjectiveC \
|
||||
$(APPKIT)
|
||||
|
||||
-include GNUMakefile.preamble
|
||||
|
|
50
Modules/ObjectiveC/GNUmakefile
Normal file
50
Modules/ObjectiveC/GNUmakefile
Normal file
|
@ -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
|
36
Modules/ObjectiveC/NSObject+additions.h
Normal file
36
Modules/ObjectiveC/NSObject+additions.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
NSObject+additions
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
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 <Foundation/NSObject.h>
|
||||
|
||||
@class NSArray;
|
||||
|
||||
@interface NSObject(ObjectiveCRuntime)
|
||||
- (NSArray *)methodNames;
|
||||
+ (NSArray *)methodNames;
|
||||
+ (NSArray *)instanceMethodNames;
|
||||
+ (NSArray *)instanceVariableNames;
|
||||
@end
|
107
Modules/ObjectiveC/NSObject+additions.m
Normal file
107
Modules/ObjectiveC/NSObject+additions.m
Normal file
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
NSObject+additions
|
||||
|
||||
Copyright (c) 2002 Free Software Foundation
|
||||
|
||||
Written by: Stefan Urbanek <urbanek@host.sk>
|
||||
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 <objc/objc-api.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
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;i<ivars->ivar_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
|
4
Modules/ObjectiveC/ObjectiveCInfo.plist
Normal file
4
Modules/ObjectiveC/ObjectiveCInfo.plist
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
STClasses = (
|
||||
);
|
||||
}
|
31
Modules/ObjectiveC/ObjectiveCModule.h
Normal file
31
Modules/ObjectiveC/ObjectiveCModule.h
Normal file
|
@ -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 <StepTalk/STModule.h>
|
||||
|
||||
@interface ObjectiveCModule:STModule
|
||||
@end
|
||||
|
40
Modules/ObjectiveC/ObjectiveCModule.m
Normal file
40
Modules/ObjectiveC/ObjectiveCModule.m
Normal file
|
@ -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 <Foundation/NSString.h>
|
||||
@class NSDictionary;
|
||||
|
||||
@implementation ObjectiveCModule
|
||||
- (NSDictionary *)namedObjects
|
||||
{
|
||||
return [NSDictionary dictionaryWithObject:[ObjectiveCRuntime sharedRuntime]
|
||||
forKey:@"Runtime"];
|
||||
}
|
||||
@end
|
||||
|
31
Modules/ObjectiveC/ObjectiveCRuntime.h
Normal file
31
Modules/ObjectiveC/ObjectiveCRuntime.h
Normal file
|
@ -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 <Foundation/NSObject.h>
|
||||
|
||||
@interface ObjectiveCRuntime:NSObject
|
||||
@end
|
||||
|
71
Modules/ObjectiveC/ObjectiveCRuntime.m
Normal file
71
Modules/ObjectiveC/ObjectiveCRuntime.m
Normal file
|
@ -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 <objc/objc-api.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
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
|
||||
|
Loading…
Reference in a new issue