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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [formal_protocol-3.m] - Blame information for rev 702

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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