This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch implements synthesizing accessors for Objective-C / Objective-C++ properties which are 'atomic', 'retain' or 'copy'. :-) The existing code would only work for 'assign, nonatomic' properties, in which case the getter/setter methods simply access the instance variable directly. The new code can generate more sophisticated getter/setter methods that call into helper functions in the Objective-C runtime. For the next runtime these are objc_getProperty(), objc_setProperty() and objc_copyStruct(). In the GNU runtime I used identical functions, with the exception of the last one, objc_copyStruct(), which seems to have been designed wrong (in a messy way as it requires two locks instead of one to protect the property because the runtime is unable to determine which argument is the property to protect and which argument is the external variable (!)), and I couldn't see any reason to reproduce the same error in the GNU runtime, where I used two separate functions (designed correctly) instead, called objc_getPropertyStruct() and objc_setPropertyStruct(), requiring only one lock to protect the property (as expected). These helpers are part of the runtime ABI, so the GNU runtime doesn't have to be the same as the next runtime - users never see these functions directly. But because they are part of the ABI, it's not necessarily easy to change them later once you add them. I hope ours are good. :-) Testcases are included; they all pass with the GNU runtime. They should work with the next runtime too if garbage collection is disabled and the old ABI is used, as the only difference is the usage of objc_copyStruct instead of objc_getPropertyStruct and objc_setPropertyStruct (anyway if there are any issues, we have 2 months to fix them). :-) Ok to commit to trunk ? Thanks In gcc/objc/: 2010-10-31 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-10-31 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.
Attachment:
patch.txt
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |