summaryrefslogtreecommitdiff
path: root/gcc/c-family/c-common.h
diff options
context:
space:
mode:
authorIain Sandoe <iains@gcc.gnu.org>2010-10-14 20:09:41 +0000
committerIain Sandoe <iains@gcc.gnu.org>2010-10-14 20:09:41 +0000
commit668ea4b1106d1a28e07ed653874192696840829c (patch)
tree2460cc4b29d1b167cadadbf17f50074e1a75ef92 /gcc/c-family/c-common.h
parente05eee4908da6139ecdfe1be68af5b58418ceedf (diff)
downloadgcc-668ea4b1106d1a28e07ed653874192696840829c.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. From-SVN: r165479
Diffstat (limited to 'gcc/c-family/c-common.h')
-rw-r--r--gcc/c-family/c-common.h29
1 files changed, 27 insertions, 2 deletions
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++. */