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-1.m] - Blame information for rev 149

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

powered by: WebSVN 2.1.0

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