Commit 8f07a2aa by Nicola Pero Committed by Nicola Pero

In gcc/objc/: 2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/objc/:
2010-11-01  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented Objective-C 2.0 property accessors. 
        * objc-act.h (enum objc_tree_index): Added OCTI_GET_PROPERTY_DECL,
        OCTI_SET_PROPERTY_DECL, OCTI_COPY_STRUCT_DECL,
        OCTI_GET_PROPERTY_STRUCT_DECL and OCTI_SET_PROPERTY_STRUCT_DECL.
        (objc_getProperty_decl): New.
        (objc_setProperty_decl): New.
        (objc_copyStruct_decl): New.
        (objc_getPropertyStruct_decl): New.
        (objc_setPropertyStruct_decl): New.
        * objc-act.c (build_objc_property_accessor_helpers): New.
        (synth_module_prologue): Call
        build_objc_property_accessor_helpers.
        (lookup_ivar): New.
        (objc_synthesize_getter): Implemented synthesizing getters that
        work with properties that are not nonatomic, assign properties.
        (objc_synthesize_setter): Implemented synthesizing setters that
        work with properties that are not nonatomic, assign properties.

In gcc/testsuite/:      
2010-11-01  Nicola Pero  <nicola.pero@meta-innovation.com>

        Implemented Objective-C 2.0 property accessors.
        * objc.dg/property/at-property-6.m: Use nonatomic properties to
        avoid testing more complex accessors in this testcase which is not
        about them.
        * objc.dg/property/at-property-7.m: Same change.
        * objc.dg/property/at-property-8.m: Same change.
        * objc.dg/property/at-property-9.m: Same change.
        * objc.dg/property/at-property-10.m: Same change.
        * objc.dg/property/at-property-11.m: Same change.
        * obj-c++.dg/property/at-property-6.mm: Same change.
        * obj-c++.dg/property/at-property-7.mm: Same change.
        * obj-c++.dg/property/at-property-8.mm: Same change.
        * obj-c++.dg/property/at-property-9.mm: Same change.
        * obj-c++.dg/property/at-property-10.mm: Same change.
        * obj-c++.dg/property/at-property-11.mm: Same change.
        * objc.dg/property/at-property-12.m: New.
        * objc.dg/property/at-property-13.m: New.
        * obj-c++.dg/property/at-property-12.mm: New.
        * obj-c++.dg/property/at-property-13.mm: New.

