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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [formal_protocol-3.m] - Blame information for rev 154

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

Line No. Rev Author Line
1 149 jeremybenn
/* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
2
#include <objc/objc.h>
3
#include <objc/Object.h>
4
 
5
/* Test defining two protocol, a class adopting both of them,
6
   and using an object of type `id <Protocol1, Protocol2>' */
7
 
8
@protocol Enabling
9
- (BOOL) isEnabled;
10
- (void) setEnabled: (BOOL)flag;
11
@end
12
 
13
@protocol Evaluating
14
- (int) importance;
15
@end
16
 
17
@interface Feature : Object <Enabling, Evaluating>
18
{
19
  const char *name;
20
  BOOL isEnabled;
21
}
22
@end
23
 
24
@implementation Feature
25
- (BOOL) isEnabled
26
{
27
  return isEnabled;
28
}
29
- (void) setEnabled: (BOOL)flag
30
{
31
  isEnabled = flag;
32
}
33
- (int) importance
34
{
35
  return 1000;
36
}
37
@end
38
 
39
int main (void)
40
{
41
  id <Enabling, Evaluating> object;
42
 
43
  object = [Feature new];
44
 
45
  [object setEnabled: YES];
46
  if (![object isEnabled])
47
    {
48
      abort ();
49
    }
50
 
51
  if ([object importance] != 1000)
52
    {
53
      abort ();
54
    }
55
 
56
  return 0;
57
}
58
 

powered by: WebSVN 2.1.0

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