diff options
author | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-10 23:28:12 +0000 |
---|---|---|
committer | nicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-10 23:28:12 +0000 |
commit | 3c7443620817cc6069df183d192c42e9e3987d34 (patch) | |
tree | 17394fa0ccdc53e9f5134ffd956a7fcc4ca13406 /libobjc/objc | |
parent | e0931d1e10be3816ef123cc9b9735cc1fc49ead3 (diff) | |
download | gcc-3c7443620817cc6069df183d192c42e9e3987d34.tar.gz |
2010-10-11 Nicola Pero <nicola.pero@meta-innovation.com>
* objc/objc.h: Updated comments.
* objc/objc-api.h: (object_copy): Added one argument; use a
#define to maintain backwards-compatibility. Moved
_objc_object_alloc, _objc_object_copy, _objc_object_dispose and
objc_get_uninstalled_dtable into
objc/deprecated/objc_get_uninstalled_dtable.h and
objc/deprecated/objc_object_alloc.h. Include these files.
* objc/deprecated/objc_get_uninstalled_dtable.h: New.
* objc/deprecated/objc_object_alloc.h: New.
* objc/runtime.h (set_getName): New.
(sel_getType): New.
(sel_getUid): New.
(sel_registerName): New.
(sel_registerTypedName): New.
(sel_isEqual): New.
(class_createInstance): New.
(object_copy): New.
(object_dispose): New.
* objects.c: Do not include tconfig.h. Include gc_typed.h if
building the garbage collection version.
(__objc_object_alloc): Removed.
(__objc_object_copy): Removed.
(__objc_object_dispose): Removed.
(class_createInstance): New from code in class_create_instance.
Cast second argument of GC_malloc_explicitly_typed. Use
objc_calloc. Do not call _objc_object_alloc.
(class_create_instance): Call class_createInstance.
(object_copy): Added extraBytes argument. Do not call
_objc_object_copy.
(object_dispose): Do not call _objc_object_dispose.
* memory.c (objc_free): When using garbage collection, mark the
argument as unused.
* selector.c (sel_getName): New.
(sel_get_name): Call sel_getName.
(sel_getType): New.
(sel_get_type): Call sel_getType.
(sel_registerName): New.
(sel_register_name): Call sel_registerName.
(sel_registerTypedName): New.
(sel_register_typed_name): Call sel_registerTypedName.
(sel_getUid): New.
(sel_get_uid): Call sel_getUid.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165264 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/objc')
-rw-r--r-- | libobjc/objc/deprecated/objc_get_uninstalled_dtable.h | 2 | ||||
-rw-r--r-- | libobjc/objc/deprecated/objc_object_alloc.h | 8 | ||||
-rw-r--r-- | libobjc/objc/objc-api.h | 17 | ||||
-rw-r--r-- | libobjc/objc/objc.h | 22 | ||||
-rw-r--r-- | libobjc/objc/runtime.h | 64 |
5 files changed, 91 insertions, 22 deletions
diff --git a/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h b/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h new file mode 100644 index 00000000000..48d508a1592 --- /dev/null +++ b/libobjc/objc/deprecated/objc_get_uninstalled_dtable.h @@ -0,0 +1,2 @@ +objc_EXPORT struct sarray* +objc_get_uninstalled_dtable(void); diff --git a/libobjc/objc/deprecated/objc_object_alloc.h b/libobjc/objc/deprecated/objc_object_alloc.h new file mode 100644 index 00000000000..f6336ca8efa --- /dev/null +++ b/libobjc/objc/deprecated/objc_object_alloc.h @@ -0,0 +1,8 @@ +/* These functions are deprecated and currently ignored. */ +/* +** Hook functions for allocating, copying and disposing of instances +*/ +objc_EXPORT id (*_objc_object_alloc)(Class _class); +objc_EXPORT id (*_objc_object_copy)(id object); +objc_EXPORT id (*_objc_object_dispose)(id object); + diff --git a/libobjc/objc/objc-api.h b/libobjc/objc/objc-api.h index eced869d883..07637337561 100644 --- a/libobjc/objc/objc-api.h +++ b/libobjc/objc/objc-api.h @@ -193,12 +193,7 @@ objc_EXPORT Class (*_objc_lookup_class)(const char *name); */ objc_EXPORT void (*_objc_load_callback)(Class _class, Category* category); -/* -** Hook functions for allocating, copying and disposing of instances -*/ -objc_EXPORT id (*_objc_object_alloc)(Class _class); -objc_EXPORT id (*_objc_object_copy)(id object); -objc_EXPORT id (*_objc_object_dispose)(id object); +#include "deprecated/objc_object_alloc.h" /* Standard functions for memory allocation and disposal. Users should @@ -326,7 +321,12 @@ objc_EXPORT IMP method_get_imp(Method_t method); objc_EXPORT IMP get_imp (Class _class, SEL sel); -objc_EXPORT id object_copy(id object); +/* object_copy used to take a single argument in the traditional GNU + Objective-C Runtime API (the one declared here), but takes 2 in the + modern API (implemented in the actual runtime). Define the old + object_copy in terms of the new one. */ +objc_EXPORT id object_copy (id object, size_t size); +#define object_copy(X) (object_copy ((X), 0)) objc_EXPORT id object_dispose(id object); @@ -394,8 +394,7 @@ object_is_meta_class (id object) && !object_is_class (object)); } -objc_EXPORT struct sarray* -objc_get_uninstalled_dtable(void); +#include "deprecated/objc_get_uninstalled_dtable.h" #ifdef __cplusplus } diff --git a/libobjc/objc/objc.h b/libobjc/objc/objc.h index 6c3214f5e08..76812ad5f79 100644 --- a/libobjc/objc/objc.h +++ b/libobjc/objc/objc.h @@ -88,22 +88,20 @@ typedef struct objc_class *Class; #include "deprecated/MetaClass.h" #include "deprecated/struct_objc_class.h" -/* An 'id' is an object of an unknown class. The struct objc_object - is private and what you see here is only the beginning of the - struct. In theory, the fact that 'class_pointer' is public means - that if you have any object 'object', you can immediately get its - class by using '((id)object)->class_pointer', but this is not - recommended; you should use object_get_class(object) instead. +/* An 'id' is an object of an unknown class. The way the object data + is stored inside the object is private and what you see here is + only the beginning of the actual struct. The first field is always + a pointer to the Class that the object belongs to. If performance + is paramount, you can use this knowledge to get the class of an + object by doing '((id)object)->class_pointer'. */ typedef struct objc_object { /* 'class_pointer' is the Class that the object belongs to. In case - of a Class object, this pointer points to the meta class. */ - /* Note that the Apple/NeXT runtime calls this variable 'isa'. - TODO: Decide if we want to call it 'isa' too. TODO: Why not - simply hide this pointer and force users to use the proper API to - get it ? - */ + of a Class object, this pointer points to the meta class. + + Compatibility Note: The Apple/NeXT runtime calls this field + 'isa'. */ Class class_pointer; } *id; diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h index 6f25ec8afe1..73c05d96e32 100644 --- a/libobjc/objc/runtime.h +++ b/libobjc/objc/runtime.h @@ -145,7 +145,67 @@ struct objc_method_description #define _F_ONEWAY 0x10 #define _F_GCINVISIBLE 0x20 -/* TODO: Add all the functions in the API. */ + +/** Internals: the following functions are in selector.c. */ + +/* Return the name of a given selector. */ +objc_EXPORT const char *sel_getName (SEL selector); + +/* Return the type of a given selector. + + Compatibility Note: the Apple/NeXT runtime has untyped selectors, + so it does not have this function, which is specific to the GNU + Runtime. */ +objc_EXPORT const char *sel_getType (SEL selector); + +/* This is the same as sel_registerName (). Please use + sel_registerName () instead. */ +objc_EXPORT SEL sel_getUid (const char *name); + +/* Register a selector with a given name (but unspecified types). If + you know the types, it is better to call sel_registerTypedName(). + If a selector with this name already exists, it is returned. */ +objc_EXPORT SEL sel_registerName (const char *name); + +/* Register a selector with a given name and types. If a selector + with this name and types already exists, it is returned. + + Compatibility Note: the Apple/NeXT runtime has untyped selectors, + so it does not have this function, which is specific to the GNU + Runtime. */ +objc_EXPORT SEL set_registerTypedName (const char *name, const char *type); + +/* Return YES if first_selector is the same as second_selector, and NO + if not. */ +objc_EXPORT BOOL sel_isEqual (SEL first_selector, SEL second_selector); + + +/** Internals: the following functions are in objects.c. */ + +/* Create an instance of class 'class', adding extraBytes to the size + of the returned object. This method allocates the appropriate + amount of memory for the instance, initializes it to zero, then + calls all the C++ constructors on appropriate C++ instance + variables of the instance (if any) (TODO: This is not implemented + yet). */ +objc_EXPORT id class_createInstance (Class class, size_t extraBytes); + +/* Copy an object and return the copy. extraBytes should be identical + to the extraBytes parameter that was passed when creating the + original object. */ +objc_EXPORT id object_copy (id object, size_t extraBytes); + +/* Dispose of an object. This method calls the appropriate C++ + destructors on appropriate C++ instance variables of the instance + (if any) (TODO: This is not implemented yet), then frees the memory + for the instance. */ +objc_EXPORT id object_dispose (id object); + + +/* TODO: Add all the other functions in the API. */ + + +/** Internals: the following functions are in objc-foreach.c. */ /* 'objc_enumerationMutation()' is called when a collection is mutated while being "fast enumerated". That is a hard error, and @@ -199,6 +259,8 @@ struct __objcFastEnumerationState */ +/** Internals: the following functions are implemented in encoding.c. */ + /* Traditional GNU Objective-C Runtime functions that are currently used to implement method forwarding. */ |