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 |
/* { dg-do run { target *-*-darwin* } } */
|
/* { dg-do run { target *-*-darwin* } } */
|
|
|
#include <objc/Object.h>
|
#include <objc/Object.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
typedef struct MyWidget {
|
typedef struct MyWidget {
|
int a;
|
int a;
|
} MyWidget;
|
} MyWidget;
|
|
|
MyWidget gWidget = { 17 };
|
MyWidget gWidget = { 17 };
|
|
|
@protocol MyProto
|
@protocol MyProto
|
- (MyWidget *)widget;
|
- (MyWidget *)widget;
|
@end
|
@end
|
|
|
@interface Foo: Object
|
@interface Foo: Object
|
@end
|
@end
|
|
|
@interface Bar: Foo <MyProto>
|
@interface Bar: Foo <MyProto>
|
@end
|
@end
|
|
|
@interface Container: Object
|
@interface Container: Object
|
+ (MyWidget *)elementForView:(Foo *)view;
|
+ (MyWidget *)elementForView:(Foo *)view;
|
@end
|
@end
|
|
|
@implementation Foo
|
@implementation Foo
|
@end
|
@end
|
|
|
@implementation Bar
|
@implementation Bar
|
- (MyWidget *)widget {
|
- (MyWidget *)widget {
|
return &gWidget;
|
return &gWidget;
|
}
|
}
|
@end
|
@end
|
|
|
@implementation Container
|
@implementation Container
|
+ (MyWidget *)elementForView:(Foo *)view
|
+ (MyWidget *)elementForView:(Foo *)view
|
{
|
{
|
MyWidget *widget = nil;
|
MyWidget *widget = nil;
|
if ([view conformsTo:@protocol(MyProto)]) {
|
if ([view conformsTo:@protocol(MyProto)]) {
|
widget = [(Foo <MyProto> *)view widget];
|
widget = [(Foo <MyProto> *)view widget];
|
}
|
}
|
return widget;
|
return widget;
|
}
|
}
|
@end
|
@end
|
|
|
int main(void) {
|
int main(void) {
|
id view = [Bar new];
|
id view = [Bar new];
|
MyWidget *w = [Container elementForView: view];
|
MyWidget *w = [Container elementForView: view];
|
|
|
if (!w || w->a != 17)
|
if (!w || w->a != 17)
|
abort ();
|
abort ();
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.