diff options
author | iains <iains@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-14 20:09:41 +0000 |
---|---|---|
committer | iains <iains@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-14 20:09:41 +0000 |
commit | 86c110acf8328aba9f0f4ed0316be3e1972b1b9e (patch) | |
tree | 2460cc4b29d1b167cadadbf17f50074e1a75ef92 /gcc/c-family | |
parent | bc2d6e846ba5988aa6a0527cfe5c55d4afa822a0 (diff) | |
download | gcc-86c110acf8328aba9f0f4ed0316be3e1972b1b9e.tar.gz |
add @property to ObjC*
merge from FSF apple 'trunk' branch.
2006 Fariborz Jahanian <fjahanian@apple.com>
Radars 4436866, 4505126, 4506903, 4517826
gcc/c-family:
* c-common.c (c_common_resword): Define @property and its attributes.
* c-common.h: Define property attribute enum entries.
(OBJC_IS_PATTR_KEYWORD): New.
(objc_property_attribute_kind): New enum.
Declare objc_set_property_attr (), objc_add_property_variable (),
objc_build_getter_call () and objc_build_setter_call ().
* stub-objc.c (objc_set_property_attr): New stub.
(objc_add_property_variable): Likewise.
(objc_build_getter_call): Likewise.
(objc_build_setter_call) Likewise.
gcc:
* c-parser.c (c_parser, objc_property_attr_context) New flag.
(c_lex_one_token): Handle property attributes.
(c_parser_external_declaration): Handle @property.
(c_parser_declaration_or_fndef): Warn on invalid attributes before
@alias, @class, @end and @property objc keywords.
(c_parser_objc_methodprotolist): Handle @property.
(c_parser_objc_property_attrlist): New.
(c_parser_objc_at_property): New.
* c-typeck.c (build_component_ref): Handle CLASS.property syntax.
(build_modify_expr): Likewise.
gcc/cp:
* typeck.c (finish_class_member_access_expr): Handle CLASS.property
syntax.
(cp_build_modify_expr): Likewise.
* parser.c (cp_parser_objc_method_prototype_list): Handle @property.
(cp_parser_objc_method_definition_list): Likewise.
(cp_parser_objc_property_decl): New.
(cp_parser_objc_property_attrlist): New.
(cp_parser_objc_at_property): New.
gcc/objc:
* objc-act.c (CALL_EXPR_OBJC_PROPERTY_GETTER): New.
property_readonly, property_getter, property_setter, property_ivar,
property_copies, in_objc_property_setter_name_context: New vars.
(objc_set_property_attr): New.
(objc_add_property_variable): New.
(lookup_property_in_list): New.
(lookup_property): New.
(objc_build_getter_call): New.
(objc_setter_func_call): New.
(get_selector_from_reference): New.
(objc_build_setter_call): New.
(is_property): New.
(build_property_reference): New.
(objc_finish_message_expr): Detect readonly property and warn.
(objc_build_property_ivar_name): New.
(objc_build_property_setter_name): New.
(objc_gen_one_property_datum): New.
(objc_process_getter_setter): New.
(objc_synthesize_getter): New.
(objc_synthesize_setter): New.
(objc_gen_property_data): New.
(finish_class): Generate property data.
(comp_proto_with_proto): Separated from ...
(match_proto_with_proto): ... New.
(objc_lookup_ivar): Handle properties.
* objc-tree.def (PROPERTY_DECL): New tree code.
* objc-act.h: CLASS_LANG_SLOT_ELTS, PROTOCOL_LANG_SLOT_ELTS update size.
(METHOD_PROPERTY_CONTEXT): New.
(PROPERTY_NAME): New.
(PROPERTY_GETTER_NAME): New.
(PROPERTY_SETTER_NAME): New.
(PROPERTY_IVAR_NAME): New.
(PROPERTY_READONLY): New.
(PROPERTY_COPIES): New.
(TOTAL_CLASS_RAW_IVARS): New.
(CLASS_PROPERTY_DECL): New.
(IMPL_PROPERTY_DECL): New.
* objc-lang.c (objc_init_ts): Update fields for property_decl.
gcc/objcp:
* objcp-lang.c (objcxx_init_ts): Update for property_decl.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165479 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 29 | ||||
-rw-r--r-- | gcc/c-family/stub-objc.c | 24 |
4 files changed, 75 insertions, 2 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index dde5c45eb4f..5ba4659ba30 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,20 @@ +2010-10-14 Iain Sandoe <iains@gcc.gnu.org> + + merge from FSF apple 'trunk' branch. + 2006 Fariborz Jahanian <fjahanian@apple.com> + + Radars 4436866, 4505126, 4506903, 4517826 + * c-common.c (c_common_resword): Define @property and its attributes. + * c-common.h: Define property attribute enum entries. + (OBJC_IS_PATTR_KEYWORD): New. + (objc_property_attribute_kind): New enum. + Declare objc_set_property_attr (), objc_add_property_variable (), + objc_build_getter_call () and objc_build_setter_call (). + * stub-objc.c (objc_set_property_attr): New stub. + (objc_add_property_variable): Likewise. + (objc_build_getter_call): Likewise. + (objc_build_setter_call) Likewise. + 2010-10-13 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 49eb5106f63..5203c0538ee 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -543,6 +543,7 @@ const struct c_common_resword c_common_reswords[] = { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC }, { "optional", RID_AT_OPTIONAL, D_OBJC }, { "required", RID_AT_REQUIRED, D_OBJC }, + { "property", RID_AT_PROPERTY, D_OBJC }, /* These are recognized only in protocol-qualifier context (see above) */ { "bycopy", RID_BYCOPY, D_OBJC }, @@ -551,6 +552,12 @@ const struct c_common_resword c_common_reswords[] = { "inout", RID_INOUT, D_OBJC }, { "oneway", RID_ONEWAY, D_OBJC }, { "out", RID_OUT, D_OBJC }, + /* These are recognized inside a property attribute list */ + { "readonly", RID_READONLY, D_OBJC }, + { "copies", RID_COPIES, D_OBJC }, + { "getter", RID_GETTER, D_OBJC }, + { "setter", RID_SETTER, D_OBJC }, + { "ivar", RID_IVAR, D_OBJC }, }; const unsigned int num_c_common_reswords = diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 71efaf955da..8c79d27d9dd 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -80,6 +80,10 @@ enum rid are keywords only in specific contexts) */ RID_IN, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY, + /* ObjC ("PATTR" reserved words - they do not appear after a '@' + and are keywords only as property attributes) */ + RID_READONLY, RID_COPIES, RID_GETTER, RID_SETTER, RID_IVAR, + /* C (reserved and imaginary types not implemented, so any use is a syntax error) */ RID_IMAGINARY, @@ -143,7 +147,7 @@ enum rid RID_AT_PROTOCOL, RID_AT_SELECTOR, RID_AT_THROW, RID_AT_TRY, RID_AT_CATCH, RID_AT_FINALLY, RID_AT_SYNCHRONIZED, - RID_AT_OPTIONAL, RID_AT_REQUIRED, + RID_AT_OPTIONAL, RID_AT_REQUIRED, RID_AT_PROPERTY, RID_AT_INTERFACE, RID_AT_IMPLEMENTATION, @@ -181,7 +185,9 @@ enum rid RID_FIRST_AT = RID_AT_ENCODE, RID_LAST_AT = RID_AT_IMPLEMENTATION, RID_FIRST_PQ = RID_IN, - RID_LAST_PQ = RID_ONEWAY + RID_LAST_PQ = RID_ONEWAY, + RID_FIRST_PATTR = RID_READONLY, + RID_LAST_PATTR = RID_IVAR }; #define OBJC_IS_AT_KEYWORD(rid) \ @@ -192,6 +198,10 @@ enum rid ((unsigned int) (rid) >= (unsigned int) RID_FIRST_PQ && \ (unsigned int) (rid) <= (unsigned int) RID_LAST_PQ) +#define OBJC_IS_PATTR_KEYWORD(rid) \ + ((unsigned int) (rid) >= (unsigned int) RID_FIRST_PATTR && \ + (unsigned int) (rid) <= (unsigned int) RID_LAST_PATTR) + /* OBJC_IS_CXX_KEYWORD recognizes the 'CXX_OBJC' keywords (such as 'class') which are shared in a subtle way between Objective-C and C++. When the lexer is lexing in Objective-C/Objective-C++, if it @@ -420,6 +430,16 @@ extern c_language_kind c_language; #define c_dialect_cxx() ((c_language & clk_cxx) != 0) #define c_dialect_objc() ((c_language & clk_objc) != 0) +/* ObjC Property Attribute types. */ +typedef enum objc_property_attribute_kind { + OBJC_PATTR_INIT = 0, + OBJC_PATTR_READONLY = 1, + OBJC_PATTR_GETTER = 2, + OBJC_PATTR_SETTER = 3, + OBJC_PATTR_IVAR = 4, + OBJC_PATTR_COPIES = 5 +} objc_property_attribute_kind; + /* The various name of operator that appears in error messages. */ typedef enum ref_operator { /* NULL */ @@ -1009,7 +1029,12 @@ extern tree objc_generate_static_init_call (tree); extern tree objc_generate_write_barrier (tree, enum tree_code, tree); extern void objc_set_method_opt (bool); extern void objc_finish_foreach_loop (location_t, tree, tree, tree, tree, tree); +extern void objc_set_property_attr + (location_t, objc_property_attribute_kind, tree); extern bool objc_method_decl (enum tree_code); +extern void objc_add_property_variable (tree); +extern tree objc_build_getter_call (tree, tree); +extern tree objc_build_setter_call (tree, tree); /* The following are provided by the C and C++ front-ends, and called by ObjC/ObjC++. */ diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c index 6b8c33457ea..4a8a2b56b8e 100644 --- a/gcc/c-family/stub-objc.c +++ b/gcc/c-family/stub-objc.c @@ -314,6 +314,30 @@ objc_get_class_ivars (tree ARG_UNUSED (name)) return 0; } +void +objc_set_property_attr (location_t ARG_UNUSED (loc), + objc_property_attribute_kind ARG_UNUSED (code), + tree ARG_UNUSED (identifier)) +{ +} + +void +objc_add_property_variable (tree ARG_UNUSED (prop)) +{ +} + +tree +objc_build_getter_call (tree ARG_UNUSED (datum), tree ARG_UNUSED (component)) +{ + return 0; +} + +tree +objc_build_setter_call (tree ARG_UNUSED (lhs), tree ARG_UNUSED (rhs)) +{ + return 0; +} + tree objc_build_throw_stmt (location_t ARG_UNUSED (loc), tree ARG_UNUSED (expr)) { |