URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 154 |
Rev 816 |
/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
|
/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
|
#include <objc/objc.h>
|
#include <objc/objc.h>
|
|
|
/* Test calling a class method on self where self has been redefined
|
/* Test calling a class method on self where self has been redefined
|
to be another class - the call requires a cast */
|
to be another class - the call requires a cast */
|
|
|
|
|
/* The first class */
|
/* The first class */
|
struct d
|
struct d
|
{
|
{
|
int a;
|
int a;
|
};
|
};
|
|
|
@interface ClassA
|
@interface ClassA
|
{
|
{
|
Class isa;
|
Class isa;
|
}
|
}
|
+ (Class) class;
|
+ (Class) class;
|
+ (struct d) method;
|
+ (struct d) method;
|
@end
|
@end
|
|
|
@implementation ClassA
|
@implementation ClassA
|
+ (Class) class
|
+ (Class) class
|
{
|
{
|
return self;
|
return self;
|
}
|
}
|
|
|
+ (struct d) method
|
+ (struct d) method
|
{
|
{
|
struct d u;
|
struct d u;
|
u.a = 5;
|
u.a = 5;
|
|
|
return u;
|
return u;
|
}
|
}
|
#ifdef __NEXT_RUNTIME__
|
#ifdef __NEXT_RUNTIME__
|
+ initialize { return self; }
|
+ initialize { return self; }
|
#endif
|
#endif
|
@end
|
@end
|
|
|
/* The second class */
|
/* The second class */
|
@interface TestClass
|
@interface TestClass
|
{
|
{
|
Class isa;
|
Class isa;
|
}
|
}
|
+ (void) test;
|
+ (void) test;
|
@end
|
@end
|
|
|
@implementation TestClass
|
@implementation TestClass
|
+ (void) test
|
+ (void) test
|
{
|
{
|
self = [ClassA class];
|
self = [ClassA class];
|
|
|
|
|
if ([(Class)self method].a != 5)
|
if ([(Class)self method].a != 5)
|
{
|
{
|
abort ();
|
abort ();
|
}
|
}
|
}
|
}
|
|
|
#ifdef __NEXT_RUNTIME__
|
#ifdef __NEXT_RUNTIME__
|
+ initialize { return self; }
|
+ initialize { return self; }
|
#endif
|
#endif
|
@end
|
@end
|
|
|
|
|
int main (void)
|
int main (void)
|
{
|
{
|
[TestClass test];
|
[TestClass test];
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.