diff options
Diffstat (limited to 'libobjc/encoding.c')
-rw-r--r-- | libobjc/encoding.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/libobjc/encoding.c b/libobjc/encoding.c index 87517f4..b30389e 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); } /* |