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-2.m] - Blame information for rev 825

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 a protocol, a class adopting it, and using an object
6
   of type `id <protocol>'. */
7
 
8
@protocol Enabling
9
- (BOOL) isEnabled;
10
- (void) setEnabled: (BOOL)flag;
11
@end
12
 
13
@interface Feature : Object <Enabling>
14
{
15
  const char *name;
16
  BOOL isEnabled;
17
}
18
@end
19
 
20
@implementation Feature
21
- (BOOL) isEnabled
22
{
23
  return isEnabled;
24
}
25
- (void) setEnabled: (BOOL)flag
26
{
27
  isEnabled = flag;
28
}
29
@end
30
 
31
int main (void)
32
{
33
  id <Enabling> object;
34
 
35
  object = [Feature new];
36
 
37
  [object setEnabled: YES];
38
  if (![object isEnabled])
39
    {
40
      abort ();
41
    }
42
 
43
  return 0;
44
}
45
 

powered by: WebSVN 2.1.0

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