In libobjc/: 2010-10-10 Nicola Pero <nicola.pero@meta-innovation.com>

In libobjc/:
2010-10-10  Nicola Pero  <nicola.pero@meta-innovation.com>

        * 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.

From-SVN: r165249
This commit is contained in:
Nicola Pero 2010-10-10 11:18:57 +00:00 committed by Nicola Pero
parent 32af57e226
commit 2461ab4bb7
16 changed files with 240 additions and 167 deletions

View File

@ -1,3 +1,33 @@
2010-10-10 Nicola Pero <nicola.pero@meta-innovation.com>
* 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 <nicola.pero@meta-innovation.com>
* objc-sync.c: Include objc-private/common.h.

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,5 @@
struct objc_protocol_list {
struct objc_protocol_list *next;
size_t count;
Protocol *list[1];
};

View File

@ -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
};

View File

@ -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;

View File

@ -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
<http://www.gnu.org/licenses/>. */
#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

View File

@ -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
}

View File

@ -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.
/* 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"
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
*/
/* 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