From: Nicola Pero Date: Sat, 26 Feb 2011 11:33:02 +0000 (+0000) Subject: Implemented encoding property types for new ObjC ABIs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=39113df12c87dd242b397fa9ba862bab673fad4b;p=gcc.git Implemented encoding property types for new ObjC ABIs From-SVN: r170516 --- diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e5cff3f58ab..b547316d82e 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,7 @@ +2011-02-26 Nicola Pero + + * objc-act.c (objc_v2_encode_prop_attr): Rewritten. + 2011-02-23 Nicola Pero * objc-act.c (build_private_template): Do not copy the @@ -16,7 +20,8 @@ 2011-02-21 Mike Stump - * Make-lang.in (check_objc_parallelize): Refine for 4 processor machines. + * Make-lang.in (check_objc_parallelize): Refine for 4 processor + machines. 2011-02-20 Nicola Pero diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 049dc00dba1..451143531a4 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -10495,47 +10495,79 @@ encode_field_decl (tree field_decl, int curtype, int format) kPropertyGetter = 'G', kPropertySetter = 'S', kPropertyInstanceVariable = 'V', - kPropertyType = 't', + kPropertyType = 'T', kPropertyWeak = 'W', - kPropertyStrong = 'S', + kPropertyStrong = 'P', kPropertyNonAtomic = 'N' - }; - - FIXME: Update the implementation to match. */ + }; */ tree objc_v2_encode_prop_attr (tree property) { const char *string; tree type = TREE_TYPE (property); - obstack_1grow (&util_obstack, 't'); + + obstack_1grow (&util_obstack, 'T'); encode_type (type, obstack_object_size (&util_obstack), OBJC_ENCODE_INLINE_DEFS); + if (PROPERTY_READONLY (property)) - obstack_grow (&util_obstack, ",r", 2); + obstack_grow (&util_obstack, ",R", 2); + + switch (PROPERTY_ASSIGN_SEMANTICS (property)) + { + case OBJC_PROPERTY_COPY: + obstack_grow (&util_obstack, ",C", 2); + break; + case OBJC_PROPERTY_RETAIN: + obstack_grow (&util_obstack, ",&", 2); + break; + case OBJC_PROPERTY_ASSIGN: + default: + break; + } - if (PROPERTY_ASSIGN_SEMANTICS (property) == OBJC_PROPERTY_COPY) - obstack_grow (&util_obstack, ",c", 2); + if (PROPERTY_DYNAMIC (property)) + obstack_grow (&util_obstack, ",D", 2); - if (PROPERTY_GETTER_NAME (property)) + if (PROPERTY_NONATOMIC (property)) + obstack_grow (&util_obstack, ",N", 2); + + /* Here we want to encode the getter name, but only if it's not the + standard one. */ + if (PROPERTY_GETTER_NAME (property) != PROPERTY_NAME (property)) { - obstack_grow (&util_obstack, ",g", 2); + obstack_grow (&util_obstack, ",G", 2); string = IDENTIFIER_POINTER (PROPERTY_GETTER_NAME (property)); obstack_grow (&util_obstack, string, strlen (string)); } - if (PROPERTY_SETTER_NAME (property)) + + if (!PROPERTY_READONLY (property)) { - obstack_grow (&util_obstack, ",s", 2); - string = IDENTIFIER_POINTER (PROPERTY_SETTER_NAME (property)); - obstack_grow (&util_obstack, string, strlen (string)); + /* Here we want to encode the setter name, but only if it's not + the standard one. */ + tree standard_setter = get_identifier (objc_build_property_setter_name (PROPERTY_NAME (property))); + if (PROPERTY_SETTER_NAME (property) != standard_setter) + { + obstack_grow (&util_obstack, ",S", 2); + string = IDENTIFIER_POINTER (PROPERTY_SETTER_NAME (property)); + obstack_grow (&util_obstack, string, strlen (string)); + } } - if (PROPERTY_IVAR_NAME (property)) + + /* TODO: Encode strong ('P'), weak ('W') for garbage collection. */ + + if (!PROPERTY_DYNAMIC (property)) { - obstack_grow (&util_obstack, ",i", 2); - string = IDENTIFIER_POINTER (PROPERTY_IVAR_NAME (property)); + obstack_grow (&util_obstack, ",V", 2); + if (PROPERTY_IVAR_NAME (property)) + string = IDENTIFIER_POINTER (PROPERTY_IVAR_NAME (property)); + else + string = IDENTIFIER_POINTER (PROPERTY_NAME (property)); obstack_grow (&util_obstack, string, strlen (string)); } - - obstack_1grow (&util_obstack, 0); /* null terminate string */ + + /* NULL-terminate string. */ + obstack_1grow (&util_obstack, 0); string = XOBFINISH (&util_obstack, char *); obstack_free (&util_obstack, util_firstobj); return get_identifier (string);