Initial revision

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@521 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1995-08-02 18:51:42 +00:00
parent d2ab1155ef
commit 1cdc3146c0
5 changed files with 174 additions and 0 deletions

16
Testing/MyCategory.h Normal file
View file

@ -0,0 +1,16 @@
/* Test Category for NSBundle.
Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Jul 1995
This file is part of the GNU Objective C Class Library.
*/
#include <Foundation/NSObject.h>
@interface NSObject(MyCategory)
- printMyName;
@end

20
Testing/MyCategory.m Normal file
View file

@ -0,0 +1,20 @@
/* Test Category for NSBundle.
Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Jul 1995
This file is part of the GNU Objective C Class Library.
*/
#include "MyCategory.h"
@implementation NSObject(MyCategory)
- printMyName
{
printf("Class %s had MyCategory added to it\n", [self name]);
return self;
}
@end

21
Testing/SecondClass.h Normal file
View file

@ -0,0 +1,21 @@
/* Test Class for NSBundle.
Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Jul 1995
This file is part of the GNU Objective C Class Library.
*/
#include <Foundation/NSObject.h>
@interface SecondClass : NSObject
{
int h;
char *dummy;
}
- init;
- printName;
@end

28
Testing/SecondClass.m Normal file
View file

@ -0,0 +1,28 @@
/* Test Class for NSBundle.
Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Jul 1995
This file is part of the GNU Objective C Class Library.
*/
#include "SecondClass.h"
@implementation SecondClass
- init
{
[super init];
h = 25;
return self;
}
- printName
{
printf("Hi my name is %s\n", [self name]);
return self;
}
@end

89
Testing/nsbundle.m Normal file
View file

@ -0,0 +1,89 @@
/* nsbundle - Program to test out dynamic linking via NSBundle.
Copyright (C) 1993,1994,1995 Free Software Foundation, Inc.
Written by: Adam Fedor <fedor@boulder.colorado.edu>
Date: Jul 1995
This file is part of the GNU Objective C Class Library.
*/
#include <sys/param.h>
#include "Foundation/NSBundle.h"
#include "Foundation/NSException.h"
#include "Foundation/NSString.h"
#include "LoadMe.h"
#include "SecondClass.h"
#include "MyCategory.h"
/* Realize externals needed by objc-load */
char **NSArgv;
int
main(int ac, char *av[])
{
NSBundle *main;
NSBundle *bundle;
NSString *path;
id object;
NSArgv = av;
main = [NSBundle mainBundle];
printf("Looking for main bundle...\n");
if (!main) {
fprintf(stderr, "* ERROR: Can't get main bundle\n");
exit(1);
}
printf(" Main bundle directory is %s\n", [[main bundlePath] cString]);
printf("Looking for LoadMe bundle...\n");
path = [main pathForResource:@"LoadMe" ofType:@"bundle"];
if (!path) {
fprintf(stderr, "* ERROR: Can't find LoadMe bundle in main bundle\n");
exit(1);
}
printf(" Found LoadMe in: %s\n\n", [path cString]);
printf("Initializing LoadMe bundle...\n");
bundle = [[NSBundle alloc] initWithPath:path];
if (!bundle) {
fprintf(stderr, "* ERROR: Can't init LoadMe bundle\n");
exit(1);
}
path = [bundle pathForResource:@"NXStringTable" ofType:@"example"];
if (!path) {
fprintf(stderr, "* ERROR: Can't find example in LoadMe bundle\n");
exit(1);
}
printf(" Found example file: %s\n\n", [path cString]);
printf("Retreiving principal class...\n");
NS_DURING
object = [bundle principalClass];
NS_HANDLER
object = nil;
fprintf(stderr, " ERROR: %s\n", [[exception reason] cString]);
fprintf(stderr, " Either there is a problem with dynamic loading,\n");
fprintf(stderr, " or there is no dynamic loader on your system\n");
exit(1);
NS_ENDHANDLER
if (!object) {
fprintf(stderr, "* ERROR: Can't find principal class\n");
exit(1);
}
printf(" Principal class is: %s\n", [object name]);
printf("Testing LoadMe bundle classes...\n");
printf(" This is LoadMe:\n");
object = [[[bundle classNamed:@"LoadMe"] alloc] init];
[object afterLoad];
[object release];
printf("\n This is SecondClass:\n");
object = [[[bundle classNamed:@"SecondClass"] alloc] init];
[object printName];
[object printMyName];
[object release];
return 0;
}