OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [formal_protocol-2.m] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 307 jeremybenn
/* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
2
 
3
#include <stdlib.h>
4
#import "../../objc-obj-c++-shared/Object1.h"
5
 
6
/* Test defining a protocol, a class adopting it, and using an object
7
   of type `id <protocol>'. */
8
 
9
@protocol Enabling
10
- (BOOL) isEnabled;
11
- (void) setEnabled: (BOOL)flag;
12
@end
13
 
14
@interface Feature : Object <Enabling>
15
{
16
  const char *name;
17
  BOOL isEnabled;
18
}
19
@end
20
 
21
@implementation Feature
22
- (BOOL) isEnabled
23
{
24
  return isEnabled;
25
}
26
- (void) setEnabled: (BOOL)flag
27
{
28
  isEnabled = flag;
29
}
30
@end
31
 
32
int main (void)
33
{
34
  id <Enabling> object;
35
 
36
  object = [Feature new];
37
 
38
  [object setEnabled: YES];
39
  if (![object isEnabled])
40
    {
41
      abort ();
42
    }
43
 
44
  return 0;
45
}
46
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.