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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [formal_protocol-2.m] - Diff between revs 149 and 154

Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
/* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
/* Contributed by Nicola Pero - Fri Mar  9 21:35:47 CET 2001 */
#include <objc/objc.h>
#include <objc/objc.h>
#include <objc/Object.h>
#include <objc/Object.h>
 
 
/* Test defining a protocol, a class adopting it, and using an object
/* Test defining a protocol, a class adopting it, and using an object
   of type `id <protocol>'. */
   of type `id <protocol>'. */
 
 
@protocol Enabling
@protocol Enabling
- (BOOL) isEnabled;
- (BOOL) isEnabled;
- (void) setEnabled: (BOOL)flag;
- (void) setEnabled: (BOOL)flag;
@end
@end
 
 
@interface Feature : Object <Enabling>
@interface Feature : Object <Enabling>
{
{
  const char *name;
  const char *name;
  BOOL isEnabled;
  BOOL isEnabled;
}
}
@end
@end
 
 
@implementation Feature
@implementation Feature
- (BOOL) isEnabled
- (BOOL) isEnabled
{
{
  return isEnabled;
  return isEnabled;
}
}
- (void) setEnabled: (BOOL)flag
- (void) setEnabled: (BOOL)flag
{
{
  isEnabled = flag;
  isEnabled = flag;
}
}
@end
@end
 
 
int main (void)
int main (void)
{
{
  id <Enabling> object;
  id <Enabling> object;
 
 
  object = [Feature new];
  object = [Feature new];
 
 
  [object setEnabled: YES];
  [object setEnabled: YES];
  if (![object isEnabled])
  if (![object isEnabled])
    {
    {
      abort ();
      abort ();
    }
    }
 
 
  return 0;
  return 0;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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