summaryrefslogtreecommitdiff
path: root/libobjc/objc
diff options
context:
space:
mode:
authornicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-12 22:00:01 +0000
committernicola <nicola@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-12 22:00:01 +0000
commit1da9f882a280710491bb5a1148b12b5da60cbe82 (patch)
treec1e1a95aab3eeed0bec8d3d90946e13dff607e7d /libobjc/objc
parent76ab33ff6aebab59cae8c47c8ce8e0099b5aa55d (diff)
downloadgcc-1da9f882a280710491bb5a1148b12b5da60cbe82.tar.gz
2010-10-12 Nicola Pero <nicola.pero@meta-innovation.com>
* Makefile.in (C_SOURCE_FILES): Added methods.c. * encoding.c (method_getNumberOfArguments): New. (method_get_number_of_arguments): Call method_getNumberOfArguments. * ivars.c (ivar_getName): Check for NULL variable argument. (ivar_getOffset): Check for NULL variable argument. (ivar_getTypeEncoding): Check for NULL variable argument. (class_copyIvarList): New. * methods.c: New. * protocols.c (class_copyProtocolList): Check for Nil class_ argument. * sendmsg.c: Use 'struct objc_method *' instead of Method_t, and 'struct objc_method_list *' instead of MethodList_t. (class_getMethodImplementation): New. (class_respondsToSelector): New. (class_getInstanceMethod): New. (class_getClassMethod): New. * objc/runtime.h: Updated comments. (class_copyIvarList): New. (class_getInstanceMethod): New. (class_getClassMethod): New. (class_getMethodImplementation): New. (class_respondsToSelector): New. (method_getName): New. (method_getImplementation): New. (method_getTypeEncoding): New. (class_copyMethodList): New. (method_getNumberOfArguments): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165400 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc/objc')
-rw-r--r--libobjc/objc/runtime.h95
1 files changed, 92 insertions, 3 deletions
diff --git a/libobjc/objc/runtime.h b/libobjc/objc/runtime.h
index a52c7611857..a11d283586f 100644
--- a/libobjc/objc/runtime.h
+++ b/libobjc/objc/runtime.h
@@ -284,16 +284,27 @@ objc_EXPORT id object_getIvar (id object, Ivar variable);
object_setInstanceVariable. */
objc_EXPORT void object_setIvar (id object, Ivar variable, id value);
-/* Return the name of the instance variable. */
+/* Return the name of the instance variable. Return NULL if
+ 'variable' is NULL. */
objc_EXPORT const char * ivar_getName (Ivar variable);
/* Return the offset of the instance variable from the start of the
- object data. */
+ object data. Return 0 if 'variable' is NULL. */
objc_EXPORT ptrdiff_t ivar_getOffset (Ivar variable);
-/* Return the type encoding of the variable. */
+/* Return the type encoding of the variable. Return NULL if
+ 'variable' is NULL. */
objc_EXPORT const char * ivar_getTypeEncoding (Ivar variable);
+/* Return all the instance variables of the class. The return value
+ of the function is a pointer to an area, allocated with malloc(),
+ that contains all the instance variables of the class. It does not
+ include instance variables of superclasses. The list is terminated
+ by NULL. Optionally, if you pass a non-NULL
+ 'numberOfReturnedIvars' pointer, the unsigned int that it points to
+ will be filled with the number of instance variables returned. */
+objc_EXPORT Ivar * class_copyIvarList (Class class_, unsigned int *numberOfReturnedIvars);
+
/** Implementation: the following functions are in class.c. */
@@ -412,6 +423,84 @@ objc_EXPORT void class_setVersion (Class class_, int version);
objc_EXPORT size_t class_getInstanceSize (Class class_);
+/** Implementation: the following functions are in sendmsg.c. */
+
+/* Return the instance method with selector 'selector' of class
+ 'class_', or NULL if the class (or one of its superclasses) does
+ not implement the method. Return NULL if class_ is Nil or selector
+ is NULL. */
+objc_EXPORT Method class_getInstanceMethod (Class class_, SEL selector);
+
+/* Return the class method with selector 'selector' of class 'class_',
+ or NULL if the class (or one of its superclasses) does not
+ implement the method. Return NULL if class_ is Nil or selector is
+ NULL. */
+objc_EXPORT Method class_getClassMethod (Class class_, SEL selector);
+
+/* Return the IMP (pointer to the function implementing a method) for
+ the instance method with selector 'selector' in class 'class_'.
+ This is the same routine that is used while messaging, and should
+ be very fast. Note that you most likely would need to cast the
+ return function pointer to a function pointer with the appropriate
+ arguments and return type before calling it. To get a class
+ method, you can pass the meta-class as the class_ argument (ie, use
+ class_getMethodImplementation (object_getClass (class_),
+ selector)). Return NULL if class_ is Nil or selector is NULL. */
+objc_EXPORT IMP class_getMethodImplementation (Class class_, SEL selector);
+
+/* Compatibility Note: the Apple/NeXT runtime has the function
+ class_getMethodImplementation_stret () which currently does not
+ exist on the GNU runtime because the messaging implementation is
+ different. */
+
+/* Return YES if class 'class_' has an instance method implementing
+ selector 'selector', and NO if not. Return NO if class_ is Nil or
+ selector is NULL. If you need to check a class method, use the
+ meta-class as the class_ argument (ie, use class_respondsToSelector
+ (object_getClass (class_), selector)). */
+objc_EXPORT BOOL class_respondsToSelector (Class class_, SEL selector);
+
+
+/** Implementation: the following functions are in methods.c. */
+
+/* Return the selector for method 'method'. Return NULL if 'method'
+ is NULL.
+
+ This function is misnamed; it should be called
+ 'method_getSelector'. To get the actual name, get the selector,
+ then the name from the selector (ie, use sel_getName
+ (method_getName (method))). */
+objc_EXPORT SEL method_getName (Method method);
+
+/* Return the IMP of the method. Return NULL if 'method' is NULL. */
+objc_EXPORT IMP method_getImplementation (Method method);
+
+/* Return the type encoding of the method. Return NULL if 'method' is
+ NULL. */
+objc_EXPORT const char * method_getTypeEncoding (Method method);
+
+/* Return all the instance methods of the class. The return value of
+ the function is a pointer to an area, allocated with malloc(), that
+ contains all the instance methods of the class. It does not
+ include instance methods of superclasses. The list is terminated
+ by NULL. Optionally, if you pass a non-NULL
+ 'numberOfReturnedMethods' pointer, the unsigned int that it points
+ to will be filled with the number of instance methods returned. To
+ get the list of class methods, pass the meta-class in the 'class_'
+ argument, (ie, use class_copyMethodList (object_getClass (class_),
+ &numberOfReturnedMethods)). */
+objc_EXPORT Method * class_copyMethodList (Class class_, unsigned int *numberOfReturnedMethods);
+
+
+/** Implementation: the following functions are in encoding.c. */
+
+/* Return the number of arguments that the method 'method' expects.
+ Note that all methods need two implicit arguments ('self' for the
+ receiver, and '_cmd' for the selector). Return 0 if 'method' is
+ NULL. */
+objc_EXPORT unsigned int method_getNumberOfArguments (Method method);
+
+
/** Implementation: the following functions are in protocols.c. */
/* Return the protocol with name 'name', or nil if it the protocol is