From: nicola Date: Sun, 10 Oct 2010 11:18:57 +0000 (+0000) Subject: In libobjc/: X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=011c3116884b2d228d03f92f9a92a34c16cabc15 In libobjc/: 2010-10-10 Nicola Pero * Makefile.in (OBJC_DEPRECATED_H): Added struct_objc_category.h, struct_objc_ivar.h, struct_objc_ivar_list.h, struct_objc_method.h, struct_objc_method_list.h, struct_objc_module.h, struct_objc_protocol_list.h, struct_objc_symtab.h. * objc/deprecated/struct_objc_category.h: New. * objc/deprecated/struct_objc_ivar.h: New. * objc/deprecated/struct_objc_ivar_list.h: New. * objc/deprecated/struct_objc_method.h: New. * objc/deprecated/struct_objc_method_list.h: New. * objc/deprecated/struct_objc_module.h: New. * objc/deprecated/struct_objc_protocol_list.h: New. * objc/deprecated/struct_objc_symtab.h: New. * objc/deprecated/struct_objc_static_instances.h: New. * objc/objc-api.h: Definitions of deprecated structures moved into the above header fragment files in objc/deprecated/. Include the files instead of definition the structures here. Updated comments. * objc/runtime.h: Updated comments. Do not include objc-api.h. (objc_set_enumeration_mutation_handler): Renamed to objc_setEnumerationMutationHandler. * objc-foreach.c (objc_set_enumeration_mutation_handler): Renamed to objc_setEnumerationMutationHandler. * objc/objc-exception.h (objc_set_exception_matcher): Renamed to objc_setExceptionMatcher. (objc_set_uncaught_exception_handler): Renamed to objc_setUncaughtExceptionHandler. * exception.c: Same changes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165249 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index ccd88904d03..99f09c03ca5 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,35 @@ 2010-10-10 Nicola Pero + * Makefile.in (OBJC_DEPRECATED_H): Added struct_objc_category.h, + struct_objc_ivar.h, struct_objc_ivar_list.h, struct_objc_method.h, + struct_objc_method_list.h, struct_objc_module.h, + struct_objc_protocol_list.h, struct_objc_symtab.h. + * objc/deprecated/struct_objc_category.h: New. + * objc/deprecated/struct_objc_ivar.h: New. + * objc/deprecated/struct_objc_ivar_list.h: New. + * objc/deprecated/struct_objc_method.h: New. + * objc/deprecated/struct_objc_method_list.h: New. + * objc/deprecated/struct_objc_module.h: New. + * objc/deprecated/struct_objc_protocol_list.h: New. + * objc/deprecated/struct_objc_symtab.h: New. + * objc/deprecated/struct_objc_static_instances.h: New. + * objc/objc-api.h: Definitions of deprecated structures moved into + the above header fragment files in objc/deprecated/. Include the + files instead of definition the structures here. Updated + comments. + * objc/runtime.h: Updated comments. Do not include objc-api.h. + (objc_set_enumeration_mutation_handler): Renamed to + objc_setEnumerationMutationHandler. + * objc-foreach.c (objc_set_enumeration_mutation_handler): Renamed + to objc_setEnumerationMutationHandler. + * objc/objc-exception.h (objc_set_exception_matcher): Renamed to + objc_setExceptionMatcher. + (objc_set_uncaught_exception_handler): Renamed to + objc_setUncaughtExceptionHandler. + * exception.c: Same changes. + +2010-10-10 Nicola Pero + * objc-sync.c: Include objc-private/common.h. 2010-10-10 Nicola Pero diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in index 25d60770888..aeb68923a3e 100644 --- a/libobjc/Makefile.in +++ b/libobjc/Makefile.in @@ -142,9 +142,17 @@ OBJC_DEPRECATED_H = \ objc_unexpected_exception.h \ objc_valloc.h \ sarray.h \ + struct_objc_category.h \ struct_objc_class.h \ + struct_objc_ivar.h \ + struct_objc_ivar_list.h \ + struct_objc_method.h \ + struct_objc_method_list.h \ + struct_objc_module.h \ struct_objc_protocol.h \ + struct_objc_protocol_list.h \ struct_objc_selector.h \ + struct_objc_symtab.h \ typedstream.h # Objective-C source files to compile diff --git a/libobjc/exception.c b/libobjc/exception.c index 0225d6789a4..a221a3e77e3 100644 --- a/libobjc/exception.c +++ b/libobjc/exception.c @@ -69,7 +69,7 @@ static objc_exception_matcher __objc_exception_matcher = is_kind_of_exception_matcher; objc_exception_matcher -objc_set_exception_matcher (objc_exception_matcher new_matcher) +objc_setExceptionMatcher (objc_exception_matcher new_matcher) { objc_exception_matcher old_matcher = __objc_exception_matcher; __objc_exception_matcher = new_matcher; @@ -81,8 +81,8 @@ static objc_uncaught_exception_handler __objc_uncaught_exception_handler = NULL; objc_uncaught_exception_handler -objc_set_uncaught_exception_handler (objc_uncaught_exception_handler - new_handler) +objc_setUncaughtExceptionHandler (objc_uncaught_exception_handler + new_handler) { objc_uncaught_exception_handler old_handler = __objc_uncaught_exception_handler; diff --git a/libobjc/objc-foreach.c b/libobjc/objc-foreach.c index a06a77ec8e5..047f0cbbf44 100644 --- a/libobjc/objc-foreach.c +++ b/libobjc/objc-foreach.c @@ -35,7 +35,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see static void (*__objc_enumeration_mutation_handler)(id) = NULL; void -objc_set_enumeration_mutation_handler (void (*handler)(id)) +objc_setEnumerationMutationHandler (void (*handler)(id)) { __objc_enumeration_mutation_handler = handler; } diff --git a/libobjc/objc/deprecated/struct_objc_category.h b/libobjc/objc/deprecated/struct_objc_category.h new file mode 100644 index 00000000000..2b7a74bc9d7 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_category.h @@ -0,0 +1,21 @@ +/* +** The compiler generates one of these structures for each category. A class +** may have many categories and contain both instance and factory methods. +*/ +typedef struct objc_category { + const char* category_name; /* Name of the category. Name + contained in the () of the + category definition. */ + const char* class_name; /* Name of the class to which + the category belongs. */ + MethodList_t instance_methods; /* Linked list of instance + methods defined in the + category. NULL indicates no + instance methods defined. */ + MethodList_t class_methods; /* Linked list of factory + methods defined in the + category. NULL indicates no + class methods defined. */ + struct objc_protocol_list *protocols; /* List of Protocols + conformed to */ +} Category, *Category_t; diff --git a/libobjc/objc/deprecated/struct_objc_ivar.h b/libobjc/objc/deprecated/struct_objc_ivar.h new file mode 100644 index 00000000000..57170ad1160 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_ivar.h @@ -0,0 +1,15 @@ +/* +** The compiler generates one of these structures for a class that has +** instance variables defined in its specification. +*/ +typedef struct objc_ivar { + const char* ivar_name; /* Name of the instance + variable as entered in the + class definition. */ + const char* ivar_type; /* Description of the Ivar's + type. Useful for + debuggers. */ + int ivar_offset; /* Byte offset from the base + address of the instance + structure to the variable. */ +} *Ivar_t; diff --git a/libobjc/objc/deprecated/struct_objc_ivar_list.h b/libobjc/objc/deprecated/struct_objc_ivar_list.h new file mode 100644 index 00000000000..8f5051fb967 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_ivar_list.h @@ -0,0 +1,10 @@ +typedef struct objc_ivar_list { + int ivar_count; /* Number of structures (Ivar) + contained in the list. One + structure per instance + variable defined in the + class. */ + struct objc_ivar ivar_list[1]; /* Variable length + structure. */ +} IvarList, *IvarList_t; + diff --git a/libobjc/objc/deprecated/struct_objc_method.h b/libobjc/objc/deprecated/struct_objc_method.h new file mode 100644 index 00000000000..10a3b3bf7fc --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_method.h @@ -0,0 +1,21 @@ +/* +** The compiler generates one (or more) of these structures for a class that +** has methods defined in its specification. +** +** The implementation of a class can be broken into separate pieces in a file +** and categories can break them across modules. To handle this problem is a +** singly linked list of methods. +*/ +typedef struct objc_method { + SEL method_name; /* This variable is the method's + name. It is a char*. + The unique integer passed to + objc_msg_send is a char* too. + It is compared against + method_name using strcmp. */ + const char* method_types; /* Description of the method's + parameter list. Useful for + debuggers. */ + IMP method_imp; /* Address of the method in the + executable. */ +} Method, *Method_t; diff --git a/libobjc/objc/deprecated/struct_objc_method_list.h b/libobjc/objc/deprecated/struct_objc_method_list.h new file mode 100644 index 00000000000..5156cabbf2d --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_method_list.h @@ -0,0 +1,9 @@ +typedef struct objc_method_list { + struct objc_method_list* method_next; /* This variable is used to link + a method list to another. It + is a singly linked list. */ + int method_count; /* Number of methods defined in + this structure. */ + Method method_list[1]; /* Variable length + structure. */ +} MethodList, *MethodList_t; diff --git a/libobjc/objc/deprecated/struct_objc_module.h b/libobjc/objc/deprecated/struct_objc_module.h new file mode 100644 index 00000000000..57950851fae --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_module.h @@ -0,0 +1,24 @@ +/* +** The compiler generates one of these structures for each module that +** composes the executable (eg main.m). +** +** This data structure is the root of the definition tree for the module. +** +** A collect program runs between ld stages and creates a ObjC ctor array. +** That array holds a pointer to each module structure of the executable. +*/ +typedef struct objc_module { + unsigned long version; /* Version of the Module data structure. */ + unsigned long size; /* sizeof(Module) according to the compiler - + only used to sanity check that it matches + sizeof(Module) according to the + runtime. */ + const char* name; /* Name of the file used to compile the + module - not set by modern compilers for + security reasons. */ + Symtab_t symtab; /* Pointer to the Symtab of the module. The + Symtab holds an array of pointers to the + classes and categories defined in the + module. */ +} Module, *Module_t; + diff --git a/libobjc/objc/deprecated/struct_objc_protocol_list.h b/libobjc/objc/deprecated/struct_objc_protocol_list.h new file mode 100644 index 00000000000..5e5788b5039 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_protocol_list.h @@ -0,0 +1,5 @@ +struct objc_protocol_list { + struct objc_protocol_list *next; + size_t count; + Protocol *list[1]; +}; diff --git a/libobjc/objc/deprecated/struct_objc_static_instances.h b/libobjc/objc/deprecated/struct_objc_static_instances.h new file mode 100644 index 00000000000..9d889bfc08c --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_static_instances.h @@ -0,0 +1,14 @@ +/* For every class which happens to have statically allocated instances in + this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. + INSTANCES is NULL terminated and points to all statically allocated + instances of this class. */ +struct objc_static_instances +{ + char *class_name; +#ifdef __cplusplus + id instances[1]; +#else + id instances[0]; +#endif +}; + diff --git a/libobjc/objc/deprecated/struct_objc_symtab.h b/libobjc/objc/deprecated/struct_objc_symtab.h new file mode 100644 index 00000000000..8e14d63ee34 --- /dev/null +++ b/libobjc/objc/deprecated/struct_objc_symtab.h @@ -0,0 +1,23 @@ +/* Whereas a Module (defined further down) is the root (typically) of a file, + a Symtab is the root of the class and category definitions within the + module. + + A Symtab contains a variable length array of pointers to classes and + categories defined in the module. */ +typedef struct objc_symtab { + unsigned long sel_ref_cnt; /* Unknown. */ + SEL refs; /* Unknown. */ + unsigned short cls_def_cnt; /* Number of classes compiled + (defined) in the module. */ + unsigned short cat_def_cnt; /* Number of categories + compiled (defined) in the + module. */ + + void *defs[1]; /* Variable array of pointers. + cls_def_cnt of type Class + followed by cat_def_cnt of + type Category_t, followed + by a NULL terminated array + of objc_static_instances. */ +} Symtab, *Symtab_t; + diff --git a/libobjc/objc/objc-api.h b/libobjc/objc/objc-api.h index 5f9043086b7..fb60d5911fd 100644 --- a/libobjc/objc/objc-api.h +++ b/libobjc/objc/objc-api.h @@ -23,10 +23,30 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ - #ifndef __objc_api_INCLUDE_GNU #define __objc_api_INCLUDE_GNU +/* + This file declares the "traditional" GNU Objective-C Runtime API. + It is the API supported by older versions of the GNU Objective-C + Runtime. Include this file to use it. + + This API is being replaced by the "modern" GNU Objective-C Runtime + API, which is declared in objc/runtime.h. The "modern" API is very + similar to the API used by the modern Apple/NeXT runtime. + + Because the two APIs have some conflicting definitions (in + particular, Method and Category are defined differently) you should + include either objc/objc-api.h (to use the traditional GNU + Objective-C Runtime API) or objc/runtime.h (to use the modern GNU + Objective-C Runtime API), but not both. +*/ +/* +#ifdef __objc_runtime_INCLUDE_GNU +# error You can not include both objc/objc-api.h and objc/runtime.h. Include objc/objc-api.h for the traditional GNU Objective-C Runtime API and objc/runtime.h for the modern one. +#endif +*/ + #include "objc.h" #ifndef GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF # include "deprecated/hash.h" @@ -91,133 +111,14 @@ struct objc_method_description #include "deprecated/objc_error.h" -/* For every class which happens to have statically allocated instances in - this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. - INSTANCES is NULL terminated and points to all statically allocated - instances of this class. */ -struct objc_static_instances -{ - char *class_name; -#ifdef __cplusplus - id instances[1]; -#else - id instances[0]; -#endif -}; - -/* Whereas a Module (defined further down) is the root (typically) of a file, - a Symtab is the root of the class and category definitions within the - module. - - A Symtab contains a variable length array of pointers to classes and - categories defined in the module. */ -typedef struct objc_symtab { - unsigned long sel_ref_cnt; /* Unknown. */ - SEL refs; /* Unknown. */ - unsigned short cls_def_cnt; /* Number of classes compiled - (defined) in the module. */ - unsigned short cat_def_cnt; /* Number of categories - compiled (defined) in the - module. */ - - void *defs[1]; /* Variable array of pointers. - cls_def_cnt of type Class - followed by cat_def_cnt of - type Category_t, followed - by a NULL terminated array - of objc_static_instances. */ -} Symtab, *Symtab_t; - - -/* -** The compiler generates one of these structures for each module that -** composes the executable (eg main.m). -** -** This data structure is the root of the definition tree for the module. -** -** A collect program runs between ld stages and creates a ObjC ctor array. -** That array holds a pointer to each module structure of the executable. -*/ -typedef struct objc_module { - unsigned long version; /* Version of the Module data structure. */ - unsigned long size; /* sizeof(Module) according to the compiler - - only used to sanity check that it matches - sizeof(Module) according to the - runtime. */ - const char* name; /* Name of the file used to compile the - module - not set by modern compilers for - security reasons. */ - Symtab_t symtab; /* Pointer to the Symtab of the module. The - Symtab holds an array of pointers to the - classes and categories defined in the - module. */ -} Module, *Module_t; - - -/* -** The compiler generates one of these structures for a class that has -** instance variables defined in its specification. -*/ -typedef struct objc_ivar { - const char* ivar_name; /* Name of the instance - variable as entered in the - class definition. */ - const char* ivar_type; /* Description of the Ivar's - type. Useful for - debuggers. */ - int ivar_offset; /* Byte offset from the base - address of the instance - structure to the variable. */ -} *Ivar_t; - -typedef struct objc_ivar_list { - int ivar_count; /* Number of structures (Ivar) - contained in the list. One - structure per instance - variable defined in the - class. */ - struct objc_ivar ivar_list[1]; /* Variable length - structure. */ -} IvarList, *IvarList_t; - - -/* -** The compiler generates one (or more) of these structures for a class that -** has methods defined in its specification. -** -** The implementation of a class can be broken into separate pieces in a file -** and categories can break them across modules. To handle this problem is a -** singly linked list of methods. -*/ -typedef struct objc_method { - SEL method_name; /* This variable is the method's - name. It is a char*. - The unique integer passed to - objc_msg_send is a char* too. - It is compared against - method_name using strcmp. */ - const char* method_types; /* Description of the method's - parameter list. Useful for - debuggers. */ - IMP method_imp; /* Address of the method in the - executable. */ -} Method, *Method_t; - -typedef struct objc_method_list { - struct objc_method_list* method_next; /* This variable is used to link - a method list to another. It - is a singly linked list. */ - int method_count; /* Number of methods defined in - this structure. */ - Method method_list[1]; /* Variable length - structure. */ -} MethodList, *MethodList_t; - -struct objc_protocol_list { - struct objc_protocol_list *next; - size_t count; - Protocol *list[1]; -}; +#include "deprecated/struct_objc_static_instances.h" +#include "deprecated/struct_objc_symtab.h" +#include "deprecated/struct_objc_module.h" +#include "deprecated/struct_objc_ivar.h" +#include "deprecated/struct_objc_ivar_list.h" +#include "deprecated/struct_objc_method.h" +#include "deprecated/struct_objc_method_list.h" +#include "deprecated/struct_objc_protocol_list.h" /* ** This is used to assure consistent access to the info field of @@ -266,27 +167,7 @@ struct objc_protocol_list { (cls)->info >>= (HOST_BITS_PER_LONG/2); \ __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); }) -/* -** The compiler generates one of these structures for each category. A class -** may have many categories and contain both instance and factory methods. -*/ -typedef struct objc_category { - const char* category_name; /* Name of the category. Name - contained in the () of the - category definition. */ - const char* class_name; /* Name of the class to which - the category belongs. */ - MethodList_t instance_methods; /* Linked list of instance - methods defined in the - category. NULL indicates no - instance methods defined. */ - MethodList_t class_methods; /* Linked list of factory - methods defined in the - category. NULL indicates no - class methods defined. */ - struct objc_protocol_list *protocols; /* List of Protocols - conformed to */ -} Category, *Category_t; +#include "deprecated/struct_objc_category.h" /* We include message.h for compatibility with the old objc-api.h which included the declarations currently in message.h. The diff --git a/libobjc/objc/objc-exception.h b/libobjc/objc/objc-exception.h index 2fb9ba6c7dd..d584014a28d 100644 --- a/libobjc/objc/objc-exception.h +++ b/libobjc/objc/objc-exception.h @@ -89,7 +89,7 @@ typedef int (*objc_exception_matcher)(Class catch_class, id exception); multi-threaded environment because other threads may be trying to invoke the exception matcher while you change it! */ objc_exception_matcher -objc_set_exception_matcher (objc_exception_matcher new_matcher); +objc_setExceptionMatcher (objc_exception_matcher new_matcher); /* An 'objc_uncaught_exception_handler' function is a function that @@ -103,12 +103,7 @@ typedef void (*objc_uncaught_exception_handler)(id exception); it. */ objc_uncaught_exception_handler -objc_set_uncaught_exception_handler (objc_uncaught_exception_handler new_handler); - - -/* For compatibility with the Apple/NeXT runtime. */ -#define objc_setExceptionMatcher objc_set_exception_matcher -#define objc_setUncaughtExceptionHandler objc_set_uncaught_exception_handler +objc_setUncaughtExceptionHandler (objc_uncaught_exception_handler new_handler); #ifdef __cplusplus } diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index 7b16f1b09ea..c46fe670eb1 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -26,11 +26,30 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef __objc_runtime_INCLUDE_GNU #define __objc_runtime_INCLUDE_GNU -#include "objc.h" +/* + This file declares the "modern" GNU Objective-C Runtime API. + Include this file to use it. + + This API is replacing the "traditional" GNU Objective-C Runtime API + (declared in objc/objc-api.h) which is the one supported by older + versions of the GNU Objective-C Runtime. The "modern" API is very + similar to the API used by the modern Apple/NeXT runtime. + + Because the two APIs have some conflicting definitions (in + particular, Method and Category are defined differently) you should + include either objc/objc-api.h (to use the traditional GNU + Objective-C Runtime API) or objc/runtime.h (to use the modern GNU + Objective-C Runtime API), but not both. +*/ +/* +#ifdef __objc_api_INCLUDE_GNU +# error You can not include both objc/objc-api.h and objc/runtime.h. Include objc/objc-api.h for the traditional GNU Objective-C Runtime API and objc/runtime.h for the modern one. +#endif +*/ -/* The following is temporary, until all code from objc-api.h has been - moved into this file and objc-api.h will include runtime.h. */ -#include "objc-api.h" +/* TODO: This file is incomplete. */ + +#include "objc.h" /* 'objc_enumerationMutation()' is called when a collection is mutated while being "fast enumerated". That is a hard error, and @@ -63,7 +82,7 @@ objc_EXPORT void objc_enumerationMutation (id collection); You probably shouldn't use this function unless you are writing your own Foundation library. */ -objc_EXPORT void objc_set_enumeration_mutation_handler (void (*handler)(id)); +objc_EXPORT void objc_setEnumerationMutationHandler (void (*handler)(id)); /* This structure (used during fast enumeration) is automatically defined by the compiler (it is as if this definition was always @@ -82,7 +101,5 @@ struct __objcFastEnumerationState unsigned long extra[5]; }; */ -/* For compatibility with the Apple/NeXT runtime. */ -#define objc_setEnumerationMutationHandler objc_set_enumeration_mutation_handler #endif