summaryrefslogtreecommitdiff
path: root/libobjc/encoding.c
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/encoding.c
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/encoding.c')
-rw-r--r--libobjc/encoding.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/libobjc/encoding.c b/libobjc/encoding.c
index 87517f4eaf8..b30389ee0e4 100644
--- a/libobjc/encoding.c
+++ b/libobjc/encoding.c
@@ -797,22 +797,39 @@ objc_skip_argspec (const char *type)
return type;
}
-/*
- Return the number of arguments that the method MTH expects.
- Note that all methods need two implicit arguments `self' and
- `_cmd'.
-*/
-int
-method_get_number_of_arguments (struct objc_method *mth)
+unsigned int
+method_getNumberOfArguments (struct objc_method *method)
{
- int i = 0;
- const char *type = mth->method_types;
- while (*type)
+ if (method == NULL)
+ return 0;
+ else
{
- type = objc_skip_argspec (type);
- i += 1;
+ unsigned int i = 0;
+ const char *type = method->method_types;
+ while (*type)
+ {
+ type = objc_skip_argspec (type);
+ i += 1;
+ }
+
+ if (i == 0)
+ {
+ /* This could only happen if method_types is invalid; in
+ that case, return 0. */
+ return 0;
+ }
+ else
+ {
+ /* Remove the return type. */
+ return (i - 1);
+ }
}
- return i - 1;
+}
+
+int
+method_get_number_of_arguments (struct objc_method *mth)
+{
+ return method_getNumberOfArguments (mth);
}
/*