From-SVN: r166143
parent 1fccc6c3
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented Objective-C 2.0 property accessors.
* objc-act.h (enum objc_tree_index): Added OCTI_GET_PROPERTY_DECL,
OCTI_SET_PROPERTY_DECL, OCTI_COPY_STRUCT_DECL,
OCTI_GET_PROPERTY_STRUCT_DECL and OCTI_SET_PROPERTY_STRUCT_DECL.
(objc_getProperty_decl): New.
(objc_setProperty_decl): New.
(objc_copyStruct_decl): New.
(objc_getPropertyStruct_decl): New.
(objc_setPropertyStruct_decl): New.
* objc-act.c (build_objc_property_accessor_helpers): New.
(synth_module_prologue): Call
build_objc_property_accessor_helpers.
(lookup_ivar): New.
(objc_synthesize_getter): Implemented synthesizing getters that
work with properties that are not nonatomic, assign properties.
(objc_synthesize_setter): Implemented synthesizing setters that
work with properties that are not nonatomic, assign properties.
2010-10-30 Nicola Pero <nicola.pero@meta-innovation.com> 2010-10-30 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented Objective-C 2.0 @property, @synthesize and @dynamic. Implemented Objective-C 2.0 @property, @synthesize and @dynamic.
......
...@@ -339,6 +339,12 @@ enum objc_tree_index ...@@ -339,6 +339,12 @@ enum objc_tree_index
OCTI_FAST_ENUM_STATE_TEMP, OCTI_FAST_ENUM_STATE_TEMP,
OCTI_ENUM_MUTATION_DECL, OCTI_ENUM_MUTATION_DECL,
OCTI_GET_PROPERTY_DECL,
OCTI_SET_PROPERTY_DECL,
OCTI_COPY_STRUCT_DECL,
OCTI_GET_PROPERTY_STRUCT_DECL,
OCTI_SET_PROPERTY_STRUCT_DECL,
OCTI_MAX OCTI_MAX
}; };
...@@ -506,4 +512,13 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX]; ...@@ -506,4 +512,13 @@ extern GTY(()) tree objc_global_trees[OCTI_MAX];
#define objc_enumeration_mutation_decl \ #define objc_enumeration_mutation_decl \
objc_global_trees[OCTI_ENUM_MUTATION_DECL] objc_global_trees[OCTI_ENUM_MUTATION_DECL]
/* Declarations of functions used when synthesizing property
accessors. */
#define objc_getProperty_decl objc_global_trees[OCTI_GET_PROPERTY_DECL]
#define objc_setProperty_decl objc_global_trees[OCTI_SET_PROPERTY_DECL]
#define objc_copyStruct_decl objc_global_trees[OCTI_COPY_STRUCT_DECL]
#define objc_getPropertyStruct_decl objc_global_trees[OCTI_GET_PROPERTY_STRUCT_DECL]
#define objc_setPropertyStruct_decl objc_global_trees[OCTI_SET_PROPERTY_STRUCT_DECL]
#endif /* GCC_OBJC_ACT_H */ #endif /* GCC_OBJC_ACT_H */
2010-11-01 Nicola Pero <nicola.pero@meta-innovation.com>
Implemented Objective-C 2.0 property accessors.
* objc.dg/property/at-property-6.m: Use nonatomic properties to
avoid testing more complex accessors in this testcase which is not
about them.
* objc.dg/property/at-property-7.m: Same change.
* objc.dg/property/at-property-8.m: Same change.
* objc.dg/property/at-property-9.m: Same change.
* objc.dg/property/at-property-10.m: Same change.
* objc.dg/property/at-property-11.m: Same change.
* obj-c++.dg/property/at-property-6.mm: Same change.
* obj-c++.dg/property/at-property-7.mm: Same change.
* obj-c++.dg/property/at-property-8.mm: Same change.
* obj-c++.dg/property/at-property-9.mm: Same change.
* obj-c++.dg/property/at-property-10.mm: Same change.
* obj-c++.dg/property/at-property-11.mm: Same change.
* objc.dg/property/at-property-12.m: New.
* objc.dg/property/at-property-13.m: New.
* obj-c++.dg/property/at-property-12.mm: New.
* obj-c++.dg/property/at-property-13.mm: New.
2010-11-01 Steven G. Kargl <kargl@gcc.gnu.org> 2010-11-01 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/46152 PR fortran/46152
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; @property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; @property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
/* { dg-do run } */
/* Test atomic, assign synthesized methods. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int a;
id b;
}
@property int a;
@property (assign) id b;
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
@synthesize a;
@synthesize b;
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
object.a = 40;
if (object.a != 40)
abort ();
object.b = object;
if (object.b != object)
abort ();
return (0);
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
/* { dg-do run } */
/* Test retain and copy synthesized methods. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int copy_count;
id a;
id b;
}
@property (copy) id a;
@property (retain) id b;
+ (id) initialize;
+ (id) alloc;
- (id) init;
- (id) copyWithZone: (void *)zone;
- (int) copyCount;
- (id) autorelease;
- (oneway void) release;
- (id) retain;
@end
/* This class implements copyWithZone, which doesn't do anything other
than increasing a counter of how many copies were made. */
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
- (id) copyWithZone: (void *)zone { copy_count++; return self; }
- (int) copyCount { return copy_count; }
- (id) autorelease { return self; }
- (oneway void) release { return; }
- (id) retain { return self; }
@synthesize a;
@synthesize b;
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
MyRootClass *argument = [[MyRootClass alloc] init];
/* This should copy argument. */
object.a = argument;
if (object.a != argument)
abort ();
/* Test that it was copied. */
if ([object.a copyCount] != 1)
abort ();
/* We just test that the retain accessors seem to work and that they
don't copy. We don't test that retain was actually called,
because if garbage collection is enabled, it may never be
called! */
object.b = argument;
if (object.b != argument)
abort ();
/* Test that it was not copied. */
if ([object.b copyCount] != 1)
abort ();
return (0);
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; @property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property (getter = getA) int a; @property (getter = getA, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property (setter = writeA:) int a; @property (setter = writeA:, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property (getter = giveMeA, setter = writeA:) int a; @property (getter = giveMeA, setter = writeA:, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; /* Use the simplest synthesized accessor (assign, nonatomic) as we are
not testing the synthesized accessors in this test, just the
property syntax. */
@property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -12,7 +12,10 @@ ...@@ -12,7 +12,10 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; /* Use the simplest synthesized accessor (assign, nonatomic) as we are
not testing the synthesized accessors in this test, just the
property syntax. */
@property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
/* { dg-do run } */
/* Test atomic, assign synthesized methods. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int a;
id b;
}
@property int a;
@property (assign) id b;
+ (id) initialize;
+ (id) alloc;
- (id) init;
@end
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
@synthesize a;
@synthesize b;
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
object.a = 40;
if (object.a != 40)
abort ();
object.b = object;
if (object.b != object)
abort ();
return 0;
}
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, October 2010. */
/* { dg-do run } */
/* Test retain and copy synthesized methods. */
#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>
@interface MyRootClass
{
Class isa;
int copy_count;
id a;
id b;
}
@property (copy) id a;
@property (retain) id b;
+ (id) initialize;
+ (id) alloc;
- (id) init;
- (id) copyWithZone: (void *)zone;
- (int) copyCount;
- (id) autorelease;
- (oneway void) release;
- (id) retain;
@end
/* This class implements copyWithZone, which doesn't do anything other
than increasing a counter of how many copies were made. */
@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
- (id) copyWithZone: (void *)zone { copy_count++; return self; }
- (int) copyCount { return copy_count; }
- (id) autorelease { return self; }
- (oneway void) release { return; }
- (id) retain { return self; }
@synthesize a;
@synthesize b;
@end
int main (void)
{
MyRootClass *object = [[MyRootClass alloc] init];
MyRootClass *argument = [[MyRootClass alloc] init];
/* This should copy argument. */
object.a = argument;
if (object.a != argument)
abort ();
/* Test that it was copied. */
if ([object.a copyCount] != 1)
abort ();
/* We just test that the retain accessors seem to work and that they
don't copy. We don't test that retain was actually called,
because if garbage collection is enabled, it may never be
called! */
object.b = argument;
if (object.b != argument)
abort ();
/* Test that it was not copied. */
if ([object.b copyCount] != 1)
abort ();
return 0;
}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property int a; @property (nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property (getter = getA) int a; @property (getter = getA, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Class isa; Class isa;
int a; int a;
} }
@property (setter = writeA:) int a; @property (setter = writeA:, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
...@@ -13,7 +13,10 @@ ...@@ -13,7 +13,10 @@
Class isa; Class isa;
int a; int a;
} }
@property (getter = giveMeA, setter = writeA:) int a; /* Use the simplest synthesized accessor (assign, nonatomic) as we are
not testing the synthesized accessors in this test, just the
property syntax. */
@property (getter = giveMeA, setter = writeA:, nonatomic) int a;
+ (id) initialize; + (id) initialize;
+ (id) alloc; + (id) alloc;
- (id) init; - (id) init;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment